下载安装pcre库
pcre是一个正则表达式库,nginx的rewrite模块需要依赖该库。
下载地址:http://www.pcre.org/wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz tar -zxvf pcre-8.40.tar.gz cd pcre-8.40 ./configure make sudo make install
下载安装nginx
下载地址:http://nginx.org/wget http://nginx.org/download/nginx-1.8.1.tar.gz tar -zxvf nginx-1.8.1.tar.gz cd nginx-1.8.1 ./configure make sudo make install
验证安装是否成功
默认安装路径:/usr/local/nginx
建立软链接:sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
执行nginx命令验证是否安装成功:
sudo nginx -t
安装成功:
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
如果出现如下类似错误:
nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
建立相应的软链接然后重试:
sudo ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 #64位系统 sudo ln -s /lib/libpcre.so.0.0.1 /lib64/libpcre.so.1 #32位系统