1.将Nginx安装包传输到Linux系统中temp目录下
.安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装
[root@localhost bin]# yum install gcc-c++
PCRE是一个Perl库,包括perl兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库
[root@localhost temp]# yum -y install pcre-devel
注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库
zlibzlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所有需要在Linux上安装zlib库
[root@localhost temp]# yum install -y zlib zlib-devel
OpenSSL是一个强大的安全套接字层密码库,囊括主要的密码算法,常用的密钥,所有也需要在linux上安装openssl库
[root@localhost temp]# yum install -y openssl openssl-devel
然后压缩包进行解压
[root@localhost temp]# tar zxvf nginx-1.8.0.tar.gz
去nginx的目录
[root@localhost temp]# cd nginx-1.8.0/
配置安装参数
在/var下创建temp及nginx目录
[root@localhost nginx-1.8.0]# mkdir -p /var/temp/nginx
在nginx-1.8.0解压目录下进行执行
[root@localhost nginx-1.8.0]# ./configure\
--prefix=/usr/local/nginx\
--pid-path=/var/run/nginx/nginx.pid\
--lock-path=/var/lock/nginx.lock\
--error-log-path=/var/log/nginx/error.log\
--http-log-path=/var/log/nginx/access.log\
--with-http_gzip_static_module\
--http-client-body-temp-path=/var/temp/nginx/client\
--http-proxy-temp-path=/var/temp/nginx/proxy\
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi\
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi\
--http-scgi-temp-path=/var/temp/nginx/scgi
在nginx-1.8.0目录下执行make
[root@localhost nginx-1.8.0]# make
此时出现了所有的警告都被当作是错误,需要修改
解决方法:
进入到nginx-1.8.0目录下(解压的目录)
在当前目录下找到objs文件夹,并进入,打开Makefile
[root@localhost nginx-1.8.0]# cd objs/
[root@localhost objs]# vi Makefile
进入到nginx-1.8.0目录下修改ngx_user.c文件内容
vi /root/temp/nginx-1.8.0/src/os/unix/ngx_user.c
然后在nginx-1.8.0目录下再次执行make就可以了
编译安装
在nginx-1.8.0目录下进行编译安装
进入nginx目录下的sbin目录
启动nginx
[root@localhost temp]# cd /usr/local/nginx/sbin
[root@localhost sbin]# ./nginx //启动nginx
验证是否安装成功
停止nginx