这里以nginx-1.13.12版本为例子
- 首先去官网下载nginx-1.13.12.tar.gz安装包并上传到linux服务器并解压缩安装包
tar -zxvf nginx-1.13.12.tar.gz
- 在安装ngxin之前我们首先要保证linux的防火墙是关闭状态
systemctl stop firewalld.service #停止
firewall systemctl disable firewalld.service #禁止firewall开机启动�
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
- 安装c++编译环境,如果已经安装过忽略即可
yum install gcc-c++
Is this ok [y/d/N]: y
安装成功
测试
[root@centos-linux nginx-1.13.12]# gcc
gcc: 致命错误:没有输入文件
编译中断。
[root@centos-linux nginx-1.13.12]# make
make: *** 没有指明目标并且找不到 makefile。 停止。
- 安装一下nginx的一些相关依赖
yum install-y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
- 安装完依赖之后进入nginx解压后的文件夹
执行命令./configure --prefix=/home/demo/nginx
/home/demo/nginx这个路径是指定ngxin的安装目录 -
安装完成之后执行ls命令会发现解压缩文件夹下有会多出来一个Makefile文件
- 开始安装
命令:make
命令:make install
- 查看安装目录
[root@centos-linux nginx]# cd /home/demo/nginx
[root@centos-linux nginx]# ls
conf html logs sbin
- 启动nginx
[root@centos-linux nginx]# cd sbin/
[root@centos-linux sbin]# ls
nginx
[root@centos-linux sbin]# ./nginx
查看进程
[root@centos-linux sbin]# ps aux|grep nginx
root 7779 0.0 0.0 20544 612 ? Ss 05:27 0:00 nginx: master process ./nginx
nobody 7780 0.0 0.1 23076 1636 ? S 05:27 0:00 nginx: worker process
root 7884 0.0 0.0 112720 984 pts/2 S+ 05:29 0:00 grep --color=auto nginx
访问服务器测试
- 关闭nginx
[root@centos-linux sbin]# ./nginx -s stop
[root@centos-linux sbin]# ps aux|grep nginx
root 7951 0.0 0.0 112720 984 pts/2 S+ 05:33 0:00 grep --color=auto nginx
- 重新加载配置文件
./nginx -s reload