Configure nginx180 for CentOS

Source: Internet
Author: User
: This article describes how to configure nginx180 for CentOS. For more information about PHP tutorials, see. Configure nginx1.8.0 for CentOS

  • Environment preparation
yum -y install gcc gcc-c++ autoconf automake makeyum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
  • Download nginx, decompress, compile, and install
wget  http://nginx.org/download/nginx-1.8.0.tar.gztar zxvf nginx-1.8.0.tar.gzcd nginx-1.8.0./configuremake && make install
  • Start nginx
/usr/local/nginx/sbin/nginx

In this case, you can access the local ip address through a browser. the following fields are displayed:

  • Start nginx

First, create an nginx file in the/etc/init. d/directory of the linux system and run the following command:
Vi/etc/init. d/nginx
Add the following command to the script:

*********************************************************************************************************************************#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.#              It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_c/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit0[ -x $nginxd ] || exit0# Start nginx daemons functions.start() {if [ -e$nginx_pid ];thenecho"nginx already running...."exit1fiecho -n $"Starting $prog: "   daemon $nginxd -c ${nginx_config}   RETVAL=$?   echo   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx   return$RETVAL}# Stop nginx daemons functions.stop() {        echo -n $"Stopping $prog: "        killproc $nginxd        RETVAL=$?        echo        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid}# reload nginx service functions.reload() {    echo -n $"Reloading $prog: "#kill -HUP `cat ${nginx_pid}`    killproc $nginxd -HUP    RETVAL=$?    echo}# See how we were called.case"$1"instart)        start        ;;stop)        stop        ;;reload)        reload        ;;restart)        stop        start        ;;status)        status $prog        RETVAL=$?        ;;*)        echo $"Usage: $prog {start|stop|restart|reload|status|help}"exit1esacexit$RETVAL*********************************************************************************************************************************

The following code is modified based on the location of your system:

nginxd=/usr/local/nginx/sbin/nginxnginx_c>/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pid

Next, set the object access permission:
Chmod a + x/etc/init. d/nginx (expression of a + x parameter ==> all user can execute all users can execute)

Add ngix to the rc. local file, so nginx is started by default when it is started.
Vi/etc/rc. local
Add
/Etc/init. d/nginx start
Save and exit
The next restart will take effect, enabling nginx to start automatically.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above describes how to configure nginx180 in CentOS, including some content. I hope my friends who are interested in the PHP Tutorial can help me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.