安装nginx

1、下载需要安装的源码安装包

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

wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz

wget wget http://zlib.net/zlib-1.2.11.tar.gz

wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz

2、源码安装

需要安装C++编译环境

yum install gcc-c++

tar -xvf nginx-1.13.0.tar.gz

tar -xvf openssl-fips-2.0.10.tar.gz

tar -xvf pcre-8.40.tar.gz

tar -xvf zlib-1.2.11.tar.gz

openssl的安装:

cd 文件目录;

sudo ./config && make && make install 安装的时候报错:

Permission denied ;可能是sudo获取的权限不足吧

切换到root用户进行安装即可

whereis openssl 简单查看一下文件目录

openssl: /usr/bin/openssl /usr/share/man/man1/openssl.1ssl.gz 应该是安装成功了

pcre的安装:

cd 文件目录;

切换到root用户 su root

./configure && make && make install

zlib安装:

cd 文件目录;

切换到root用户 su root

./configure && make && make install

nginx安装:

cd 文件目录;

切换到root用户 su root

./configure && make && make install

查看nginx目录:whereis nginx; /usr/local/nginx;

测试之后直接启动成功了

如果加载不到相应的库文件的话,

.whereis libpcre.so.1命令找到libpcre.so.1在哪里
.ln -s /usr/local/lib/libpcre.so.1 /lib64命令做个软连接就可以了
 /usr/local/nginx/sbin/nginx 启动服务



安装成功!!!

3、相关命令:

/usr/local/nginx/sbin/nginx -启动服务

/usr/local/nginx/sbin/nginx -s stop -停止服务

/usr/local/nginx/sbin/nginx -h 命令帮助

/usr/local/nginx/sbin/nginx -t 验证配置文件

vim /usr/local/nginx/conf/nginx.conf nginx的配置文件

原文地址:https://www.cnblogs.com/nihaofenghao/p/6853910.html