国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

CentOS下編譯安裝nginx及配置縮略圖插件的方法教程

2024-08-30 12:28:31
字體:
來源:轉載
供稿:網友

相信大家都知道利用yum安裝nginx 非常方便,但是有些插件并不會默認安裝,比如 http_image_filter_module, 因此我們需要編譯安裝 nginx,已達到我們的目的。下面來看看詳細的方法吧。

安裝依賴

yum install -y pcre-devel libmxl2-devel libxslt-devel gd-devel

安裝 nginx

wget http://nginx.org/download/nginx-1.9.1.tar.gztar -xzvf nginx-1.9.1.tar.gzcd nginx-1.9.1./configure/ --user=nginx/ --group=nginx/ --with-http_ssl_module/ --with-http_spdy_module/ --with-http_realip_module/ --with-http_addition_module/ --with-http_xslt_module/ --with-http_image_filter_module/ --with-http_sub_module/ --with-http_auth_request_module/ --with-http_stub_status_module/ --with-http_gzip_static_module make make install

安裝完成后,可以使用如下命令來查看 nginx 安裝的模塊

[root@linux001 ~]# /usr/local/nginx/sbin/nginx -Vnginx version: nginx/1.9.1built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013TLS SNI support enabledconfigure arguments: --user=nginx --group=nginx --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_auth_request_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_image_filter_module

增加啟動腳本

新建文件 /etc/init.d/nginx , 內容如下:

#!/bin/sh## nginx - this script starts and stops the nginx daemon## chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse /#    proxy and IMAP/POP3 proxy server# processname: nginx# config:  /etc/nginx/nginx.conf# config: /usr/local/nginx/conf/nginx.conf# pidfile: /usr/local/nginx/logs/nginx.pid # Source function library.. /etc/rc.d/init.d/functions # Source networking configuration.. /etc/sysconfig/network # Check that networking is up.[ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx"prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() { # make required directories user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=/([^ ]*/).*//1/g' -` if [ -z "`grep $user /etc/passwd`" ]; then  useradd -M -s /bin/nologin $user fi options=`$nginx -V 2>&1 | grep 'configure arguments:'` for opt in $options; do  if [ `echo $opt | grep '.*-temp-path'` ]; then   value=`echo $opt | cut -d "=" -f 2`   if [ ! -d "$value" ]; then    # echo "creating" $value    mkdir -p $value && chown -R $user $value   fi  fi done} start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval} stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval} restart() { #configtest || return $? stop sleep 1 start} reload() { #configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo} force_reload() { restart} configtest() { $nginx -t -c $NGINX_CONF_FILE} rh_status() { status $prog} rh_status_q() { rh_status >/dev/null 2>&1} case "$1" in start)  rh_status_q && exit 0  $1  ;; stop)  rh_status_q || exit 0  $1  ;; restart|configtest)  $1  ;; reload)  rh_status_q || exit 7  $1  ;; force-reload)  force_reload  ;; status)  rh_status  ;; condrestart|try-restart)  rh_status_q || exit 0   ;; *)  echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"  exit 2esac

添加好 /etc/init.d/nginx 后,需要增加執行權限,然后就可以用腳本來 啟動、停止 nginx 了。

chmod a+x /etc/init.d/nginx /etc/init.d/nginx start/etc/init.d/nginx stop/etc/init.d/nginx restart/etc/init.d/nginx reload

或者以服務來 啟動、停止 nginx。

service nginx startservice nginx stopservice nginx restartservice nginx reload

設置自啟動

chkconfig --add nginxchkconfig --level 345 on

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網的支持。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 深水埗区| 阜南县| 沽源县| 探索| 简阳市| 竹北市| 洛南县| 宁蒗| 伊通| 扎囊县| 江川县| 津南区| 太白县| 建水县| 永平县| 嘉义市| 太谷县| 庄浪县| 稻城县| 武鸣县| 衡东县| 双鸭山市| 漳州市| 磴口县| 安达市| 西安市| 额敏县| 敦煌市| 师宗县| 马边| 洪洞县| 社会| 江华| 汉寿县| 冕宁县| 台中市| 高青县| 长顺县| 长子县| 石首市| 青河县|