Nginx in Ubuntu quickly builds the FCGI environment
Source: Internet
Author: User
It is difficult to build the nginx + php environment on FreeBsd. However, due to historical usage problems, there are still many articles about this experience on the internet. with the gradual promotion of Ubuntu, it is necessary to study how to build the nginx + php environment in ubuntu, so that you can easily build the nginx + php environment on FreeBsd, however, due to historical usage issues, there are still many articles on this experience on the internet. with the gradual promotion of Ubuntu, it is necessary to study how to build the nginx + php environment under ubuntu, it is easier for friends who need this and can promote the popularity of Ubuntu. In fact, it is much faster to build an nginx + php environment under Ubuntu than FreeBsd, in FreeBsd, I used ports for installation. compilation is required. in Ubuntu, I installed apt-get install directly. the installation speed is very fast. let's start the installation next!
1. install nginx. execute the following command and it will be completed soon. However, the default installation version of apg-get is 0.5.33.
Php-cgi:/usr/bin/php-cgi
Php5-cgi:/usr/bin/php5-cgi
Cgi config:/usr/bin/cgi/php. ini
Modify the cgi. fix_pathinfo data of the php. ini file to 1. the default value is 0 cgi. fix_pathinfo = 1. in this way, the SCRIPT_FILENAME variable can be used normally in php-cgi.
3. installing spawn-fcgi is a lighttpd tool used to control php-cgi.
If the GCC compiling environment is not installed in the system, run the following command to install the build-essential toolkit before installing lighttpd:
Sudo apt-get install build-essential
Wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz
Tar-xvf lighttpd-1.4.19.tar.gz
Cd lighttpd-1.4.19/
Sudo apt-get install libpcre3-dev
./Configure-without-zlib-without-bzip2
Make
Sudo cp src/spawn-fcgi/usr/local/bin/spawn-fcgi
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/var/www/nginx-default;
}
# 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 $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www/nginx-default $ fastcgi_script_name;
Include/etc/nginx/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;
How is it? Is it fast and convenient? try it now. if you are planning to be a WordPress user, you can try it. nginx + php is more efficient than Apache + php!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.