How to run multiple sites on one apache instance

后端 未结 2 1934
轮回少年
轮回少年 2020-12-07 08:56

Spent hours going in circles following every guide I can find on the net.

I want to have two sites running on a single apache instance, something like this - 192.168

2条回答
  •  粉色の甜心
    2020-12-07 09:23

    Yes with Virtual Host you can have as many parallel programs as you want:

    Open

    /etc/httpd/conf/httpd.conf

    Listen 81
    Listen 82
    Listen 83
    
    
        ServerAdmin webmaster@site1.com
        DocumentRoot /var/www/site1/html
        ServerName site1.com
        ErrorLog logs/site1-error_log
        CustomLog logs/site1-access_log common
        ScriptAlias /cgi-bin/ "/var/www/site1/cgi-bin/"
    
    
    
        ServerAdmin webmaster@site2.com
        DocumentRoot /var/www/site2/html
        ServerName site2.com
        ErrorLog logs/site2-error_log
        CustomLog logs/site2-access_log common
        ScriptAlias /cgi-bin/ "/var/www/site2/cgi-bin/"
    
    
    
        ServerAdmin webmaster@site3.com
        DocumentRoot /var/www/site3/html
        ServerName site3.com
        ErrorLog logs/site3-error_log
        CustomLog logs/site3-access_log common
        ScriptAlias /cgi-bin/ "/var/www/site3/cgi-bin/"
    
    

    Restart apache

    service httpd restart

    You can now refer Site1 :

    http://:81/ 
    http://:81/cgi-bin/
    

    Site2 :

    http://:82/
    http://:82/cgi-bin/
    

    Site3 :

    http://:83/ 
    http://:83/cgi-bin/
    

    If path is not hardcoded in any script then your websites should work seamlessly.

提交回复
热议问题