在CentOS7上源碼安裝OpenResty
您必須將這些庫
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-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