0

I have Ubuntu 14.04 and I want to add multiple LAMP server. How can I do this. I tried a lot of things but it doesn't work... I'm new in Linux

0
2

I assume you are using Apache 2.4.

You have to create a virtual host for every server in directory /etc/apache2/sites-enabled.

A sample file looks like:

<VirtualHost *:80>
   ServerName server1.com

   <Directory "/any-path/server1">
      Require all granted
   </Directory>

   DocumentRoot /any-path/server1

</VirtualHost>

Save this as s1.conf and make a second one s2.conf. Note that apache 2.4 requires the file extension to be .conf.

Make the directories:

mkdir /any-path/server1
mkdir /any-path/server2

Copy the default index.html:

cp /var/www/html/index.html /any-path/server1
cp /var/www/html/index.html /any-path/server2

Modify them, so you can see which server you are accessing:

nano /any-path/server1/index.html
nano /any-path/server2/index.html

If you now run service apache2 restart, then both sites should become active.

You can test that by adding entries to your /etc/hosts file:

192.168.12.165  server1.com
192.168.12.165  server2.com

But replace the IP address with the IP address of the server.

Then point your browser to www.server1.com and www.server2.com.

Note: Normally you would create your .conf files in /etc/apache2/sites-available and enable/disable them using a2ensite and a2dissite, but for testing it is easier to create them in /etc/apache2/sites-enabled.

1

Probably what you need is to set up some virtual hosts, to run different sites with different root directories.

try to have a look at one of the tutorial available on the internet.

google first result is https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Not the answer you're looking for? Browse other questions tagged or ask your own question.