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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值