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

    

  

原文地址:https://www.cnblogs.com/slqdba/p/10823901.html