码迷,mamicode.com
首页 > 其他好文 > 详细

在CentOS7上源码安装OpenResty

时间:2018-02-03 21:52:17      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:net   gunzip   iter   bsp   var   用户   src   ted   1.0   

您必须将这些库
perl 5.6.1+
libreadline
libpcre
libssl
安装在您的电脑之中。

对于 Linux来说, 您需要确认使用 ldconfig 命令,让其在您的系统环境路径中能找到它们。

 

CentOS 7 安装OpenResty所需依赖:

[root@snails ~]# yum -y install readline-devel pcre-devel openssl-devel gcc

 

下载:

[root@snails ~]# wget https://openresty.org/download/openresty-VERSION.tar.gz

[root@snails ~]# tar xzvf ngx_openresty-VERSION.tar.gz

 

编译安装:

然后在进入 ngx_openresty-VERSION/
目录, 然后输入以下命令配置:
./configure --prefix=/root/openresty

默认, --prefix=/usr/local/openresty
程序会被安装到/usr/local/openresty目录。

./configure \
--with-http_ssl_module \
--with-zlib=/root/zlib-1.2.8 \   #源码路径
--with-http_gzip_static_module \
--with-pcre=/root/pcre-8.39 \
--with-pcre-jit \
--with-http_flv_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-openssl=/root/openssl-1.0.2j \
--with-http_gunzip_module \

gmake

gmake install

make -j 4 && make install

试着使用 ./configure --help 查看更多的选项。

 

设置环境变量及文件软链接:

[root@snails ~]# ln -s /usr/local/openresty/nginx /usr/local/nginx
[root@snails ~]# vi /etc/profile
  export ORPATH=/usr/local/openresty
  export PATH=$PATH:$ORPATH/bin:$ORPATH/nginx/sbin
 

配置用户及组:

[root@snails nginx]# groupadd -f www
[root@snails nginx]# useradd -r -s /sbin/nologin -g www www
[root@snails nginx]# vi conf/nginx.conf user www www;

验证:

[root@snails nginx]# nginx

[root@snails nginx]# curl -I localhost

HTTP/1.1 200 OK

 

Nginx开机自动启动脚本:

/usr/lib/systemd/system/nginx.service

 

[root@snails nginx]# cat >> /usr/lib/systemd/system/nginx.service  << EOF
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target   
 
[Service]
Type=forking
PIDFile=/usr/local/nginx/log/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true   
 
[Install]
WantedBy=multi-user.target
 
EOF
 
配置开机服务项:
[root@snails src]# systemctl status nginx
 
[root@snails src]# systemctl enable nginx
 
[root@snails src]# systemctl start nginx
 
[root@snails src]# systemctl reload nginx

在CentOS7上源码安装OpenResty

标签:net   gunzip   iter   bsp   var   用户   src   ted   1.0   

原文地址:https://www.cnblogs.com/feixiablog/p/8410725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!