(1):进入 http://nginx.org/en/download.html 点击下载 nginx-1.8.1 pgp
(2):上传到 linux目录,对其进行解压
# tar -xvf nginx-1.8.1.tar.gz
# cd nginx-1.8.1
编译ngingx ,命令如下:
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/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_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
出现如下错误:
checking for C compiler ... not found
./configure: error: C compiler cc is not found
根据错误提示,百度搜索 安装gcc
yum -y install gcc gcc-c++ autoconf automake make
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
根据错误提示 安装
yum -y install pcre-devel
继续执行编译,报如下错误
./configure: error: SSL modules require the OpenSSL library.
根据错误信息,安装如下:
yum -y install openssl openssl-devel
重新执行编译命令,即可编译成功 如下:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/var/run/nginx/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/tmp/nginx/client/"
nginx http proxy temporary files: "/var/tmp/nginx/proxy/"
nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi/"
nginx http uwsgi temporary files: "/var/tmp/nginx/uwsgi"
nginx http scgi temporary files: "/var/tmp/nginx/scgi"
执行 如下命令,进行脚本级配置
# make
进行 安装 ,命令如下:
# make install
# 进入 /usr/local/nginx
#cd /usr/local/nginx
启动nginx
# cd sbin
#./nginx
保如下错误:
nginx: [emerg] getpwnam("nginx") failed (没有安装nginx用户导致的无法启动)
执行如下命令:
# useradd -s /sbin/nologin -M nginx
重新 启动nginx
#./nginx
报如下错误:
nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory)
由于目录没有创建,手动创建该目录
# mkdir sudo mkdir -p /var/tmp/nginx/client/
重新执行启动nginx命令
# ./nginx
恭喜 启动成功
本文档详细记录了在CentOS系统中安装Nginx-1.8.1的过程,包括从官网下载源码、解决编译时依赖的GCC、PCRE和OpenSSL库问题,以及安装完成后启动Nginx时遇到的用户权限和目录创建问题。
1158

被折叠的 条评论
为什么被折叠?



