centos7 nginx 配置,
centos7 nginx 配置,
1、下载nginx 官方下载1.6.2
2、编译安装
[root@bogon nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@bogon nginx-1.6.2]# make
[root@bogon nginx-1.6.2]# make install
3、查看nginx版本
[root@bogon nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v
4、配置前端项目
1、把项目放入/**/nginx/html 目录下
2、config配置
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/ess-web/; #ess-web 为打包的项目文件夹
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /cors/{ #“cors” 为指向标识
proxy_pass http://192.168.10.22:8080/; #“cors" 所指向的IP路径
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
开机自启
新建配置文件 /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/webserver/nginx/sbin/nginx
ExecReload=/usr/local/webserver/nginx/sbin/nginx -s reload
ExecStop=/usr/local/webserver/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl enable xxx.service
设置某个服务开机启动systemctl disable xxx.service
设置取消某个服务开机启动systemctl stop xxx.service
关闭某个服务systemctl status xxx.service
查看某个服务状态
评论暂时关闭