Ubuntu 10.04 lts
1. Use apt-get to download nginx, PHP, MySQL, phpMyAdmin, and spawn-fcgi.
Sudo apt-Get install nginx php5-cgi php5-cli mysql-server-5.1 phpMyAdmin spawn-fcgi
During this period, you may need to enter the MySQL password and follow the prompts to install it step by step.
After OK, you can access http: // 127.0.0.1/or http: // localhost/in Firefox to see the welcome interface of nginx.
2. nginx cannot run php at this timeProgram. You need to modify some configuration files.
$ CD/etc/nginx
$ Sudo Vim fastcgi_params, which is modified as follows (red part ):
Fastcgi_ignore_client_abort on;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param QUERY_STRING $ QUERY_STRING;
Fastcgi_param request_method $ request_method;
Fastcgi_param content_type $ content_type;
Fastcgi_param content_length $ content_length;
Fastcgi_param script_filename $ document_root $ fastcgi_script_name;
Fastcgi_param script_name $ fastcgi_script_name;
Fastcgi_param request_uri $ request_uri;
Fastcgi_param document_uri $ document_uri;
Fastcgi_param document_root $ document_root;
Fastcgi_param server_protocol $ server_protocol;
Fastcgi_param gateway_interface cgi/1.1;
Fastcgi_param server_software nginx/$ nginx_version;
Fastcgi_param remote_addr $ remote_addr;
Fastcgi_param remote_port $ remote_port;
Fastcgi_param server_addr $ server_addr;
Fastcgi_param server_port $ server_port;
Fastcgi_param SERVER_NAME $ SERVER_NAME;
Modify nginx configuration file nginx. conf
Sudo Vim nginx. conf:
User codebean; # user and user group
Worker_processes 2;
Error_log/var/log/nginx/error. log;
Pid/var/run/nginx. PID;
Events {
Worker_connections 1024;
# Multi_accept on;
}
HTTP {
Include/etc/nginx/mime. types;
Access_log/var/log/nginx/access. log;
Sendfile on;
# Tcp_nopush on;
# Keepalive_timeout 0;
Keepalive_timeout 65;
Tcp_nodelay on;
Gzip on;
Gzip_disable "MSIE [1-6] \. (?!. * Sv1 )";
Include/etc/nginx/CONF. d/*. conf;
Include/etc/nginx/sites-enabled /*;
}
3. configure a default site:
CD/etc/nginx/sites-available
Sudo Vim default
The modification is as follows:
Server {
Listen 80 default; # default indicates the default site
SERVER_NAME localhost; # access name
Root/var/www/nginx-default; # website root directory
Access_log/var/log/nginx/localhost. Access. log;
Location /{
Index index. php index.html index.htm;
}
Location ~ \. Php $ {
Include fastcgi_params; # this is very important.
}
}
Next, create an index. php in the/var/www/nginx-default directory and enter:
Phpinfo();
Restart the nginx service and enable FastCGI:
$ Sudo/etc/init. d/nginx restart
$/Usr/bin/spawn-fcgi-A 127.0.0.1-P 9000-C 5/usr/bin/PHP-CGI
Visit http: // 127.0.0.1/or http: // localhost /.