Linux系统Centos安装部署nginx代理
Linux安装部署Nginx环境(Centos7)包含所需依赖
一、下载nginx及依赖包
Nginx安装所需全部依赖包下载地址:
链接:https://pan.quark.cn/s/56020e643dde
下载后将文件上传到服务器
二、安装依赖GCC和gcc-c++
1.进入gcc目录安装gcc依赖
# 进入目录
[root@localhost nginx]# cd gcc
# 安装依赖
[root@localhost gcc]# rpm -Uvh *.rpm --nodeps --force
2.进入gcc-c++目录安装依赖
[root@localhost gcc]# cd ../
[root@localhost nginx]# cd gcc-c++/
[root@localhost gcc-c++]# rpm -Uvh *.rpm --nodeps --force
3.验证gcc是否安装成功
[root@localhost gcc-c++]# gcc -v
三、安装pcre
PCRE(Perl Compatible Regular Expressions)是一个轻量级的Perl函数库,包括 perl 兼容的正则表达式库。它比Boost之类的正则表达式库小得多。PCRE十分易用,同时功能也很强大,性能超过了POSIX正则表达式库和一些经典的正则表达式库
1.解压、配置、编译安装
#解压
[root@localhost nginx]# tar -zxvf pcre-8.45.tar.gz
#进入解压目录
[root@localhost nginx]# cd pcre-8.45/
#配置
[root@localhost pcre-8.45]# ./configure
#编译安装
[root@localhost pcre-8.45]# make && make install
四、安装zlib
Zlib库是一个开源的压缩解压库,它具备良好的速度和准确性
1.解压、编译、安装
#解压
[root@localhost nginx]# tar -zxvf zlib-1.2.13.tar.gz
#进入目录
[root@localhost nginx]# cd zlib-1.2.13
#配置
[root@localhost zlib-1.2.13]# ./configure
#编译安装
[root@localhost zlib-1.2.13]# make & make install
五、检查openssl是否安装,
1.检查openssl是否安装,若没有则进行安装
#检查openSSL是否安装
[root@localhost zlib-1.2.13]# openssl version
六、安装libtool依赖的M4
1.配置libtool过程可能会报错,缺少M4,则进行安装
2.解压、配置、编译、安装
#解压
[root@localhost nginx]# tar -zxvf m4-1.4.19.tar.gz
#进入目录
[root@localhost nginx]# cd m4-1.4.19
#配置
[root@localhost m4-1.4.19]# ./configure
#安装
[root@localhost m4-1.4.19]# make
[root@localhost m4-1.4.19]# make install
#检查m4是否安装
[root@localhost m4-1.4.19]# m4 --version
七、安装libtool
libtool 是一个通用库支持脚本,将使用动态库的复杂性隐藏在统一、可移植的接口中
1.解压、配置、编译、安装
#解压
[root@localhost nginx]# tar -zxvf libtool-2.4.6.tar.gz
[root@localhost nginx]# cd libtool-2.4.6
#配置
[root@localhost libtool-2.4.6]# ./configure
#安装
[root@localhost m4-1.4.19]# make
[root@localhost m4-1.4.19]# make install
八、安装nginx
1.解压、配置、编译、安装
# 解压
[root@localhost nginx]# tar -zxvf nginx-1.24.0.tar.gz
[root@localhost nginx]# cd nginx-1.24.0
# 配置 --prefix=/home/develop/nginx 参数可以配置安装目录 默认安装在/usr/local/nginx目录
[root@localhost nginx-1.24.0]# ./configure
#安装
[root@localhost m4-1.4.19]# make
[root@localhost m4-1.4.19]# make install
#进入安装目录下sbin目录
[root@localhost nginx-1.24.0]# cd /usr/local/nginx/sbin
#检查
[root@localhost nginx]# ./nginx -t
# 启动nginx
[root@localhost sbin]# ./nginx
2.添加开机启动
编辑 /etc/rc.local 文件 在文件最后加入
重启之后若发现不生效,则查看文件的权限。
/etc/rc.local 是 rc.d/rc.local的软连接,给源文件增加执行权限
重启后生效