前段时间接触到了代理服务器,在摸索下搭建了nginx环境,接下来给大家介绍一下在mac上安装nginx环境的基本步骤。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanuprm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
brew install nginx
nginx -t
正确提示:nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successfulchmod 777 file file为需要开放权限的文件路径
vim /usr/local/etc/nginx/nginx.conf
server {
listen 9999(自定义端口号);
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /Users/loki/Desktop/web/(需要部署应用的文件路径);
index index.html index.htm;
}sudo nginx
nginx -s reload #重新加载配置 nginx -s reopen #重启 nginx -s stop #停止 nginx -s quit #退出
选项:
-?,-h : 打开帮助信息
-v : 显示版本信息并退出
-V : 显示版本和配置选项信息,然后退出
-t : 检测配置文件是否有语法错误,然后退出
-q : 在检测配置文件期间屏蔽非错误信息
-s signal : 给一个 nginx 主进程发送信号:stop(停止), quit(退出), reopen(重启), reload(重新加载配置文件)
-p prefix : 设置前缀路径(默认是:/usr/local/Cellar/nginx/1.2.6/)
-c filename : 设置配置文件(默认是:/usr/local/etc/nginx/nginx.conf)
-g directives : 设置配置文件外的全局指令以上就介绍了服务器 mac安装nginx环境,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号