系统:Centos6.6  64位

Nginx:  http://nginx.org/en/download.html 眼下最新版本号1.9.4 我下载1.8.0

Linux下nginx安装

下载模块依赖性Nginx须要依赖以下3个包
1.gzip 模块须要 zlib 库 ( 下载: http://www.zlib.net/ )
2.rewrite 模块须要 pcre 库 ( 下载: http://www.pcre.org/ )
3.ssl 功能须要 openssl 库 ( 下载: http://www.openssl.org/ )

依赖包安装顺序依次为:openssl、zlib、pcre, 然后安装Nginx包

Linux下nginx安装Linux下nginx安装Linux下nginx安装

假设没有安装c++编译环境,还得安装,通过yum install gcc-c++完毕安装
下载完毕后:

Linux下nginx安装

 

下一步。编译安装

openssl :

 

[[email protected]] tar zxvf openssl-fips-2.0.9.tar.gz

[[email protected]] cd openssl-fips-2.0.9

[[email protected]] ./config && make && make install

 

pcre:

 

[[email protected]] tar zxvf pcre-8.36.tar.gz

[[email protected]] cd pcre-8.36

[[email protected]]  ./configure && make && make install

 

zlib:

[[email protected]]tar zxvf zlib-1.2.8.tar.gz

[[email protected]] cd zlib-1.2.8

[[email protected]]  ./configure && make && make install

 

最后安装nginx

[[email protected]]tar zxvf nginx-1.8.0.tar.gz

[[email protected]] cd nginx-1.8.0

[[email protected]]  ./configure && make && make install

Linux下nginx安装

 

安装完毕后。可启动nginx:

Linux下nginx安装

启动命令:/usr/local/nginx/sbin/nginx
发现报错了:
error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
经网上查询,这是linux的通病

[[email protected] nginx]# sbin/nginx 
sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[[email protected] nginx]# error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[[email protected] nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so /usr/local/lib/libpcre.so.1
[[email protected] nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[[email protected] nginx]# sbin/nginx   
                           
先找到libpcre.so.1所在位置,然后做个软链接就能够了。
查看是否已启动:

Linux下nginx安装

 

通过浏览器訪问:

Linux下nginx安装

 

看到这个就说明nginx安装并启动成功。

 

ps:

启动:/usr/local/nginx/sbin/nginx
停止/又一次载入:/usr/local/nginx/sbin/nginx -s stop(quit、reload)
验证配置文件是否合法:/usr/local/nginx/sbin/nginx -t
命令帮助:/usr/local/nginx/sbin/nginx -h

相关文章:

  • 2021-06-16
猜你喜欢
  • 2022-12-23
  • 2021-11-14
  • 2021-04-21
  • 2021-04-14
  • 2021-03-31
  • 2021-11-15
相关资源
相似解决方案