1 Nginx 添加新的网站
在nginx部署新网站的时候,我的操作步骤是:
- ubuntu 16,已用
apt-get install nginx
安装nginx
- 已在
/etc/nginx/conf.d
文件夹下添加 自定义的网站配置文件,egabc.conf
server {
listen 9000;
# 配置域名 或 ip
server_name 123.56.86.151;
error_log /root/new54/test/error_log.log;
location / {
# 配置网站根目录
root /root/new54/test;
index index.html;
# history模式下 需要加入下面这一行,vue hash模式不需要这一行
try_files $uri $uri/ /index.html;
}
}
- 在
/etc/nginx/nginx.conf
文件中,确保此文件中存在include /etc/nginx/conf.d/*.conf;
这行代码,表示刚刚新添加的网站已添加。
http {
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
}
2 启动Nginx
- 查看nginx的安装目录:whereis nginx
- 启动Nginx:/usr/sbin/nginx
- 查看进程的使用情况:ps -aux | grep nginx
- 查看端口占用情况:lsof -i:8080
3 解决Nginx出现403 forbidden (13: Permission denied)报错的四种方法
- 500 Internal Server Error
原因分析:
vim /etc/nginx/nginx.conf
并且将第一行user wwwdata
改为user root
2. 确认阿里云端口已开、ufw防火墙没有禁用端口、网站配置正确的情况下:
查看ufw防火墙:ufw status
查看网站配置:请看文章标题
查看iptables:
```bash
iptables -I INPUT -p tcp --dport 49153 -j ACCEPT
```
可能是Iptables禁用了端口。
参考文章
- https://www.cnblogs.com/huchong/p/10031523.html(文章特别好)