centos7安装nginx
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装Nginx
sudo yum install -y nginx
查找编辑Nginx配置文件
whereis nginx
cd /etc/nginx
vi nginx.conf
修改
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
为如下:
server {
listen 80;
# listen [::]:80 default_server;
server_name xxx.xxx.xx.xx; # 反向代理服务器IP
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://xxx.xxx.xx.xx:3000; # web服务器IP、端口
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
启动Nginx
sudo systemctl start nginx.service
停止Nginx
sudo systemctl stoN nginx.service
卸载Nginx
sudo yum remove -y nginx