Nginx 安装
编译安装前先安装开发环境:
- yum groupinstall -y ‘Development Tools’
解决依赖关系
下载地址:http://nginx.org/en/download.html
选择最新版下载并解压 :
- wget http://nginx.org/download/nginx-1.10.1.tar.gz
- tar -zxvf nginx-1.10.1.tar.gz
- cd nginx-1.10.1
- ./configure
- make && make install
1. 问题:
checking for PCRE library … not found checking for PCRE library in/usr/local/ … not found checking for PCRE library in /usr/include/pcre/ … notfound checking for PCRE library in /usr/pkg/ … not found checking for PCRElibrary in /opt/local/ … not found ./configure: error: the HTTP rewrite modulerequires the PCRE library. You can either disable the module by using–without-http_rewrite_module option, or install the PCRE library into thesystem, or build the PCRE library statically from the source with nginx byusing –with-pcre=<path> option.
解决办法:
- yum install pcre-devel
2. 问题:
./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using –without-http_gzip_module option, orinstall the zlib library into the system, or build the zlib library staticallyfrom the source with nginx by using –with-zlib=<path> option.
解决办法:
- yum install zlib zlib-devel
3. 可能还会用到openssl组件:
- yum install openssl openssl-devel
启动与配置nginx:(nginx的安装路径为:/usr/local/nginx 可以通过whereis nginx查询)
1. 修改nginx.conf (/usr/local/nginx/etc/conf/nginx.conf) 这是nginx的配置文件
修改的方法:
进入配置文件目录 cd /usr/local/nginx/etc/conf/ 用vi或者vim进行修改 vi nginx.conf (vi和vim的用法可自行百度)
或者使用winscp直接修改配置文件
2. 运行nginx:
cd /usr/local/nginx/sbin
./nginx
可以使用如下命令查看运行情况:
ps aux |grep nginx 或者 netstat -tupln
没有错误就可以看到nginx监听80端口
3. 访问vps ip可以看到nginx欢迎页面: