Linux-RedHat7.2 安装nginx托管.net core2.0

1、安装依赖包

yum -y install gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel

2、下载安装包

wget http://nginx.org/download/nginx-1.13.5.tar.gz

3、解压

mkdir nginxfiles
tar -zxvf nginx-1.13.5.tar.gz -C nginxfiles

4、切换目录

cd nginxfiles/
cd nginx-1.13.5/

5、配置

./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-mail=dynamic

6、编译、安装

make
make install

7、创建软链接

ln -s /usr/local/nginx/sbin/nginx /usr/local/bin 

8、查看安装状态

cd /
nginx -v

9、托管.net core 应用

vim /usr/local/nginx/conf/nginx.conf
  location / {
            root   html;
            index  index.html index.htm;
        }

修改为:

  location / {
            proxy_pass http://127.0.0.1:5000;
            proxy_set_header Connection "";
            proxy_http_version 1.1;
            root   html;
            index  index.html index.htm;
        }

10、设置开机启动

vim /lib/systemd/system/nginx.service
--内容如下:

[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
# 启动nginx服务
systemctl start nginx.service
# 查看状态
systemctl status nginx.service

# 如果修改了文件,这个是必须的
systemctl daemon-reload
# 重新启动服务
systemctl restart nginx.service

11、使用ip访问(80端口)

ifconfig -a

 

 

posted @ 2018-09-06 13:07  狂想NICE  阅读(611)  评论(0编辑  收藏  举报