Nginx服務器環境搭建


1.下載Nginxd安裝包

   Nginx官網查看Nignx版本,找到stable版本下載

    wget -c https://nginx.org/download/nginx-1.16.0.tar.gz

   解壓安裝包:tar -zxvf nginx-1.16.0.tar.gz

2.配置Nginx

  root用戶執行

  >yum install gcc-c++ -y

  >yum install zlib zlib-devel -y

  >yum install pcre pcre-devel -y 

  >yum install openssl openssl-devel -y

  >./configure

  >make install

  >whereis nginx

3.Nginx啟停

  >cd /usr/local/nginx/sbin

  --啟動

  >./nginx

  --查出Nginx進程id,然后使用kill命令強制殺掉進程

  >./nginx -s stop 

  --待Nginx進程處理完任務再進行停止

  >./nginx -s quit

  --重新加載配置文件使其生效

  >./nginx -s reload

  查看nginx進程

  >ps -ef | grep nginx

  [root@pgdb_slave sbin]# ps -ef | grep nginx
  root 61636 1 0 23:01 ? 00:00:00 nginx: master process ./nginx
  nobody 61637 61636 0 23:01 ? 00:00:00 nginx: worker process
  root 61641 53355 0 23:06 pts/0 00:00:00 grep --color=auto nginx

 

3.修改Nginx端口號

  >cd /usr/local/nginx/conf

  >cp nginx.conf nginx.confbak

  >vim nginx.conf

  修改server項內的端口號

  >./nginx -s reload

  --重啟

  >./nginx -s quit

  >./nginx

4.配置開機啟動

  >echo "/usr/local/nginx/sbin" >> /etc/rc.local

5.登錄頁面

  ip:port

    

 

 

 

 

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM