@ Install Pcre (nginx urlrewrite module relies on pcre)
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz
# tar ZXVF pcre-8.12.tar.gz
# CD pcre-8.12
#./configure--prefix=/usr/local/webserver/pcre
# Make && make install
# Cp/usr/local/webserver/pcre/lib/libpcre.a/usr/local/webserver/pcre/libpcre.a
# cp/usr/local/webserver/pcre/lib/libpcre.la/usr/local/webserver/pcre/libpcre.la
# cp/usr/local/webserver/pcre/include/pcre.h/usr/local/webserver/pcre/pcre.h
Copy to Pcre directory
# Mkdir/usr/local/webserver/pcre/.libs
Create the. Libs folder
# Cp/usr/local/webserver/pcre/lib/libpcre.a/usr/local/webserver/pcre/.libs/libpcre.a
# cp/usr/local/webserver/pcre/lib/libpcre.la/usr/local/webserver/pcre/.libs/libpcre.la
# cp/usr/local/webserver/pcre/include/pcre.h/usr/local/webserver/pcre/.libs/pcre.h
Copy to. lib Folder
@ Install Nginx/usr/local/nginx
# wget http://nginx.org/download/nginx-1.0.10.tar.gz
# tar ZXVF nginx-1.0.10.tar.gz
# CD nginx-1.0.10
#./configure--user=nobody--group=nobody--prefix=/usr/local/webserver/nginx--with-http_stub_status_module-- With-http_ssl_module
Error in configuration, pcre for compile installation, to specify Pcre path
./configure:error:the HTTP Rewrite module requires the PCRE library.
Can either disable the module by using--without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
Statically from the source with Nginx by using--with-pcre= option.
#./configure--user=nobody--group=nobody--prefix=/usr/local/webserver/nginx--with-http_stub_status_module-- With-http_ssl_module--with-pcre=/usr/local/webserver/pcre
# Make && make install
Error: Nginx can not be well recognized in the system Pcre
Make-f Objs/makefile
MAKE[1]: Entering directory '/usr/local/nginx-1.0.10 '
Cd/usr/local/webserver/pcre \
&& if [f Makefile]; then make Distclean; FI \
&& cc= "gcc" cflags= "-o2-fomit-frame-pointer-pipe" \
./configure--disable-shared
/bin/sh:line 2:./configure:no such file or directory
MAKE[1]: * * * [/usr/local/webserver/pcre/makefile] Error 127
MAKE[1]: Leaving directory '/usr/local/nginx-1.0.10 '
Make: * * * [build] Error 2
#./configure--user=nobody--group=nobody--prefix=/usr/local/webserver/nginx--with-http_stub_status_module-- With-http_ssl_module--with-pcre=/usr/local/webserver/pcre
# VI Objs/makefile
Find configure--disable-shared, in line 1089, delete./configure--disable-shared, save
: St Nu can display line number
: 1089 jump straight to 1089 lines
#make && make Install
@ Create nginx log directory
Mkdir-p/var/log/nginx
chmod +w/var/log/nginx
Chown-r Nobody:nobody/var/log/nginx
@ Create nginx configuration file
#mv/usr/local/webserver/nginx/conf/nginx.conf nginx.conf-
#vi/usr/local/webserver/nginx/conf/nginx.conf
================================================
Copy into the following, save
User nobody nobody;
Worker_processes 8;
Error_log/var/log/nginx/nginx_error.log Crit;
Pid/usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors the can is opened by this process.
Worker_rlimit_nofile 51200;
Events {
Use Epoll;
Worker_connections 51200;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
#charset gb2312;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32k;
Large_client_header_buffers 4 32k;
Client_max_body_size 8m;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 60;
Tcp_nodelay on;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64k;
Fastcgi_buffers 4 64k;
Fastcgi_busy_buffers_size 128k;
Fastcgi_temp_file_write_size 128k;
gzip on;
Gzip_min_length 1k;
Gzip_buffers 4 16k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
#limit_zone crawler $binary _remote_addr 10m;
server {
Listen 80;
server_name 114.80.232.167;
Index index.html index.htm index.php;
root/opt/www;
#limit_conn crawler 20;
Location ~\.php {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Include fcgi.conf;
}
Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $ {
Expires 30d;
}
Location ~. *\. (JS|CSS)? $ {
Expires 1h;
}
location/status/{
Stub_status on;
Access_log off;
}
Log_format access ' $remote _addr-$remote _user [$time _local] ' $request '
' $status $body _bytes_sent ' $http _referer '
' $http _user_agent ' $http _x_forwarded_for ';
Access_log/var/log/nginx/access.log access;
}
}
================================================
@ Create fcgi.conf file in/usr/local/webserver/nginx/conf/directory
#vi/usr/local/webserver/nginx/conf/fcgi.conf
================================================
Copy the following to save
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
Fastcgi_split_path_info ^ (. *\.php) (. *) $;
Fastcgi_param path_info $fastcgi _path_info;
================================================
@ start Nginx
#ulimit-shn 51200
Using Ulimit-a, you can view all the restrictions on the current system and use Ulimit-n to view the current maximum number of open files.
New installed Linux defaults only 1024, as a load of the server, it is easy to encounter error:too many open files. Therefore, it needs to be changed to large.
The use of ulimit-n 65535 can be modified immediately, but it will not work after the reboot. (note ulimit-shn 65535 equivalent ulimit-n 65535,-s means soft,-h refers to hard)
#/usr/local/webserver/nginx/sbin/nginx-----> Start
Setting up a web directory
@ Daily cut Nginx log
#vi/usr/local/webserver/nginx/sbin/cut_nginx_log.sh
================================================
Enter the following to save:
#!/bin/bash
# This script run at 00:00
# The Nginx logs path
Logs_path= "/var/log/nginx/"
Logs_bak_path= "/var/log/nginx_bak/"
Mkdir-p ${logs_bak_path}$ (date-d "Yesterday" + "%Y")/$ (date-d "Yesterday" + "%m")/
CP ${logs_path}access.log ${logs_bak_path}$ (date-d "Yesterday" + "%Y")/$ (date-d "Yesterday" + "%m")/access_$ (date-d " Yesterday "+"%y%m%d "). Log
RM-RF ${logs_path}*.log
KILL-USR1 ' Cat/usr/local/webserver/nginx/nginx.pid '
================================================
#crontab-E-------> Set crontab, 00:00 daily cut nginx access log
================================================
Enter the following content
* * * */bin/bash/usr/local/webserver/nginx/sbin/cut_nginx_log.sh
================================================