apache下设置域名多站点访问
当前系统:macOS High Sierra
域名访问配置指定端口后,不同域名只能配置不同的端口
apache配置目录:
sudo vim /etc/apache2/httpd.conf
sudo vim /etc/apache2/extra/httpd-vhosts.conf
具体代码如下(/etc/apache2/extra/httpd-vhosts.conf):
Listen 8001 <VirtualHost *:8001> DocumentRoot "/Users/wanghaokun/dev/code/demo" ServerName localhost ErrorLog "/private/var/log/apache2/localhost-error_log" CustomLog "/private/var/log/apache2/localhost-access_log" common <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order deny,allow Allow from all Require all granted </Directory> </VirtualHost> Listen 8002 <VirtualHost *:8002> DocumentRoot "/Users/wanghaokun/dev/code/phalcon54/" ServerName www.testphalcon.com ErrorLog "/private/var/log/apache2/testphalcon-error_log" CustomLog "/private/var/log/apache2/testphalcon-access_log" common <Directory /> Options Indexes FollowSymLinks MultiViews AllowOverride All Order deny,allow Allow from all Require all granted </Directory> </VirtualHost>
apache启动方式:
sudo apachectl start
sudo apachectl stop
sudo apachectl restart
禁止apache访问80端口
在apache配置目录中查找80端口占用情况,修改或注释对应代码段即可