mac configure Apache2 multi-port access

1

/etc/apache2;
sudo vim httpd.conf //此操作会提示输入密码  输入密码 回车即可

2. Next, find this line

 51 #Listen 12.34.56.78:80
 52 <IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
 53     Listen 8080
 54 </IfDefine>
 55 <IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
 56     Listen 80
 57     Listen 81============>只修改此处
 58 </IfDefine>

Listen 80 as shown above to find this line, which is the default port, chances are that your default port is or Listen 8080 Listen 8001, in short, it is in line with Listen

Add the following a listening port Listen 81, so you can browse http: // localhost: 81 / a

3. Modify the project directory

246 DocumentRoot "/Users/renzhifan/www"
247 <Directory "/Users/renzhifan/www">

Both addresses must be the same, this is your site where the root directory

4. Keep looking down in this file, locate the following line of code

517 # Virtual hosts
518 Include /private/etc/apache2/extra/httpd-vhosts.conf

The front of the top row # 518 is removed

5. Modify /private/etc/apache2/extra/httpd-vhosts.conf file

 23 <VirtualHost *:80>
 24     DocumentRoot "/Users/renzhifan/www"
 25     ServerName localhost
 26 </VirtualHost>
 27 <VirtualHost *:81>
 28       DocumentRoot "/Users/renzhifan/www/traceability/public"
 29       ServerName localhost
 30  </VirtualHost>

6. OK again

//切换到工作目录

$cd /etc

//拷贝配置文件

$sudo cp php.ini.default php.ini

// 重新启动apache服务器 之后下面说这句话是正常的

$sudo apachectl -k restart

So far through http: // localhost: 81 / visit the project

Reproduced in: https: //www.jianshu.com/p/f1443fdbc780

Guess you like

Origin blog.csdn.net/weixin_34279061/article/details/91113654