nginx
nginx.conf 配置文件位置:/usr/local/etc/nginx/nginx.conf
nginx 安装目录:/usr/local/Cellar/nginx
nginx 网站目录:/usr/local/var/www
启动:sudo nginx
重启:sudo nginx -s reload
退出:sudo nginx -s quit
server配置说明
server{
listen 8000;
root /home/www/;
index index.html;
location / {
root /home/www/webroot/;
index index.html index.htm;
try_files $uri $uri/ /webroot/index.html
}
location /abc {
try_files /4.html /5.html @qwe;
}
location @qwe {
rewrite ^/(.*)$ http://www.baidu.com;
}
}
listen 表示需要监听的端口号
root 表示需要映射的根目录.
index 表示默认访问的页面
server_name 表示需要映射的域名,不配置则表示不启用域名
try_files 检测文件,如果前面的文件不正常,就使用后面的
rewrite 设置跳转页面
mac 本地服务器
文件名访问权限设置
- cd 你的文件夹路径的上一级目录。
- sudo chmod -R 777 你的文件夹名。
- 输入密码。
- 成功
本地服务器命令
//开启apache: sudo apachectl start
//重启apache: sudo apachectl restart
//关闭apache: sudo apachectl stop
网站目录:open /Library/WebServer/Documents