CentOS 에서 nginx 를 컴 파일 하고 미리 보기 플러그 인 을 설정 하 는 방법 튜 토리 얼

3887 단어 centos
yum 을 이용 하여 nginx 를 설치 하 는 것 이 매우 편리 하 다 는 것 을 잘 알 고 있 지만 일부 플러그 인 은 기본적으로 설치 하지 않 습 니 다. 예 를 들 어 httpimage_filter_module, 따라서 우 리 는 nginx 를 컴 파일 하여 설치 해 야 합 니 다. 이미 우리 의 목적 을 달성 하 였 습 니 다.자세 한 방법 을 알 아 보 겠 습 니 다.
설치 의존
yum install -y pcre-devel libmxl2-devel libxslt-devel gd-devel
설치 nginx
wget -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

좋은 웹페이지 즐겨찾기