首先apache文件夹
打开访达 前往->前往文件夹
输入路径
/etc/apache2/
回车进入
打开httpd.conf 找到Virtual hosts 把下面include一行前面的#去掉 结果如下
保存
打开该目录下extra目录 打开httpd-vhosts.conf
添加新开发端口
Listen 8000
<VirtualHost *:8000>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/****/****" #网站根目录目录
ServerName localhost
ErrorLog "/private/var/log/apache2/webServer_log" #错误日志生成路径
CustomLog "/private/var/log/apache2/webServer_log" common
</VirtualHost>
保存
在terminal终端重启apache
sudo apachectl restart
输入密码后回车。
接下来打开浏览器访问lcoalhost:8000
出现提示
发现没有权限访问 查看我们填写的错误日志(错误日志在上边填写的路径中 我的是/private/var/log/apache2/webServer_log)
说是没有找到对应索引也就是index.html,index.php之类的。 那我们在文件夹下创建一个test1.php文件 随便写点东西
然后再访问http://localhost:8000/test1.php
多端口配置成功