0
votes

Please help me setup correct configuration on apache server. I don't know what it is called but I want to setup multiple sites on my server (Amazon EC2 (CentOS) server). It doesn't have a domain name yet.

I have installed the required software including php (checked with phpinfo.php). It is working fine.

Now, I want to host two different php based sites on my machine.
Assume, my IP address is x.y.z.a

Directories :
/var/www/html/crm
/var/www/html/crmpanel
/var/www/html/mysite

In my httpd.conf, I have :

NameVirtualHost *:80
ServerName x.y.z.a
DocumentRoot "/var/www/html"

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName x.y.z.a
    ServerAlias x.y.z.a

    DocumentRoot "/var/www/html/crm"

    ErrorLog  /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log combined

</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName x.y.z.a
    ServerAlias x.y.z.a

    DocumentRoot "/var/www/html/crmpanel"

    ErrorLog  /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log combined

</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName x.y.z.a
    ServerAlias x.y.z.a

    DocumentRoot "/var/www/html/mysite"

    ErrorLog  /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log combined

</VirtualHost>


If I run "httpd -S", it returns 'Syntax OK'. Apache server starts without any errors.

Please help me understand what is wrong in my configuration.

1
I hope you have a different servername in each VirtualHost config. One for site1.com and the other for site2.comTJ-
No, I don't. I have not purchased any domain name yet.Riddhish Ojha

1 Answers

1
votes

You need to set the ServerName and ServerAlias (Domain names instead of the ip) for corresponding virtual host entry and also the correct DocumentRoot .

The ServerAlias is optional .

ServerName : xyz.com
ServerAlias  : www.xyz.com

please refer this blog post for detailed explanation .