`

CentOS6.5 安装 Nginx1.7.2

 
阅读更多

一.安装

安装Nginx需要如下lib,在附件中提供下载,将他们拷贝至 /usr/local/src



 

安装命令如下:

// 安装 pcre
tar -xvzf pcre-8.35.tar.gz 
cd pcre-8.35
./configure 
make
make test
sudo make install

// 安装 zlib
tar -xvzf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make test
make install
whereis zlib

// 安装 openssl
tar -xvzf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
./config 
make
make test
sudo make install

// 安装 nginx
tar -xvzf nginx-1.7.2.tar.gz
cd nginx-1.7.2


# 下面一段没有空格   
./configure  --with-http_ssl_module  --with-pcre=/usr/local/src/pcre-8.35  --with-zlib=/usr/local/src/zlib-1.2.8  --with-openssl=/usr/local/src/openssl-1.0.1h
# 与上面的功能相同,表示可以配置更多的参数 其实不推荐
# ./configure  --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf  --pid-path=/usr/local/nginx/nginx.pid  --with-http_ssl_module  --with-pcre=/usr/local/src/pcre-8.35  --with-zlib=/usr/local/src/zlib-1.2.8  --with-openssl=/usr/local/src/openssl-1.0.1h


make
make test
make install

 

二.启动和停止

1.启动

sudo /usr/local/nginx/sbin/nginx  -c /usr/local/nginx/conf/nginx.conf 

 

参数“-c”指定了配置文件的路径,如果不加“-c”参数,Nginx会默认加载其安装目录的conf子目录中的nginx.conf文件

 

2.查看进程

ps -ef  | grep nginx
cat /usr/local/nginx/logs/nginx.pid

 

3.停止

sudo kill -QUIT 主进程号
sudo pkill -9 nginx

 

三. 一些问题

1.查看80端口占用情况

sudo netstat -tlnp|grep 80

 

2.查看nginx.conf文件是否配置正确

sudo /usr/local/nginx/sbin/nginx -t

 

3.启动时出现如下问题

/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)
find / -type f -name *libpcre.so.* 
发现 /lib64/libpcre.so.0.0.1
cd /lib64
ln -s libpcre.so.0.0.1 libpcre.so.1

 

 

 

  • 大小: 4.3 KB
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics