U
U
unfapable2016-03-12 18:58:11
linux
unfapable, 2016-03-12 18:58:11

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

2 answer(s)
S
Sanes, 2016-03-12
@Sanes

For these purposes, came up with control panels. Put VestaCP, chtol and do not suffer.

S
Sergey Goryachev, 2016-03-12
@webirus

you create a folder with a host name, and it is automatically created

So it is unlikely, but through the BASH script and the console I set it up.
I run the script, enter the name of the site, and everything is 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

This is my script, but you should not mindlessly copy it.
Because the paths and functions are different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question