Debian 5 VPS Nginx + PHP + MySQL Solution

Source: Internet
Author: User
Tags vps

This article introduces the nginx + php + mysql solution under Debian 5 VPS. This solution uses php-fpm as the fastcgi Process Manager.

This article is based on the 64-bit Debian 5 VPS. If it is a 32-bit Debian VPS, modify it in the corresponding section.

When using php-fpm, php must be re-compiled, and the built-in php cannot be used. MySQL comes with Debian. Nginx is the latest version downloaded from the official Debian software library.



Install Nginx
The nginx version of Debian 5 is relatively low. The latest stable version of Nginx 0.7.61 and the latest version of nginx will be included in Debian 6, after testing, we found that nginx can run under Debian 5. Installation command:

Wget http://ftp.us.debian.org/debian/pool/main/n/nginx/nginx_0.7.61-2_amd64.deb
Dpkg-I nginx_0.7.61-2_amd64.deb
/Etc/init. d/nginx start
Mkdir-p/var/www/nginx-default
Echo 'nginx OK '>/var/www/nginx-default/index.html
Echo ''>/var/www/nginx-default/test. php

In addition, run the dpkg-L nginx command to check which directories The nginx files are installed in.

The default webpage directory of nginx In Debian is/var/www/nginx-default. This directory is not created during installation and we create it manually.

When you access nginx through a browser, you can see the default web page of nginx, which means nginx is working properly!

Install MySQL
Run the following command to install MySQL that comes with Debian:

Apt-get install mysql-server-5.0
/Etc/init. d/mysql start

Run the mysql-uroot-p command to connect to MySQL normally.

Install php & php-fpm
Library files required for installing php:

Apt-get update
Apt-get install libxml2 libldap-2.4-2 libmhash2 curl libpng3 lib21362 libsasl2-2 libmcrypt4

Download and install our own php-fpm compiled in Debian in http://rashost.com/download:

Cd/opt
Tar zxf php-fpm-5.2.10-amd64.tar.gz
Ln-s/opt/php/sbin/php-fpm/etc/init. d/php-fpm
Update-rc.d-f php-fpm defaults
/Etc/init. d/php-fpm start

Integration
First, create the file test. php in the/var/www/nginx-default directory. The content is very simple, as long as the following line:


Assume that the VPS address is debian5.rashost.com. Then, access http://debian5.rashost.com/test.php through a browser.

Modify the nginx configuration file/etc/nginx/sites-enabled/default, search for fastcgi_pass in the file, and modify the content:

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 fastcgi_params;
}

Note: The nginx Configuration File In Debian differs greatly from that in centos. Debian splits the configuration into multiple files. We recommend that you use one site and one configuration file, we modified/etc/nginx/sites-enabled/default. In addition, the/var/www/nginx-default/Section following the fastcgi_param parameter is a specific webpage directory. If it is written as $ document_root In Debian, I don't know why it doesn't work.

Restart nginx:

/Etc/init. d/nginx/restart

Then access the test. php page in the browser, the http://ubuntuone.cn should be able to correctly display, reboot VPS test, each module should be able to bring their own boot. Success!
 

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.