![]() |
Apache Virtual host - Printable Version +- Post4VPS Forum | Free VPS Provider (https://post4vps.com) +-- Forum: VPS Discussion (https://post4vps.com/Forum-VPS-Discussion) +--- Forum: Tutorials (https://post4vps.com/Forum-Tutorials) +--- Thread: Apache Virtual host (/Thread-Apache-Virtual-host) |
Apache Virtual host - kabir145 - 04-07-2017 What is Apache Virtual Hosts? Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to use the same host name. You will also need to have Apache installed in order to work through these steps. If you haven't already done so, you can get Apache installed on your server through Code: sudo apt-get update After these Steps we have successfully Installed Apache in our Vps So now we get start for example we will create two virtual hosts 1 kabir.com and another vps13.com this is just for example you can change these name to yours so now first of all we will create directories and then we will setup the configuration file for creating directories type the following commands Code: sudo mkdir -p /var/www/html/kabir.com/ Code: sudo chown -R $USER:$USER /var/www/html/vps13.com/ Code: sudo chmod -R 755 /var/www Now we will create a Example file in our folders in order to check it its working or not So for create files in folders you will need nano if you dont have you can install it by typing the following command Code: sudo apt-get install nano Code: nano /var/www/html/kabir.com/index.html Code: <html> so we will create file for vps13.com with the following command Code: nano /var/www/html/vps13.com/index.html Code: <html> So we will start it by copying first domain file we can do it by the following command Code: sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/kabir.com.conf now open your with editor ffor modifying you do it with the following command Code: sudo nano /etc/apache2/sites-available/kabir.com.conf the file will looks like this but from this file i have removed useless comments Code: <VirtualHost *:80> As you can see there are not much we will customize it and will add some more things First of all you need to change the Serveradmin Email change it to your email from which you able to recive emails Code: serveradmin [email protected] After this we need to add two more things no 1 is servername and second is serveralias so you add them like that Code: servername kabir.com the last thing we have to change is location change its location to your site directory like here we did Code: DocumentRoot /var/www/html/kabir.com in total our virtual file should looks like this Code: <VirtualHost *:80> So now we will again copy that file for our second domain file with the following command Code: sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/vps13.com.conf now you have to open it with nano editor in order to customizze it you do it with the following command Code: sudo nano /etc/apache2/sites-available/vps13.com.conf our virtualhost file will looks like this from this i have removed useless things Code: <VirtualHost *:80> as you you can see this is not complete so we have to customize it for our second domain file First of all you need to change the Serveradmin Email change it to your email from which you able to recive emails Code: serveradmin [email protected] After this we need to add two more important things which is servername and serveralias you can add them like Code: servername vps13.com the last thing we have to change is location change its location to your site directory like here we did in our first domain but i will repeat it again Code: DocumentRoot /var/www/html/vps13.com in total our virtual file should looks like this Code: <VirtualHost *:80> So now we have created cirtualhost ffiles but now we have to enable them for that apache allow us to do it with a command you can do with the following command Code: sudo a2ensite kabir.com.conf After this we have to restart apache we can do it with the following command Code: Code: sudo service apache2 restart RE: Apache Virtual host - Han105 - 04-07-2017 is virtualhost something like name of domain ? it can be publish ? sorry, but i never done virtualhost to publish it..... |