Install nginx1.05 + php5.3 + mongodb1.82 in centos 5-Note

Source: Internet
Author: User
Tags mongodb driver php cli

1. Install nginx

Download nginx http://nginx.org/download/nginx-1.0.5.tar.gz

(2) decompress tar-zxvf nginx-1.0.5.tar.gz

(3) Compile./configure -- with-http_stub_status_module

Error reported, not found PCRE, need to download PCRE ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

Note: You must use root for configure, make, and make install.

Then install PCRE

Libtool: compile: Unrecognized option '-dhave_config_h' may be reported'

Solution: Yum install gcc-C ++

Recompile nginx

The./configure: error: the HTTP gzip module requires the zlib library.

Solution: Yum install-y zlib-devel

Make

Make install

(4) nginx has been installed. The installation directory is in/usr/local/nginx.

2. Install PhP5

(1) download PHP http://www.php.net/get/php-5.3.6.tar.gz/from/cn.php.net/mirror

(2) decompress tar-zxvf php-5.3.6.tar.gz

(3) Compile./configure -- enable-FPM

Libxml2 not found, install libxml2 $ Yum install libxml2 libxml2-devel

Continue to compile./configure -- prefix =/usr/local/PHP -- enable-FPM

(4) Make make install

(5) The default installation directory is as follows, which is messy. Therefore, it is best to add./configure -- prefix =/usr/local/PHP -- enable-FPM during compilation.

Installing php sapi module: FPM
Installing php cli binary:/usr/local/bin/
Installing php cli man page:/usr/local/man/Man1/
Installing php fpm binary:/usr/local/sbin/
Installing php fpm config:/usr/local/etc/
Installing php fpm man page:/usr/local/man/man8/
Installing Build Environment:/usr/local/lib/PHP/build/
Installing header files:/usr/local/include/PHP/
Installing helper programs:/usr/local/bin/
Program: phpize
Program: PHP-config
Installing man pages:/usr/local/man/Man1/
Page: phpize.1
Page: php-config.1
Installing pear environment:/usr/local/lib/PHP/
[Pear] archive_tar-installed: 1.3.7
[Pear] lele_getopt-installed: 1.3.0
[Pear] structures_graph-installed: 1.0.4
[Pear] xml_util-installed: 1.2.1
[Pear] pear-installed: 1.9.2
Wrote pear system config file at:/usr/local/etc/pear. conf
You may want to add:/usr/local/lib/PHP to your php. ini include_path
/Home/admin/php-5.3.6/build/shtool install-c ext/phar. phar/usr/local/bin
Ln-S-F/usr/local/bin/phar. phar/usr/local/bin/phar
Installing PDO headers:/usr/local/include/PHP/EXT/PdO/

----------------------------------------------------------------

(5) Last copy the configuration file

Cp php. ini-development/usr/local/lib/PHP. ini

Or

Cp php. ini-production/usr/local/PHP/lib/PHP. ini

(6) mV/usr/local/PHP/etc/php-fpm.conf.default/usr/local/PHP/etc/php-fpm.conf

Modify the php-fpm.conf and open pm. start_servers, PM. min_spare_servers, PM. max_spare_servers, PM. max_requests.

(7) Start fast_cgi manager,/usr/local/sbin/PHP-FPM

3. Configure nginx + PhP Integration

(1) Open nginx. conf and set

Location ~ \. Php $ {
Root HTML;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param script_filename/usr/local/nginx/html $ fastcgi_script_name;
Include fastcgi_params;
}

(2) Start nginx,/usr/local/nginx/sbin/nginx

(3) set startup

Echo "/usr/local/PHP/sbin/PHP-FPM">/etc/rc. Local

Echo "/usr/local/nginx/sbin/nginx">/etc/rc. Local

4. Install the MongoDB driver

CD/usr/local/PHP/bin

./PECL install Mongo

Add "extension = Mongo. So" to PhP. ini"

5. MongoDB Testing Program

<? PHP

// Connect
$ M = new Mongo ();

// Select a database
$ Db = $ M-> comedy;

// Select a collection (analogous to a relational database's table)
$ Collection = $ db-> cartoons;

// Add a record
$ OBJ = array ("title" => "Calvin and Hobbes", "author" => "Bill Watterson ");
$ Collection-> insert ($ OBJ );

// Add another record, with a different "shape"
$ OBJ = array ("title" => "XKCD", "online" => true );
$ Collection-> insert ($ OBJ );

// Find everything in the collection
$ Cursor = $ collection-> Find ();

// Iterate through the results
Foreach ($ cursor as $ OBJ ){
Echo $ OBJ ["title"]. "\ n ";
}

?>

Related Article

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.