Linux(Centos6.8)配置Nginx环境

时间:2021-05-21 03:43:25

1.环境配置

操作系统:centos6.8

[root@host79 ~]# uname -a

Linux host79.pluto 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@host79 ~]# cat /etc/issue

CentOS release 6.8 (Final)

Kernel \r on an \m

[root@host79 ~]# lsb_release -a

LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch

Distributor ID: CentOS

Description: CentOS release 6.8 (Final)

Release: 6.8

Codename: Final

2.安装pcre

[1].安装gcc++

需要提前安装 gcc++,进入安装光盘目录的软件包(/media/CentOSXX/Package)执行.

[root@host79 ~]# cd /media/CentOS_6.8_Final/Packages/

[root@host79 Packages]# rpm -ivh libstdc++-devel-4.4.7-17.el6.x86_64.rpm

[root@host79 Packages]# rpm -ivh gcc-c++-4.4.7-17.el6.x86_64.rpm

[2].解压缩pcre-xx.tar.gz 包

[root@host79 opt]# pwd

/opt

[root@host79 opt]# tar -zxvf pcre-8.37.tar.gz

[3].安装pcre-xx.tar.gz包

[root@host79 opt]# cd pcre-8.37

[root@host79 pcre-8.37]# ./configure

[root@host79 pcre-8.37]# make && make install

[root@host79 pcre-8.37]# pcre-config --version

8.37

若出现以下的情况则成功,接着执行make && make install,否则执行[1]安装GCC++

Linux(Centos6.8)配置Nginx环境

3.安装openssl|zlib

[root@host79 opt]# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

Linux(Centos6.8)配置Nginx环境

4.安装nginx

[1].把nginx安装文件放到Linux中

[root@host79 opt]# cd /mnt/hgfs/VMShare/

[root@host79 VMShare]# cp nginx-1.12.2.tar.gz /opt/

[root@host79 VMShare]# cd /opt/

#以上是将nginx压缩包移到linux中,通过vm共享文件夹实现,当然也可以通过其它方式

[2].解压编译nginx

[root@host79 opt]# tar -zxvf nginx-1.12.2.tar.gz

[root@host79 opt]# cd nginx-1.12.2

[root@host79 nginx-1.12.2]# ./configure

[root@host79 nginx-1.12.2]# make && make install

Linux(Centos6.8)配置Nginx环境

Linux(Centos6.8)配置Nginx环境

[3].测试nginx

[root@host79 opt]# cd /usr/local/nginx/sbin/

[root@host79 sbin]# ls

nginx

[root@host79 sbin]# ./nginx

[root@host79 sbin]# ps -ef|grep nginx

root      20562      1  0 22:25 ?        00:00:00 nginx: master process ./nginx

nobody    20563  20562  0 22:25 ?        00:00:00 nginx: worker process

root      20565  16136  2 22:26 pts/2    00:00:00 grep nginx

Linux(Centos6.8)配置Nginx环境

注:若出现Nginx: error while loading shared libraries: libpcre.so.1

https://blog.csdn.net/perfer258/article/details/81283656

Linux(Centos6.8)配置Nginx环境

查看防火墙开放的端口centos6.8

[root@host79 conf]# /etc/init.d/iptables status

添加端口号centos6.8

[root@host79 conf]# vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 8001 -j ACCEPT

重启防火墙centos6.8

[root@host79 conf]# service iptables restart


查看防火墙开放的端口centos7.0

firewall-cmd --list-ports

添加端口号centos7.0
重启防火墙centos7.0

https://www.jb51.net/article/144599.htm