(1) Nginx installation configuration
① Download Nginx Installation
wget-c http://nginx.org/download/nginx-1.12.0.tar.gz
② Unpacking the installation package
Tar-xzf nginx-1.12.0.tar.gz
③ into the source directory
CD nginx-1.12.0
④ into the source directory, precompiled, compiled, installed
Useradd www
./configure--prefix=/usr/local/nginx--user=www--group=www
Comments:
If in the process of compiling, report. CONFIGURE:ERROR:C complier cc is not found
The solution is yum install gcc gcc-c++
if in the process of compiling, report ./configure:error:the HTTP Rewrite module requires the PCRE library.
The solution is yum install Pcre-devel
If in the process of compiling, quote /configure:error:the HTTP gzip module requires the Zlib library.
The solution is yum install-y zlib-devel
Finish, execute make make install
Anatomy of the ⑤nginx configuration file
Nginx configuration file consists of conf HTML logs Sbin
Conf directory, the configuration file is stored
HTML directory, is the site publishing directory
Logs is the log directory
Sbin directory, which is the directory where commands are stored
⑥ Turn off SELinux and firewalls
Setenfroce 0 Service Iptabltes Stop
⑦ start Nginx
/usr/local/nginx/sbin/nginx
⑧ to see if ports and processes are started
Ps-ef |grep nginx Netstat-ntl|grep 80
⑨ Modifying Nginx Publishing directory
Enter cd/usr/local/nginx/html
In the HTML directory, there is a index.html file, modify it, you can
Restart Nginx/usr/local/nginx/sbin/nginx-s Reload
⑩ Stopping Nginx/usr/local/nginx/sbin/nginx-s Stop
? nginx boot from boot will need to boot from the relative content written to the/etc/rc.local configuration file
? /usr/local/nginx/sbin/nginx-v Viewing nginx version information
? /USR/LOCAL/NGINX/SBIN/NGINX-V View Nginx parameter information
? Configuration of Nginx Virtual host
<1> Remove # in nginx.conf config file, space grep-v "#" nginx.conf | Grep-v "^$" >>nginx.conf.swp
<2> Open the Vim nginx.conf configuration file and locate the server configuration segment
server {
Listen 80;
server_name www.jf1.com;
Location/{
root HTML;
Index index.html index.htm;
}
}
Comments:
<1> server_name the domain name of the website
The index.html on the <2> site is stored by default in the HTML directory root directory, and can also be modified to html/www.jf1.com create index,html files in this directory
<3> several Web sites configure several server segments
<4> Server Segment configuration, can also be separated from nginx.conf, in the Nginx configuration file, the server segment is placed in the Vhosts directory, in the HTTP configuration section to add the include vhosts/*
? Nginx Upgrade
<1> download new version of Nginx source files, unzip, enter the source code compilation directory, precompiled, compile
<2> back up older versions of Nginx executables Mv/usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.old
<3> CP Objs/nginx/usr/local/nginx/sbin
<4> test the new version of Nginx is normal
/usr/local/nginx/sbin/nginx-t
<5> Verify that Nginx upgrade is successful
/usr/local/nginx/sbin-v
Nginx Web Installation Configuration