All Products
Document Center

Multi-site configuration

Last Updated: Feb 06, 2018


A user has two domain names, which are and bbb.yoursite.comThe user wants to open different subdirectory website programs when accessing the above two sites.


Upload the code

Let’s assume that the user has already uploaded code for the two sites to the subdirectories /home/www/htdocs/aaa and /home/www/htdocs/bbb. For testing convenience, we have placed two index.html files with different content in the subdirectories, and we have modified the permission of the two directories and subdirectories to www:www.Refer to command: chown www:www -R /home/www/htdocs

Modify the configuration file

Modify the httpd.conf configuration file to activate virtual nodes. Detailed steps are as follows: vi /usr/local/apache/conf/httpd.conf

As shown in the preceding figure, move the cursor to the start of the row in the red box,enter x and delete #, as shown in the following figure:Include conf/extra/httpd-vhosts.confand then move to the start of ProxyPassMatch, and add # in the front (comment out this row). At last, modify the two corresponding rows as follows:

  1. Include conf/extra/httpd-vhosts.conf
  1. #ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/home/www/logs/php-fpm.sock|fcgi://127.
  2. 0.0.1/home/www/htdocs

Press shift+, enter x!, and then press the Return key to complete modification on the file.Modify the httpd-vhosts.conf configuration file Add # in front of the rows in the red box (comment out these rows), and add the following two nodes to the end.

  1. <VirtualHost *:80>
  2. ServerAdmin
  3. DocumentRoot "/home/www/htdocs/aaa"
  4. ServerName
  5. ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/home/www/logs/php-fpm.sock|fcgi://
  6. </VirtualHost>
  7. <VirtualHost *:80>
  8. ServerAdmin
  9. DocumentRoot "/home/www/htdocs/bbb"
  10. ServerName
  11. ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/home/www/logs/php-fpm.sock|fcgi://
  12. </VirtualHost>

Press shift+, enter w!, save and exit, as shown in the following figure.

Restart service

Restart Apache, the command is as follows:

  1. /usr/local/apache/bin/apachectl restart

Test the access

Finally, test the access