1 安装nginx需要系统中有gcc环境
先查看本机是否安装gcc: gcc –version
如果没有就需要安装:gcc、gcc-c++、gcc-g、gcc-gnat、gcc-java、gcc-objc、libgcj、libgcj-devel、libgnat、libobjc、libstdc++、zlib-devel(上述软件包全部在redhat9.0 cd2中)在虚拟机中挂载redhat9.0 cd2即可
安装命令是:rpm -ivh + 软件包名
1.下载gcc-4.6.1安装包
gcc各版本浏览地址:http://ftp.gnu.org/gnu/gcc/
gcc-4.6.1浏览地址:http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/
gcc-4.6.1下载地址:http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2
2.将gcc-4.6.1.tar.bz2放到/opt文件夹下解压
[root@rekfan.com ~]# cd /opt
[root@rekfan.com opt]# tar xjvf gcc-4.6.1.tar.bz2
3.创建安装目录
[root@rekfan.com opt]# mkdir /usr/local/gcc-4.6.1/
4.进入安装目录
[root@rekfan.com opt]# cd /usr/local/gcc-4.6.1/
5.配置安装文件
[root@rekfan.com gcc-4.6.1]# /opt/gcc-4.6.1/configure --prefix=/usr/local/gcc-4.6.1
(执行源目录 /opt/gcc-4.6.1/中的configure命令,配置将gcc安装到目标目录/usr/local/gcc-4.6.1/下,这里–prefix选项代表要将该库安装在哪里,我是装在/usr/local/gcc-4.6.1目录下,后面的安装都会用到这个选项)
Nginx安装
模块依赖性nginx需要依赖的3个包
gzip 模块需要 zlib 库 “zlib-1.2.8.tar.gz”
rewrite 模块需要 pcre 库 “pcre-8.32.tar.gz”
ssl 功能需要 openssl 库 “openssl-fips-2.0.2.tar.gz”
a
安装依赖包
cd /tmp目录下,新建一个目录soft_pkg
将’openssl-fips-2.0.2.tar.gz、zlib-1.2.8.tar.gz、pcre-8.32.tar.gz’上传到上述指定目录
tar zxvf openssl-fips-2.0.2.tar.gz
cd openssl-fips-2.0.2
./config && make && make install
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure && make && make install
tar zxvf pcre-8.3z
cd pcre-8.32
./configure && make && make install
安装PCRE的时候如果报下面的.el错,则需要安装gcc-C++-4.4.7--4.el6.x86_64.rpm4
![](https://img-blog.csdn.net/20141201152505733?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl1ZmFuZ2FsaXlh/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
安装nginx包
路径指定、/tmp/soft_pkg
tar zxvf nginx-1.2.6.tar.gz
cd nginx-1.2.6
./configure --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-fips-2.0.2 --with-poll_module --with-http_stub_status_module --with-http_ssl_module
make && make install
安装检验:
/usr/local/nginx/sbin/nginx -t
启动nginx
[root@localhost sbin]# ./nginx
查看端口
[root@localhost sbin]# netstat -ntlp
昨天安装完成后启动报错,及解决办法:
NGINX启动时提示错误:
$ /usr/local/nginx/sbin/nginx -t
$ /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
$ ldd $(which /usr/local/nginx/sbin/nginx)
linux-vdso.so.1 => (0x00007fff48ff0000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003065800000)
libpcre.so.1 => not found
libssl.so.6 => /lib64/libssl.so.6 (0x0000003067000000)
解决方法:
64位系统则:
ln -s /usr/local/lib/libpcre.so.1 /lib64
32位系统则:
ln -s /usr/local/lib/libpcre.so.1 /lib