安装环境
Centos6.5
nginx下载,以1.12.2版本为例
- 通过winscp上传到centos服务器上
安装依赖pcre
- 安装pcre依赖,版本8.37
下载地址:添加链接描述 - 下载之后,通过工具,比如winscp传到服务器中
- 服务器将压缩包解压,cd进入目录
- 执行./configure,如果报错,参考以下方案
- -使用make
- make & install
如果报以下错误,参考解决,不报错请忽略,我是新装的centos,所以缺少这些库;
错误:
no acceptable C compiler found in $PATH
解决方案:原因是缺少C编译器
yum install gcc
错误:
configure: error: You need a C++ compiler for C++ support
原因:缺少C++环境
解决方案:
yum install gcc-c++
- 查看是否安装成功
pcre-config --version
yum 安装其他依赖
yum -y install make zlib zlib-devel libtool openssl openssl-devel
安装nginx
- 将压缩包解压
tar -zxvf nginx-1.12.2.tar
-
cd到nginx目录
-
执行./configure,检查是否报错
-
执行 make
-
执行 make install
-
安装完的路径:
/usr/local/nginx -
启动脚本在这个目录霞
/usr/local/nginx/sbin/ -
启动nginx,在启动脚本的目录中
./nginx
- 我这报错,你的没报请忽略
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决方案:
前提你安装了pcre库
执行以下命令查找libpcre.so.1
find / -name libpcre.so.1
结果:
/usr/local/lib/libpcre.so.1
执行命令:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
- 重新启动
./nginx
- 查看是否启动进程
ps -ef | grep nginx
测试
- 浏览器输入虚拟机的ip地址
- 弹出nginx界面就是成功的
- 此处注意防火墙要开放80端口;
- 我的环境,ip出来的apache,系统安装自带的,删除apache
rpm -e httpd
执行可能会提示删除依赖
如果出现类似“httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.10-6.el5.i386”这样的提示就说明,httpd这个服务是依赖于gnome-user-share的,我们需要先卸载gnome-user-share然后再卸载apache,执行以下命令
rpm -e gnome-user-share