linux RedHat7LNMP构架搭建论坛之源码安装Nginx(2)

一、提供Perl语言兼容的正则表达式库的软件包pcre,Nginx服务程序用于实现伪静态功能的依赖包
进入目录解压文件
#cd /usr/local/src
#tar xzvf pcre-8.35.tar.gz
#cd pcre-8.35
用了--prefix参数,那么此时服务程序就会被安装到那个目录,(一般会被默认安装到/usr/local/bin目录中)

#./configure --prefix=/usr/local/pcre
译生成出真正可供用户安装服务程序的二进制可执行文件了)

#make
#make install
二 、openssl软件包是用于提供网站加密证书服务的程序文件步骤如pcre
#cd /usr/local/src
#tar xzvf openssl-1.0.1h.tar.gz
#cd openssl-1.0.1h
#./config --prefix=/usr/local/openssl
#make
#make install

三、编辑/usr/local/openssl/bin目录中,我们需要像前面的操作那样,
#vim /etc/profile这个目录中提供很多的可用命令
将这个目录添加到PATH环境变量中
74 export PATH=$PATH:/usr/local/mysql/bin:/usr/local/openssl/bin

执行source命令以便让新的PATH环境变量内容可以立即生效:
#source /etc/profile

四、zlib软件包是用于提供压缩功能的函数库文件。步骤如上:
#cd /usr/local/src
#tar xzvf zlib-1.2.8.tar.gz
#cd zlib-1.2.8

#./configure --prefix=/usr/local/zlib
#make
#make install

五 、创建一个用于执行Nginx服务程序的账户。账户名称可以自定义
#cd /usr/local/src

#useradd www -s /sbin/nologin

在使用命令编译Nginx服务程序时,需要设置特别多的参数,其中,--prefix参数用于定义服务程序稍后安装到的位置,--user与--group参数用于指定执行Nginx服务程序的用户名和用户组。在使用参数调用openssl、zlib、pcre软件包时,请写出软件源码包的解压路径,而不是程序的安装路径:
#tar xzvf nginx-1.6.0.tar.gz
#cd nginx-1.6.0/

#./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35

#make

#make install

六 、要启动Nginx服务程序并加入到开机启动项中需要在/etc/rc.d/init.d目录中创建脚本
脚本见博客http://blog.51cto.com/13608119/2176814

保存脚本文件后将其赋予755权限
#chmod 755 /etc/rc.d/init.d/nginx
然后以绝对路径的方式执行这个脚本,通过restart参数重启Nginx服务程序,
#/etc/rc.d/init.d/nginx restart
最后再使用chkconfig命令将Nginx服务程序添加至开机启动项中。
#chkconfig nginx on

Nginx安装完成,通过浏览器查看
linux RedHat7LNMP构架搭建论坛之源码安装Nginx(2)

猜你喜欢

转载自blog.51cto.com/13608119/2176817
今日推荐