Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ CentOS 6.5 installation and simple configuration Nginx     - Netapp storage routine inspections and information gathering (Linux)

- To install Python-Pip and Fabric under CentOS / Ubuntu (Linux)

- Use custom backup plans for Debian backupninja (Linux)

- MySQL log from the library than the main library (Database)

- Developing a Web server yourself (Server)

- AFNetworking + Nginx HTTPS communication server + (Server)

- OGG-01496 OGG-01031 Error Resolution (Database)

- Why do you need close contact Rust 1.0 (Programming)

- Tomcat session clustering and server session (Server)

- Service manager OpenBSD on rccl (Server)

- Linux / Unix: chroot command examples to explain (Linux)

- Oracle partition table data migration, process management automation (Database)

- Installation and use the telnet command under CentOS 6.x (Linux)

- ActiveMQ configuration Getting Started Tutorial (Server)

- Linux source code analysis tool (Linux)

- MySQL management partition table (Database)

- Linux disk management practices (Linux)

- CentOS7 yum install third-party source EPEL (Linux)

- Linux in order to make NMAP hide and seek with the firewall (Linux)

- Linux regex sed detailing (Linux)

 
         
  CentOS 6.5 installation and simple configuration Nginx
     
  Add Date : 2016-05-29      
         
       
         
  CentOS 6.5 installation and simple configuration Nginx

First, Preparation

(1) because nginx need to access port 80 so turn off the firewall or open ports, and selinux.

Command Reference

Turn off the firewall:

[Root @ local ~] # iptables -I INPUT -p tcp --dport 80 -j ACCEPT

[Root @ local ~] # service iptables save

Close selinux:

[Root @ local ~] # setenforce 0

[Root @ local ~] # vim / etc / selinux / config

The SELINUX = enforcing to SELINUX = disabled
 

(2) If the domain name is used to build their own DNS service

Second, the installation

(1) needs to be installed to run because nginx pcre, zlib packages, etc., so we installed

Pcre = Pcre Compatible Regular Expressions

[Root @ local ~] yum -y install pcre * zlib * # or compile and install

[Root @ local ~] # useradd -M -s / sbin / nologin nginx # Create nginx service
 

Launching User

(3) compile and install nginx, download address: http: //nginx.org/en/download.html install the latest stable version of nginx-1.8.0

[Root @ local ~] # tar zxf nginx-1.8.0.tar.gz

[Root @ local ~] # cd nginx-1.8.0

[Root @ local nginx-1.8.0] # ls

auto CHANGES.ru configure html Makefile objs src

CHANGES conf contrib LICENSE man README

[Root @ local nginx-1.8.0] # ./configure --user = nginx --group = nginx --prefix = / application / nginx-1.8.0 --with-http_stub_status_module --with-http_ssl_module #. / Configure parameter Description -help

[Root @ local nginx-1.8.0] # make

[Root @ local nginx-1.8.0] # make install
 

(4) production of soft connection

[Root @ local nginx-1.8.0] #ln -a /application/nginx-1.8.0/

/ Application / nginx
 

(5) Basic Usage

# Syntax check

[Root @ local nginx-1.8.0] # / application / nginx / sbin / nginx -t

nginx: the configuration file /application/nginx-1.8.0/conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.8.0/conf/nginx.conf test is successful

# Start Service

[Root @ local nginx-1.8.0] # / application / nginx / sbin / nginx

# Port inspection

[Root @ local nginx-1.8.0] # netstat -lnt

# Inspection process

[Root @ local nginx-1.8.0] # ps -ef | grep nginx # port information is stored in

/ Application / nginx / logs / nginx.pid file

# View port occupied by process

[Root @ local nginx-1.8.0] # lsof -i: 80

# Error log

/application/nginx/logs/error.log
 

Third, write a script nginx service

In order to facilitate usage by server to start, close, open, reload nginx service so we have to compile

Write nginx service script (script I have written for informational purposes only!)

[Root @ local ~] # vim /etc/init.d/nginx

#! / Bin / bash

#chkconfig: - 99 20

#description: Nginx Server Contorl Script

