一般Linux下nginx通过源码安装
1.下载 nginx-1.4.0.tar.gz和pcre-8.30.tar.bz2
2.安装 pcre 让nginx支持rewrite
上传nginx-1.4.0.tar.gz和pcre-8.30.tar.bz2到/home
tar jxvf pcre-8.30.tar.bz2
cd pcre-8.30
make
make install
安装完成
3.安装nginx
tar zxvf nginx-1.4.0.tar.gz
cd nginx-1.4.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make
make install
安装完成
4.检查是否安装成功
cd /usr/local/nginx/sbin/
[root@localhost sbin]#./nginx -t
结果显示报错:
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方法:
确认是否已经安装PCRE:
[root@localhost sbin]# cd /lib/
[root@localhost lib]# ls *pcre*
libpcre.so.0 libpcre.so.0.0.1
结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
5.启动nginx
cd /usr/local/nginx/sbin 目录下面 输入 ./nginx 启动 nginx
6.检查是否启动成功
在浏览器中输入 http://ip