Quickly install PHP-fpm 5.3 and Nginx on Ubuntu/Debian

Source: Internet
Author: User

Today, we started VPS again. Unfortunately, they didn't provide the archlinux system and had to choose Debian. But lenny's PHP version is too old to include fpm, I don't want to waste any time compiling, So google finds a source that provides PHP-fpm 5.3 and provides common modules, So I directly installed it, simply record the installation process.

1. Install Nginx
The Nginx version does not need to be too new. It is good to use the official source, at least stable enough.

 

Sudo apt-get install nginx simple edit its default configuration, and then test whether it works normally with PHP.

After sudo vim/etc/nginx/sites-available/default is changed, it looks like this.

Server {
Listen 80;
Server_name localhost;
Access_log/var/log/nginx/localhost. access. log;

# Default location
Location /{
Root/var/www;
Index. php;
}

# Images and static content is treated different
Location ~ * ^. +. (Jpg | jpeg | gif | css | png | js | ico | xml) $ {
Access_log off;
Expires 30d;
Root/var/www;
}

# Parse all. php file in the/var/www directory
Location ~ . Php $ {
Fastcgi_split_path_info ^ (. +. php) (. *) $;
Fastcgi_pass backend;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www $ fastcgi_script_name;
Include fastcgi_params;
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_intercept_errors on;
Fastcgi_ignore_client_abort off;
Fastcgi_connect_timeout 60;
Fastcgi_send_timeout 180;
Fastcgi_read_timeout 180;
Fastcgi_buffer_size 128 k;
Fastcgi_buffers' 4 256 k;
Fastcgi_busy_buffers_size 256 k;
Fastcgi_temp_file_write_size 256 k;
}

# Disable viewing. htaccess &. htpassword
Location ~ /. Ht {
Deny all;
}
}
2. Preparations
If you are using Ubuntu, you do not need to manually install two packages or Debian.

Cd/tmp
Wget http://us.archive.Ubuntu.com/ubuntu/pool/main/k/krb5/libkrb53_1.6.dfsg.4 ~ Beta1-5ubuntu2_i386.deb
Wget http://us.archive.Ubuntu.com/ubuntu/pool/main/ I /icu/libicu38_3.8-6ubuntu0.2_i386.deb
Sudo dpkg-I *. deb if the amd64 system is used, change i386 in the above two packages to amd64.
3. Add an unofficial source and install PHP-fpm

Sudo echo "deb http://php53.dotdeb.org stable all">/etc/apt/sources. list update source

Install the PHP environment using sudo apt-get update

Sudo apt-get install php5-cli php5-common php5-suhosin above is installed with cli php, then install CGI, fpm

Sudo apt-get install php5-fpm php5-cgi requires other modules or extensions that can be installed on your own, here list all the modules and extensions provided in this source

Php5-curl_5.3.2-0.dotdeb.1_i386.deb
Php5-dbg_5.3.2-0.dotdeb.1_i386.deb
Php5-dev_5.3.2-0.dotdeb.1_i386.deb
Php5-enchant_5.3.2-0.dotdeb.1_i386.deb
Php5-fpm_5.3.2-0.dotdeb.1_i386.deb
Php5-gd_5.3.2-0.dotdeb.1_i386.deb
Php5-gmp_5.3.2-0.dotdeb.1_i386.deb
Php5-imap_5.3.2-0.dotdeb.1_i386.deb
Php5-interbase_5.3.2-0.dotdeb.1_i386.deb
Php5-ldap_5.3.2-0.dotdeb.1_i386.deb
Php5-mcrypt_5.3.2-0.dotdeb.1_i386.deb
Php5-mysql_5.3.2-0.dotdeb.1_i386.deb
Php5-odbc_5.3.2-0.dotdeb.1_i386.deb
Php5-pgsql_5.3.2-0.dotdeb.1_i386.deb
Php5-pspell_5.3.2-0.dotdeb.1_i386.deb
Php5-recode_5.3.2-0.dotdeb.1_i386.deb
Php5-snmp_5.3.2-0.dotdeb.1_i386.deb
Php5-sqlite_5.3.2-0.dotdeb.1_i386.deb
Php5-sybase_5.3.2-0.dotdeb.1_i386.deb
Php5-tidy_5.3.2-0.dotdeb.1_i386.deb
Php5-xmlrpc_5.3.2-0.dotdeb.1_i386.deb
Php5-xsl_5.3.2-0.dotdeb.1_i386.deb
Php5_5.3.2-0.dotdeb.1_all.deb
Php5-apc_5.3.2-0.dotdeb.1_i386.deb
Php5-ffmpeg_5.3.2-0.dotdeb.1_i386.deb
Php5-geoip_5.3.2-0.dotdeb.1_i386.deb
Php5-http_5.3.2-0.dotdeb.1_i386.deb
Php5-imagick_5.3.2-0.dotdeb.1_i386.deb
Php5-memcache_5.3.2-0.dotdeb.1_i386.deb
Php5-spplus_5.3.2-0.dotdeb.1_i386.deb
Php5-ssh2_5.3.2-0.dotdeb.1_i386.deb
Php5-suhosin_5.3.2-0.dotdeb.1_i386.deb
Php5-xcache_5.3.2-0.dotdeb.1_i386.deb
Php5-xdebug_5.3.2-0.dotdeb.1_i386.deb

4. Test Run
Start Nginx and PHP-Fpm

Sudo/etc/init. d/nginx restart
Sudo/etc/init. d/php5-fpm restart next create an index. PHP file under/var/www/, then write the PHP test function

<? Php phpinfo ();?> Then, the PHP environment information is displayed, indicating that the operation is normal.
View error information

Sudo tail/var/log/nginx/error. log
 

 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.