centos7 安裝 Nginx

一、下载Nginx的

可以到Nginx官网下载Nginx官网

[或者]

[root@localhost home]# wget https://nginx.org/download/nginx-1.13.2.tar.gz

二、安装gcc和Nginx的依赖包

[root@localhost home]# yum install -y gcc
[root@localhost home]# yum install -y pcre pcre-devel
[root@localhost home]# yum install -y zlib zlib-devel
[root@localhost home]# yum install -y openssl openssl-devel

三、安装Nginx

[root@localhost src]# tar -zxvf nginx-1.13.2.tar.gz
[root@localhost src]# cd nginx-1.13.2
[root@localhost nginx-1.13.2]# ./configure --prefix=/usr/local/mysoftware/nginx

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/mysoftware/nginx"
  nginx binary file: "/usr/local/mysoftware/nginx/sbin/nginx"
  nginx modules path: "/usr/local/mysoftware/nginx/modules"
  nginx configuration prefix: "/usr/local/mysoftware/nginx/conf"
  nginx configuration file: "/usr/local/mysoftware/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/mysoftware/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/mysoftware/nginx/logs/error.log"
  nginx http access log file: "/usr/local/mysoftware/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[root@localhost nginx-1.13.2]# make && make install

四、操作Nginx

[root@localhost ~]# cp /usr/local/mysoftware/nginx/sbin/nginx /usr/bin/nginx

##先关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service

##开启
[root@localhost ~]# nginx

##关闭Nginx
[root@localhost ~]# nginx -s stop

##重启Nginx
[root@localhost ~]# nginx -s reload

##检查Nginx是否已经启动
[root@www sbin]# ps -aux|grep nginx
root       4659  0.0  0.0  20480   608 ? Ss   23:43   0:00 nginx: master process ./nginx ##一个主进程(守护进程)
nobody     4660  0.0  0.1  20924  1588 ? S    23:43   0:00 nginx: worker process##工作进程,处理用户的httpd请求
root       4731  0.0  0.0 112660  976 pts/0  R+   23:51   0:00 grep --color=auto nginx

设置开机自启

[root@localhost ~]# vim /etc/rc.d/rc.local
# 添加如下参数
/usr/bin/nginx
[root@localhost ~] chmod +x /etc/rc.d/rc.local

猜你喜欢

转载自blog.csdn.net/post_mans/article/details/74557075