18 06 2015
Nginx install on CentOS
Linux Centos7: 참고 https://blog.bypass.kr/134
의존패키지 install
1 2 3 4 |
yum -y install gcc g++ cpp gcc-c++ make yum -y install pcre-devel yum -y install openssl openssl-devel yum -y install gd gd-devel |
현재 최신 안정화 버젼 Download
wget http://nginx.org/download/nginx-1.8.0.tar.gz
압축해제
tar xvfz nginx-1.8.0.tar.gz
cd nginx-1.8.0
Compile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
./configure --prefix=/app/nginx \ --conf-path=/app/nginx/conf/nginx.conf \ --sbin-path=/app/nginx/sbin/nginx \ --lock-path=/var/lock/nginx.lock \ --pid-path=/var/run/nginx.pid \ --http-client-body-temp-path=/var/lib/nginx/body \ --http-proxy-temp-path=/var/lib/nginx/proxy \ --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \ --http-scgi-temp-path=/var/lib/nginx/scgi \ --http-log-path=/app/nginx/log/access.log \ --error-log-path=/app/nginx/log/error.log \ --with-http_addition_module \ --with-http_degradation_module \ --with-http_flv_module \ --with-http_gzip_static_module \ --with-http_image_filter_module \ --with-http_mp4_module \ --with-http_random_index_module \ --with-http_realip_module \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_sub_module \ --with-http_realip_module \ --user=nobody \ --group=nobody |
Install
1 |
make && make install |
Nginx 실행시 필요한 폴더 생성
1 |
mkdir -p /var/lib/nginx |
서비스(Service)등록
1 |
vi /etc/init.d/nginx |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
#!/bin/sh # # nginx - this script starts and stops the nginx daemin # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /app/nginx/conf/nginx.conf # pidfile: /var/run/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="/app/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/app/nginx/conf/nginx.conf" lockfile=/var/lock/nginx.lock start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 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 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 2 esac |
1 |
chmod +x /etc/init.d/nginx |
자동실행될수 있게
1 |
chkconfig nginx on |
확인
1 |
chkconfig --list nginx |
시작/종료/재시작
1 |
service nginx start/stop/restart |
참고
1.http://blog.beany.co.kr/archives/2422
2.https://www.digitalocean.com/community/tutorials/how-to-compile-nginx-from-source-on-a-centos-6-4-x64-vps
Oracle Exp/Imp로 Data 이관 Apache install Ubuntu