nginx
macOS
brew 安装 nginx
brew install nginxnginx
常用命令
启动
sudo nginx
重新加载配置|重启|停止|退出
nginx -s reload|reopen|stop|quit
测试配置是否有语法错误
nginx -t
配置文件
/usr/local/etc/nginx/nginx.conf
参考
ubuntu
apt-get install nginx在 /etc/nginx/sites-available 创建一个 ghost.conf 文件
nano /etc/nginx/sites-available/ghost.conf
内容
server {
listen 80;
server_name [example.com](http://example.com/);
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass [http://127.0.0.1:2368](http://127.0.0.1:2368/);
}
}
把你的配置文件软链接到 sites-enabled 文件夹下
ln -s /etc/nginx/nginx.conf /etc/nginx/sites-enabled/nginx.conf
重启 nginx
service nginx restart
错误日志位置 error_log /var/log/nginx/error.log
查看错误日志
cat /var/log/nginx/error.log;
ubuntu 默认 nginx html 目录 /usr/share/nginx/html
参考
centos
- https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
- https://www.cyberciti.biz/faq/nginx-linux-restart/
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl restart nginx