安装相关依赖项
apt install -y curl gnupg2 ca-certificates lsb-release
安装nginx
apt install -y nginx
启动nginx
systemctl start nginx
开机时自启动
systemctl enable nginx
将本地写好的nginx.conf文件写入服务器/etc/nginx/nginx.conf中
nginx相关配置
nginx常用命令
启动nginx
/etc/init.d/nginx start
重启nginx
nginx -s reload
配置服务器安全组
一定要放行80和443端口,不然连nginx 505都看不到
nginx权限相关问题
如果是直接使用root用户进行nginx启动的话,需要将/etc/nginx/nginx.conf文件第一行的user设置为root
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
其他用户则将user设置为www-data即可
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;