配置HOSTS
#vim /private/etc/hosts
添加↓:
127.0.0.1 tp.zhy.cn
配置虚拟主机
#vim /private/etc/apache2/extra/httpd-vhosts.conf
添加↓:
ServerAdmin xxx@qq.com
DocumentRoot "/Users/zhy/Sites/xxxx_5/public/"
ServerName tp.zhy.cn
ErrorLog "/private/var/log/apache2/xx.cn-error_log"
CustomLog "/private/var/log/apache2/xx.cn-access_log" common
最后重启 apache ↓
这个命令很早以前就查过了,但是每次使用的时候还是要在网上查:
停止服务:sudo /usr/sbin/apachectl stop
开启服务:sudo /usr/sbin/apachectl start
重启服务:sudo /usr/sbin/apachectl restart
步骤:
1.打开相关配置;
2.对vhost配置文件进行参数配置,复制即可
3.重启apache
1. sudo vim /etc/apache2/httpd.conf
开启php模块,去掉前边的分号
2。打开引入vhost文件.
sudo vi /etc/apache2/extra/httpd-vhosts.conf
输入下面代码:
ServerName www.mall.com [此处需修改成你的]
DocumentRoot "/Library/WebServer/Documents/mall"[此处需修改成你的]
[此处需修改成你的]
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.php
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
ServerName localhost
DocumentRoot "/Library/WebServer/Documents"[此处需修改成你的]
[此处需修改成你的]
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.php
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
3.重启apache
sudo apachectl restart
网友评论