Hi,

Steps below works fine if I have only one folder(site) in /var/www/http/ but when I add another (folder)site into /var/www/http/ and repeat same steps just by changing the name of the (folder)site, it retrieves the previous site even if I enter the second one.

e.g. myhost1.com and myhost2.com display the content of myhost1.com

How can I enable second one?

Thanks in advance

mycomputer@ubuntu:~$ sudo mkdir /var/www/http/myhost1.com
mycomputer@ubuntu:~$ sudo gedit /var/www/http/myhost1.com/index.php
(Add this line to the file:)
<?php
echo "This is myhost1.com";
?>

mycomputer@ubuntu:~$ sudo gedit /etc/apache2/apache2.conf
(Add this line to the file:)
Include sites-enabled/

mycomputer@ubuntu:~$ sudo gedit /etc/apache2/sites-available/myhost1.com.conf
(Add these lines to the file:)
<VirtualHost myhost1.com>
	ServerAdmin webmaster@localhost

	#We want to be able to access the web site using myhost1.com or www.myhost1.com
	ServerAlias www.myhost1.com
	DocumentRoot /var/www/http/myhost1.com

	#If using awstats
	ScriptAlias /awstats/ /usr/lib/cgi-bin/

	#We want specific log file for this server
	CustomLog /var/log/apache2/myhost1.com-access.log combined
</VirtualHost>

mycomputer@ubuntu:~$ sudo ln -s /etc/apache2/sites-available/myhost1.com.conf /etc/apache2/sites-enabled/myhost1.com.conf
mycomputer@ubuntu:~$ sudo gedit /etc/hosts
(Add these lines to the file:)
127.0.0.1 localhost.localdomain localhost myhost1.com www.myhost1.com

mycomputer@ubuntu:~$ sudo /etc/init.d/apache2 reload
mycomputer@ubuntu:~$ sudo a2ensite myhost1.com.conf

Hello,

Your missing the port I believe. Here is my httpd.conf entries for a couple of sites on same server.

NameVirtualHost *:80

#<VirtualHost *:80>
#    	ServerAdmin webmaster@chartwriter.com
#    	DocumentRoot /var/www/html/default
#    	ServerName chartwriter.com
#    	ErrorLog logs/chartwriter.com-error_log
#    	CustomLog logs/chartwriter.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
    	ServerAdmin webmaster@chartwriter.com
    	DocumentRoot /var/www/html/chartwriter.com
    	ServerName chartwriter.com
    	ServerAlias www.chartwriter.com
    	ErrorLog logs/chartwriter.com-error_log
    	CustomLog logs/chartwriter.com-access_log common
</VirtualHost>

<VirtualHost *:80>
    	ServerAdmin webmaster@txlinux.com
    	DocumentRoot /var/www/html/txlinux.com
    	ServerName txlinux.com
    	ServerAlias www.txlinux.com
    	ErrorLog logs/txlinux.com-error_log
    	CustomLog logs/txlinux.com-access_log common
</VirtualHost>

The NameVirtualHost entry at the top makes the system use the first host as the default if someone just goes to the IP address.

Yes you are right. However, you use "http.d" unlike me creating individual or combined conf files in "/etc/apache2/sites-available/". I don't know the difference! Any major difference?

As you've solved my problem, I'll mark it as "Solved" after your answer rch1231

Hello,

Actually I use a domains.conf file in the /etc/http/conf directory and have this at the bottom of the httpd.conf file so I dont have to view or edit the original file:

Include /etc/httpd/conf/domains.conf

Thanks for help and informaion

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.