Answer the question
In order to leave comments, you need to log in
How to make on ubunt so that hosts are automatically created like in Open Server?
Switched from Windows to Ubuntu. Set up the server, database, php and so on. I add vhost through a script, specify the host name, it is added to Apache. Is it possible to automate this, as in an open server, you create a folder with a host name, and it is automatically created?
Answer the question
In order to leave comments, you need to log in
For these purposes, came up with control panels. Put VestaCP, chtol and do not suffer.
you create a folder with a host name, and it is automatically created
#!/bin/bash
echo -n "please enter site name: "
read new_site
mkdir $new_site
chown sergey:www-data -R $new_site
chmod 777 -R $new_site
echo "127.0.0.1 localhost $new_site" >> /etc/hosts
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$new_site.conf
echo "<VirtualHost *:80>" >> /etc/apache2/sites-available/$new_site.conf
echo "ServerName $new_site" >> /etc/apache2/sites-available/$new_site.conf
echo "DocumentRoot /home/sergey/public_html/$new_site" >> /etc/apache2/sites-available/$new_site.conf
echo "</VirtualHost>" >> /etc/apache2/sites-available/$new_site.conf
a2ensite $new_site
service apache2 reload
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question