1、rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 配置yum源
2、yum install -y nginx 下载安装nginx
3、vim /etc/nginx/nginx.conf 修改web站点配置
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
#==WEB站点配置==#
server {
listen 80 default_server;
#监听IPV4的地址与端口,地址为空表示监听所有,“default_server”即默认服务器,DNS映射一个域名
#到该主机,但是当用户访问的这个域名与这些WEB虚拟主机绑定的域名都不匹配的情况下,默认由监
#听“default_server”的虚拟主机呈现内容。
listen [::]:80 default_server;
#监听IPV6的地址与端口。
server_name _;
#域名绑定,绑定一个域名。
location / {
#匹配“/”,即用户访问“server_name/”时则呈现里面定义的内容。
root /usr/share/nginx/html;
#WEB应用根目录。
index index.html;
#默认呈现的首页文件,当用户访问域名或IP地址是自动索引呈现该文件中的内容。
# 反向代理配置
# /api/为接口前缀,如/api/login代理到http://127.0.0.1:8080/login
# 这里服务器地址最后的反斜杠不能省略
proxy_pass http://127.0.0.1:80/;
}
error_page 404 /404.html;
#HTTP请求错误响应码,反馈给用户的页面文件位置。
location = /40x.html {
#匹配上面的错误页面。
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
4、vim /usr/share/nginx/html/webapp 将项目放到所指定的发布目录下