参考:
https://nginx.org/en/download.html
# pwd
/home/soft
# yum install wget
#
yum install pcre
#
yum install openssl*
# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers make
# yum -y install gd gd2 gd-devel gd2-devel
安装 pcre , nginx 需要正则的使用 ,这个建意指定目录安装 /usr/local
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
# tar -zxvf pcre2-10.21
# cd pcre2-10.21
# ./configure --prefix=/usr/local/pcre2
# make && make install
#
./configure --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/pcre2 --with-http_realip_module --with-http_image_filter_module
出现错误
make[1]: *** [/usr/local/pcre842/Makefile] Error 127
解决方案:
在 nginx
--with-pcre=
/usr/local/pcre2 指向参数,是设置源码目录,而不是编译安装后的目录
#
./configure --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/home/soft/pcre2-10.31 --with-http_realip_module --with-http_image_filter_module
出现错误
s -I src/os/unix -I /home/soft/pcre2-10.31 -I objs \
-o objs/src/core/nginx.o \
src/core/nginx.c
In file included from src/core/ngx_core.h:71,
from src/core/nginx.c:9:
src/core/ngx_regex.h:15:18: error: pcre.h: No such file or directory
In file included from src/core/ngx_core.h:71,
from src/core/nginx.c:9:
src/core/ngx_regex.h:24: error: expected specifier-qualifier-list before ?.cre?
make[1]: *** [objs/src/core/nginx.o] Error 1
make[1]: Leaving directory `/home/soft/nginx-1.12.2'
make: *** [build] Error 2
解决方案:
# yum install pcre-devel
不通过最终还是换回了 pcre-8.42 版本
# make
# make install
配置开机启动,在 rc.local 文件后面加上启动路径
vim /etc/rc.local
# for nginx auto start
/usr/local/nginx/sbin/nginx
制做启动服务脚本 , 先查看 nginx 1.5 版
官方
https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/