趁最近失业的这段空挡,来搭建一个本身的博客。 环境:阿里云ECS云服务器 OS:centos 64位 安装方法:二进制包手动编译安装 新建用户组php
groupadd -r nginx
新建用户html
useradd -s /sbin/nologin -g nginx -r nginx
这里有一个问题为甚么要新建用户 下载 nginx-1.10.1 的二进制包 这里是地址nginx
wget http://nginx.org/download/nginx-1.10.1.tar.gz
解压到 tmp 目录centos
tar -xvf nginx-1.10.1.tar.gz
x 是 extract 简写,提取 v 是 verbose 简写,展现文件压缩或解压缩的过程 f 是 file 简写,文件名 以上这些能够查看手册得知(tar --help 或 man tar) 进入解压好的nginx-1.10.1文件夹服务器
cd nginx-1.10.1
开始预编译ui
./configure
报错,信息以下阿里云
./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.
里面的信息提示说 HTTP 重写模块须要 PCRE 库,系统给了三种解决方案.net
cd /tmp wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2
解压code
tar -xvf pcre-8.37.tar.bz2
预编译htm
cd pcre-8.37 ./configure
编译 && 安装
make && make install
清除编译安装后的垃圾文件
make clean
继续预编译 nginx-1.10.1
cd /tmp/nginx-1.10.1 ./configure
又发现报错 ./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option. 这和上次的报错信息同样,只不过模块换成了 zlib 下载 zlib
wget http://zlib.net/zlib-1.2.8.tar.gz
解压
tar -xvf zlib-1.2.8.tar.gz
编译安装
cd zlib-1.2.8 ./configure make && make install make clean
继续编译 nginx-1.10.1
cd /tmp/nginx-1.10.1 ./configure
又报错了,报错信息以下
./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option.
提示缺乏 openssl 库 下载 openssl 官网地址
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
解压 安装
tar -xvf openssl-1.0.1t.tar.gz cd openssl-1.0.1t ./config make depend
这里安装过程有些不同 再去编译nginx-1.10.1 产生和上次同样的报错 无奈,尝试屡次无果,因而用 yum 装了一遍
yum -y install openssl openssl-devel
ok 继续编译ngnix-1.10.1
./configure \ --prefix=/usr \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --pid-path=/var/run/nginx/nginx.pid \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_gzip_static_module \ --http-log-path=/var/log/nginx/access.log \ --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 \ --with-http_stub_status_module
ok没报错
make && make install
也ok
/usr/sbin/nginx
启动失败,报错信息
/usr/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
libpcore.so.1 打不开,解决办法
ln -s /usr/local/lib/libpcre.so.1 /lib64
再次启动
/usr/sbin/nginx
失败,报错信息
nginx: [emerg] mkdir() "/var/tmp/nginx/client" failed (2: No such file or directory)
建立"/var/tmp/nginx/client"文件夹失败(权限不够致使),解决办法
mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}
再次启动
/usr/sbin/nginx
成功显示 Wellcom to nginx! http://121.40.173.143/ 源码包安装最新 php-7.0.8 最新版 解压 预编译 安装 配置
参考: http://blog.csdn.net/dazhi_100/article/details/17143213 http://www.nginx.cn/install http://www.cnblogs.com/suihui/archive/2013/04/13/3018557.html http://www.qttc.net/201208194.html http://www.tuicool.com/articles/uEre6fr