PROG = "/ application / nginx / sbin / nginx"

PIDF = "/ application / nginx / logs / nginx.pid"

ok = `echo -e" \ e [1; 31m [ok] \ e [0m "`

no = `echo -e" \ e [1; 31m [no] \ e [0m "`

detection = `/ application / nginx / sbin / nginx -t 2> & 1`

screen_1 = `echo $ detection | awk '{print $ 6, $ 7, $ 8}'`

screen_2 = `echo $ detection | awk '{print $ 13, $ 14, $ 15}'`

if [ "$ screen_1" = "syntax is ok"] && [ "$ screen_2" = "test is successful"];

then

    case "$ 1" in

    start)

      $ PROG

      echo "Nginx Is starting state $ ok"

      ;;

    stop)

      kill -s QUIT $ (cat $ PIDF)

      echo "Nginx Is closing state $ ok"

      ;;

    restart)

      $ 0 stop

      $ 0 start

      echo "Nginx Is to restart state $ ok"

      ;;

    reload)

      kill -s HUP $ (cat $ PIDF)

      echo "Nginx Is overloaded state $ ok"

      ;;

    *)

      echo "Usage: $ 0 (start | stop | restart | reload)"

      exit 1

      esac

else

  echo "Nginx check state $ no"

  echo "Please check the configuration file"

  echo "$ detection"

fi

exit 0
 
  
[Root @ local ~] # chmod + x /etc/init.d/nginx

[Root @ local ~] # chkconfig -add nginx # add a system service

[Root @ local ~] # chkconfig nginx on
 

Fourth, simple nginx web site

Nginx default site directory is the installation html directory here (/ application / nginx / html)

In the main configuration file /application/nginx/conf/nginx.conf view, redeployed for web pages

Just / application / nginx / html / index.html in to replace

The main configuration file to explain

 

[Root @ local ~] # egrep -v "# | ^ $" /application/nginx/conf/nginx.conf

worker_processes 1; # specify the number of processes open Nginx

events {# set Nginx operating mode and on-line connections

worker_connections 1024;

}

http {

include mime.types; # main module commands implementation sets the configuration file that contains all files

default_type application / octet-stream; # http belong core module command, located here

Type set to binary, that is, when the file type is not defined in this way, for example, no PHP

Environment, nginx is not given to resolve, this time, to access a PHP file browser download window will appear.

sendfile on; # for efficient file transfer mode

keepalive_timeout 65; set the client request header file read timeout, if more than this

Between the server closes the connection.

Keyword server {# define virtual host begins

listen 80; # is used to specify the virtual host port services

Used to specify the ip address or domain, multiple domain names separated by spaces; server_name localhost

location / {

root html;

index index.html index.htm; # is used to set the default home page to access

}

error_page 500 502 503 504 /50x.html;# static pages redirect server error

Page, such as page Ctrip's website crashes occur

location = /50x.html {

root html;

}

}

}
     
         
       
         
  More:      
 
- C ++ virtual functions Classic Insights (Programming)
- Installation and Configuration JDK8 In CentOS 7 (Linux)
- Linux Log Clear (Linux)
- How to use Android Studio to play more package names APK (Programming)
- Git bulk delete remote tag (Linux)
- Linux system performance analysis and top command ps.pstree Comments (Linux)
- Solve ORA-01012: not logged on (Database)
- Extended VMware Ubuntu root partition size (Linux)
- PostgreSQL with the C Completing the storage process instances (Database)
- RHEL 6.6 install GNOME desktop environment (Linux)
- Ubuntu 14.04 installed VirtualBox 4.3 appears vboxdrv: Unknown symbol mcount (Linux)
- Zabbix using Omsa monitor hardware information of Dell server (Server)
- cp: omitting directory error solutions under Linux (Linux)
- Oracle multi-table query optimization (Database)
- MySQL loose index scan (Database)
- Oracle SQL statement tracking (Database)
- Linux find command detailing (Linux)
- Standard and IO redirection (Linux)
- Oracle user lock how to know what causes (Database)
- Oracle 12C with multi-column index (Database)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.