nginx 安装步骤

1. 下载nginx,网址:http://nginx.org/download/

2. 解压 tar -xzvf nginx-1.6.2.tar.gz

3. 建立映像文件:mount -t iso9660 rhel-server-6.5-i386-dvd.iso /media/iso -o loop

4. 在/etc/yum.repos.d目录下,新建文件myResource.repo内容如下:

    [rhel-source]

    name=ISO - Source

    baseurl=file:///media/iso

    enabled=1

    gpgcheck=0

    baseurl是我们的映像路径,注意有三个反斜杠;enabled值表示该文件是否可用,1表示可用,0表示不可用;gpgcheck表示需要检查 gpg 签名,0表示不需要,1表示需要

5. 执行安装命令:yum groupinstall Development Tools ,安装一些开发用的工具软件。

    无意中遇到的一个问题:

    如果/etc/yum.repos.d目录下有另外一个repo文件中也定义了:baseurl=file:///mnt/iso ;那么执行yum groupinstall Development Tools命令时,寻找的

    安装包可能会定位到:/mnt/iso目录下导致找不到相应安装文件。可以将路径修改为我们建立映像的路径(baseurl=file:///media/iso)。

6. 设置nginx安装目录,方便卸载等:./configure --prefix=/usr/local/install           // 注意:--prefix=/usr/...的等号两边不要有空格;

    这一步可能会报如下错误,要求安装PCRE library 或者关联到PCRE安装目录;    

   ./configure: error: the HTTP rewrite module requires the PCRE library.
   You can either disable the module by using --without-http_rewrite_module
   option, or install the PCRE library into the system, or build the PCRE library
   statically from the source with nginx by using --with-pcre=<path> option.

    如果系统中没有安装PCRE,如果需要下载安装PCRE相关安装包,我使用的是:pcre-8.35.tar.gz。

    安装完PCRE后再次执行:./configure --prefix=/usr/local/nginx 命令,如果还是报错,可能是需要关联到PCRE路径。根据错误提示关联即可,

    例如:./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre

7. 然后执行,make命令,如果没有问题再执行:make install 安装完毕

 

说明:3,4,5 步的目的是为了安装一些相关开发工具软件,严格来说跟nginx安装没关系。目的是避免安装nginx过程中出现大规模依赖程序缺失问题。

一些错误: 

nginx无法启动: libpcre.so.1/libpcre.so.0: cannot open shared object file解决办法

解决办法zlib包缺失:安装zlib-devel包
#yum -y install  zlib-devel

 

Linux(CentOS)系统下设置nginx开机自启动  

http://blog.163.com/qsc0624@126/blog/static/140324073201312734548701/

路径配置参考:

[root@nginx nginx-1.4.2]# ./configure   --prefix=/usr   --sbin-path=/usr/sbin/nginx   --conf-path=/etc/nginx/nginx.conf   --error-log-path=/var/log/nginx/error.log   --http-log-path=/var/log/nginx/access.log   --pid-path=/var/run/nginx/nginx.pid    --lock-path=/var/lock/nginx.lock   --user=nginx   --group=nginx   --with-http_ssl_module   --with-http_flv_module   --with-http_stub_status_module   --with-http_gzip_static_module   --http-client-body-temp-path=/var/tmp/nginx/client/   --http-proxy-temp-path=/var/tmp/nginx/proxy/   --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/   --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi   --http-scgi-temp-path=/var/tmp/nginx/scgi   --with-pcre

原文地址:https://www.cnblogs.com/Jtianlin/p/4216724.html