Centos7.6源码编译安装nginx1.18.0

一、 环境准备

1. Centos7.6服务器1台

2.winscp+putty 连接工具1套

二、 开始安装

1.  用putty连接上centos7服务器,输入服务器ip,连接端口

 

 

 

 

 2. 输入服务器的超级管理员账号和密码

 

 

 3. 编译安装nginx1.8.0

[root@VM-8-16-centos ~]# yum install pcre-devel -y openssl openssl-devel gcc wget

[root@VM-8-16-centos ~]# useradd -s /sbin/nologin -M nginx

[root@VM-8-16-centos ~]# cd /opt/

[root@VM-8-16-centos opt]# wget http://nginx.org/download/nginx-1.18.0.tar.gz

[root@VM-8-16-centos opt]# tar xf nginx-1.18.0.tar.gz

[root@VM-8-16-centos opt]# cd nginx-1.18.0/

[root@VM-8-16-centos nginx-1.18.0]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.18.0 --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

[root@VM-8-16-centos nginx-1.18.0]# make && make install

[root@VM-8-16-centos ~]# cd /usr/local/

[root@VM-8-16-centos local]# ln -s nginx-1.18.0 nginx

4. 启动nginx

[root@VM-8-16-centos local]# cd /usr/local/nginx/sbin/

[root@VM-8-16-centos sbin]# ./nginx   #启动nginx

[root@VM-8-16-centos sbin]# ps -ef|grep nginx   #查看nginx进程

 

[root@VM-8-16-centos sbin]# netstat -lntup|grep 16734  #查看该进程的端口号

 

 

 [root@VM-8-16-centos sbin]# curl localhost  #访问nginx

 

 

5. nginx的常用命令

[root@VM-8-16-centos sbin]# cd /usr/local/nginx/sbin/  

[root@VM-8-16-centos sbin]# ./nginx -t    #检查nginx配置文件的语法是否ok

[root@VM-8-16-centos sbin]# ./nginx -s reload    #平滑重启nginx

[root@VM-8-16-centos sbin]# ./nginx -s stop      #停止nginx

[root@VM-8-16-centos sbin]# ./nginx -V    #查看编译安装nginx时的参数和nginx版本号

[root@VM-8-16-centos sbin]# ./nginx -v    #查看nginx的版本

 

posted @ 2020-11-18 14:12  Shanghai-Roy  阅读(527)  评论(0编辑  收藏  举报