4323213 发表于 2017-3-3 13:53:05

源码编译lnmp之简介与nginx安装

源码编译lnmp系统环境:Centos 6.6相关软件包: nginx-1.11.6.tar.gz      mysql-boost-5.7.15.tar.gz      php-5.6.28.tar.bz2下载地址:      nginx官网:http://nginx.org      mysql官网:http://dev.mysql.com/downloads/mysql/      php官网:http://jp2.php.net/downloads.php第一部分:安装nginx
一、安装nginx时必须先安装相应的编译工具
1、编译环境c/c++库,以及make和make install的编译环境:
yum -y install gcc gcc-c++ autoconf automake(提示:如果没有安装make:yum install make -y ,其中autoconf automake是make install 安装的依赖环境)
2、zlib:nginx提供gzip模块,需要zlib库支持
openssl:nginx提供ssl功能,https支持
pcre:支持地址重写rewrite功能:
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

二、建立nginx 用户和组
groupadd -r nginx
useradd -s /sbin/nologin -g nginx -r nginx
三、解压安装过程
1、解压:tar zxvf nginx-1.11.6.tar.gz
2、进入目录:cd nginx-1.11.6
./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 \            #ssl模块,https
--with-http_gzip_static_module \   #gzip模块
--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 \       #proxy代理
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi \       #fastcgi模块
--with-http_stub_status_module \                #状态检测模块
--with-http_mp4_module\                  #MP4视频模块
--with-http_flv_module\                  #flv视频模块
--with-poll_module   \                      #nginx poll epoll工作模式
--with-http_perl_module \                     #perl(类比FASTCGI理解)
--with-mail    \                         #邮件模块
--with-pcre   \                        #支持地址重写
--with-http_geoop_module                     #ipGeoIP模块处理不同国家请求
nginx具有相当多的模块,具体编译时使用那些参数呢?从安全与稳定性来讲,应该安装必要的几个模块即可,生产环境中需要什么功能,再添加即可。
./configure --prefix=/usr --user=nginx --group=nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module            四、关闭防火墙、selinux
1、关闭防火墙:iptables -F
2、关闭selinux:
             获取selinux状态:getenforce
             临时关闭selinux功能:setenforce o
             永久关闭selinux:/etc/selinux/conf 改成disabled
五、启动服务
检测配置文件语法
/usr/sbin/nginx -t
启动服务
/usr/sbin/nginx
*可以编译脚步service启动
六、测试
curl 127.0.0.1

页: [1]
查看完整版本: 源码编译lnmp之简介与nginx安装