Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ CentOS 6.5 installation and simple configuration Nginx     - C # asynchronous delegates (Programming)

- Oracle table space create large files (Database)

- Volatile keyword in C language understanding (Programming)

- C ++ containers (Programming)

- Linux System Getting Started Learning: Linux how to install 7zip (Linux)

- Slow update statement Performance Analysis (Database)

- Nodejs command-line program development tutorial (Programming)

- GNU / Linux system, how to clean up memory space (Linux)

- Ubuntu Thunderbird 24.4.0 (Linux)

- Kafka + Log4j log implement centralized management (Server)

- How to update the Linux kernel to improve system performance (Linux)

- Ora-00020: maximum number of processes (500) exceeded (Database)

- How nodeclub constructed Docker image (Server)

- Using Vagrant create cross-platform development environment (Linux)

- Fedora 19/20 and Debian Jessie / Sid users to install FFmpeg 2.3.2 (Linux)

- Mysql binlog resolve the garbage problem decryption (Database)

- How Datadog monitor Nginx (Server)

- To set up the printer use Nagios Monitoring Server (Server)

- Phoenix agents use P2P WebRTC development (Programming)

- To install the Contiki development toolchain on Ubuntu (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:      
 
- Eclipse-ee Tomcat browser can not start Tomcat, and Web project service deployment (Server)
- A command to install Sublime Text 3 on Manjaro / Archlinux (Linux)
- The compiler installed Kaldi under Ubuntu 12.04 (Linux)
- Oracle Linux 6.4 installed Oracle 11gR2 + RAC + ASM (Database)
- Use LKM change the default linux security level (Linux)
- How to configure Apache Solr on Ubuntu 14/15 (Server)
- Justniffer installed on Ubuntu 15.04 (Linux)
- Linux command line to put on your coat GUI (Linux)
- Linux itself disguised illusion strengthen security (Linux)
- Oracle to start to solve the error ORA-27102 (Database)
- RVM installation instructions (Linux)
- Installation image conversion tool on your Ubuntu Converseen 0.8.1 (Linux)
- Linux uses a screen recording under RecordMyDesktop (Linux)
- Ubuntu Locale configuration problem solving Can not set LC_CTYPE (Linux)
- CentOS 6.5 opens the Xmanager Remote Desktop login (Linux)
- Analysis: Little Notebook facing a major security threat secure online (Linux)
- Linux 64-bit porting (Programming)
- Upload the project to GitHub, synchronous remote repository Github (Linux)
- Python Django direct implementation of sql statement (Programming)
- How to use SHA256 checksum files download (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.