nginx环境搭建

nginx安装步骤

安装nginx
[root@insure opt]# yum install nginx
启动nginx [root@insure opt]# service nginx start Redirecting to
/bin/systemctl start nginx.service
测试nginx是否安装成功 [root@insure opt]# wget http:
//127.0.0.1 --2019-01-09 10:03:09-- http://127.0.0.1/ Connecting to 127.0.0.1:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3700 (3.6K) [text/html] Saving to: ‘index.html’ 100%[==================================================================================================================================================================>] 3,700 --.-K/s in 0s 2019-01-09 10:03:09 (811 MB/s) - ‘index.html’ saved [3700/3700]

nginx操作

查看安装目录
[root@insure nginx]# whereis nginx nginx:
/usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz /usr/share/man/man3/nginx.3pm.gz [root@insure nginx]# cd /etc/nginx/ [root@insure nginx]# ls conf.d fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf default.d fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default

添加前端启动的配置  vi nginx.conf

server {
        listen       9000 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 / { root /opt/dev/claimconf/dist; index index.html index.html; try_files $uri $uri/ @router; } location @router { rewrite ^.*$ /index.html last; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }

修改完成保存 重启nginx

service nginx restart

猜你喜欢

转载自www.cnblogs.com/mutong1228/p/10242779.html
今日推荐