Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ CentOS 6.5 installation and simple configuration Nginx     - CentOS 6.4 compiler installed MySQL 5.6.14 (Database)

- Python variable type (Programming)

- MySQL optimization resulting order by using filesort (Database)

- Android and OpenCV2.4.4 build an image processing framework (2013 edition) (Linux)

- Ubuntu security settings and tools (Linux)

- Flask deploy applications using Nginx on Ubuntu (Server)

- File SUID, SGID, Sticky property (Linux)

- Compare several ways to transfer files between Linux hosts (Linux)

- The several technical presentation Raid under Linux (Linux)

- JavaScript in this usage (Programming)

- Windows Server 2012 R2 Datacenter install SQL Server 2016 CTP (Database)

- PostgreSQL export data dictionary documents (Database)

- Oracle view object space usage show_space (Database)

- Apache2.4.7 make an error [exports.lo] Error 1 Solution (Server)

- Linux installed Cisco Packet Tracer (Linux)

- Installation under Linux to deploy Java (Linux)

- Linux modify the network interface name (Linux)

- Ubuntu download install and configure Plank Dock (Linux)

- The difference between Linux su and sudo commands (Linux)

- Understanding the type in C ++ bitset (Programming)

 
         
  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:      
 
- 7 extremely dangerous Linux commands (Linux)
- How to install OpenOffice Ubuntu or Linux Mint (Linux)
- Hadoop + Zookeeper NameNode achieve high availability (Server)
- CentOS 7.0 Automatic installation CD-ROM production Comments (Linux)
- Detailed driver compiled into the Linux kernel (Programming)
- Linux learning portal: CentOS 6.4 system kernel upgrade (Linux)
- LNMP Note: Addressing mail function can not send mail (Server)
- OpenNMS compile under Linux (Server)
- Linux Shell introduces (Linux)
- Java Annotation Comments (Programming)
- Error: Unable to establish connection with FTP SFTP server (Server)
- Android Studio Clear Project or Rebuild Project Error (Linux)
- How to Install Xombrero 1.6.4 (minimalist Web browser) on Ubuntu and Archlinux (Linux)
- Troubleshooting Linux virtual machine device id and the letter of inconsistencies (Linux)
- Qt for file splitting and fusion gadgets (Programming)
- Python 2.7.9 Installation on Linux CentOS 6.6 (Linux)
- ARP Linux-related operations (Linux)
- MySQL Tutorial: Philosophical Reflections on the unauthenticated user (Database)
- SLF4J Tutorial (Programming)
- Configuring automatic mail GAMIT under CentOS system (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.