To make sure that you can use regular expressions in nginx for more flexible configuration, You need to determine whether the PCRE (Perl Compatible Regular Expressions) package is installed in the system before installation. You can go to the ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ to download the latest PCRE source package, use the following command to download the compilation and installation of PCRE package:
# 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 = "directory to be installed"
# Make
# Make install
Next, install nginx. nginx generally has two versions: stable version and development version. You can select one of these two versions for your purpose, the following describes how to install nginx in the/opt/nginx directory:
# Wget http://nginx.org/download/nginx-0.8.54.tar.gz
# Tar zxvf nginx-0.8.54.tar.gz
# Cd nginx-0.8.54
#. /Configure -- with-http_stub_status_module-Prefix =/usr/webserver/nginx -- With-PCRE = "the directory after your PCRE install make install" -- user = "your user name or user group (otherwise not root users cannot support PHP)"
# Make
# Make install
Modify the configuration file CONF/nginx. conf to configure the instance.
User nginx;
Worker_processes 1;
# Error_log logs/error. log;
# Error_log logs/error. Log notice;
Error_log logs/error. Log Info;
PID logs/nginx. PID;
Worker_rlimit_nofile 1024;
Events {
Worker_connections 1024;
}
HTTP {
Include mime. types;
Default_type application/octet-stream;
Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent' $ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';
Access_log logs/access. Log main;
Sendfile on;
Tcp_nopush on;
# Keepalive_timeout 0;
Keepalive_timeout 65;
Gzip on;
Gzip_buffers 32 4 K;
Gzip_comp_level 1;
Gzip_min_length 1024;
Gzip_types text/plain application/X-JavaScript text/CSS application/XML;
Server {
Listen 8888;
SERVER_NAME localhost;
# Charset koi8-r;
Access_log logs/host. Access. Log main;
Location /{
Root HTML;
Index index.html index.htm;
}
Error_page 404/404 .html;
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root HTML;
}
# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 127.0.0.1;
#}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Location ~ \. Php $ {
# Root HTML;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param script_filename/scripts $ fastcgi_script_name;
# Include fastcgi_params;
#}
# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}
}
# Another virtual host using mix of IP-, name-, and port-Based Configuration
#
# Server {
# Listen 8000;
# Listen somename: 8080;
# SERVER_NAME somename alias another. Alias;
# Location /{
# Root HTML;
# Index index.html index.htm;
#}
#}
# HTTPS Server
#
# Server {
# Listen 443;
# SERVER_NAME localhost;
# SSL on;
# Ssl_certificate cert. pem;
# Ssl_certificate_key cert. Key;
# Ssl_session_timeout 5 m;
# Ssl_protocols SSLv2 SSLv3 tlsv1;
# Ssl_ciphers high :! Anull :! MD5;
# Ssl_prefer_server_ciphers on;
# Location /{
# Root HTML;
# Index index.html index.htm;
#}
#}
}
Configuration instructions reference: http://wiki.xdays.info/web:nginx:config
Check whether the configuration is correct:
./Sbin/nginx-T
Start:
./Sbin/nginx
Close:
PS-Ef | grep nginx
Kill-9 $ PID
Access:
Http: // 192.168.1.1: 8888/