nginx1.16-0安装

nginx linux版本下载地址:

http://nginx.org/download/nginx-1.16.0.tar.gz

执行wget命令下载nginx

wget http://nginx.org/download/nginx-1.16.0.tar.gz

解压安装包,执行tar zxvf nginx-1.16.0.tar.gz
转到nginx的解压目录下 cd nginx-1.16.0
在目录下执行./configure命令
过程中如果遇到
./configure: error: the HTTP rewrite module requires the PCRE library 错误

执行 yum install -y pcre-devel 安装完成后重新执行./configure

出现:

checking for OS
 + Linux 3.10.0-229.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found

执行yum -y install gcc gcc-c++ autoconf automake make

出现:./configure: error: the HTTP gzip module requires the zlib library.
执行yum install -y zlib-devel

make
make install

安装完成后,查看nginx的安装目录,执行whereis nginx
到nginx目录下执行-t命令,测试nginx是否安装成功

/usr/local/nginx/sbin/nginx -t

启动nginx

cd /usr/local/nginx/sbin
./nginx

停止

./nginx -s stop

重启

./nginx-s reload

ps aux | grep nginx命令查看nginx进程信息
netstat –nltp命令查看nginx监听的端口
编辑nginx的配置文件,把ip地址映射到配置文件中,以保证宿主可以通过ip访问nginx网站执行

vi /usr/local/nginx/conf/nginx.conf

添加ip配置
nginx1.16-0安装_第1张图片
为了nginx命令的使用,可以在bin目录下创建一个软链接执行

ln -s /usr/local/nginx/sbin/nginx /bin/nginx

在这里插入图片描述
直接执行nginx –v即可
在这里插入图片描述

你可能感兴趣的:(linux)