Nginx在CentOS上的安装

--------------------------先下载Nginx需要的依赖----------------------------------------------

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

mkdir /opt/nginx-source

mkdir /opt/nginx

-------------------------在/opt/nginx-source中下载源码-------------------------------------

cd  /opt/nginx-source
wget http://nginx.org/download/nginx-1.13.11.tar.gz
tar zxvf nginx-1.13.11.tar.gz

-------------------------解析Nginx源码包,输出到/opt/nginx目录下-----------------------------------

cd /opt/nginx-source/nginx-1.13.11
./configure --prefix=/opt/nginx
make
make install

./nginx -s stop #立即停止

./nginx -s quit  #安全停止

./nginx -s reload #重启

./nginx   # 启动

 

下面的配置是用80端口代理本机的8080端口

server {
        listen       80;
        server_name  localhost;

       location / {
          proxy_pass http://localhost:8080;
          proxy_redirect default;
       }

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #location / {
        #   root   html;
        #   index  index.html index.htm;
        #}
}

posted @ 2022-07-17 12:13  小大宇  阅读(5)  评论(0编辑  收藏  举报