PHP+MONGODB Development Environment Building (linux+apache+mongodb+php) _php Tutorial

Source: Internet
Author: User
Tags install mongodb

PHP+MONGODB Development Environment Construction (linux+apache+mongodb+php)


I. Preparing the Linux environment (turn off Selinux,iptables, configure initialization operations such as IP)

Two. Prepare the software:

1. Apache: can be installed with Yum, you can also download the source code compilation.

2. MongoDB: Now Linux is not integrated, so to download.

My environment is Linux, the number of bits 64, download http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz, other in the MongoDB official website.

3. PHP, here is the use of PHP5 for development, so download the source code compiled. Http://cn2.php.net/distributions/php-5.4.32.tar.gz

4. Because php5 to operate MongoDB, and there is no integration driver, so you have to download the driver (PHP extension) http://pecl.php.net/get/mongo-1.5.5.tgz

Three. Installation

It's like installing lamp (linux+apache+mysql+php) in the same order. Apache and MySQL no matter who installs it first, but PHP has to be behind both. The standard, lamp sequence is used here.

1. Installing Apache:yuminstall Httpd*–y

After installing, modify the configuration file/etc/httpd/conf/httpd.conf

ServerName host IP or host name: Listening port (format, according to your actual situation configuration)

2. To install MongoDB:

Create the required directory first:

[Root@code ~]# Mkdir/data/mongodb/db–p

[Root@code ~]# Mkdir/data/mongodb/logs–p

Then install MongoDB: The installation is very simple, unzip the archive can be

[Root@code pub]# tar-xvf mongodb-linux-x86_64-1.6.4.tar.gz-c/usr/local/

The environment variable is then configured so that no path is required when using the command

[Root@code ~]# Cat. Bash_profile

#. Bash_profile

# Get the aliases and functions

If [-f ~/.BASHRC]; Then

. ~/.bashrc

Fi

# User specific environment and startup programs

Path= $PATH: $HOME/bin:/usr/local/mongodb-linux-x86_64-1.6.4/bin

Export PATH

Finally, the source will take effect.

[Root@code ~]# source. bash_profile

3. Installing PHP5

[Root@code pub]# TAR-XVF php-5.4.32.tar.gz

[Root@code pub]# CD php-5.4.32

[Root@code php-5.4.32]#./configure--prefix=/usr/local/php--with-config-file-path=/etc--with-apxs2=/usr/sbin/ Apxs

After this--with-apxs2 will be in

[Root@code ~]# ls/etc/httpd/modules/libphp5.so

/etc/httpd/modules/libphp5.so has this provided to Apache to load PHP using

Here--with-apxs2=/usr/sbin/apxs according to the actual situation (APXS command directory location, if Apache is compiled, will go to the Apache directory to find-here also according to the actual situation)

[Root@code php-5.4.32]# make && make install

[Root@code php-5.4.32]# CP Php.ini-production/etc/php.ini

Configure environment variables so that PHP-related commands do not need to take the path

[Root@code ~]# Cat. Bash_profile

#. Bash_profile

# Get the aliases and functions

If [-f ~/.BASHRC]; Then

. ~/.bashrc

Fi

# User specific environment and startup programs

Path= $PATH: $HOME/bin:/usr/local/mongodb-linux-x86_64-1.6.4/bin:/usr/local/php/bin

Export PATH

Finally, the source will take effect.

[Root@code ~]# source. bash_profile

4. Install PHP extensions, support for MongoDB

[Root@code pub]# TAR-XVF mongo-1.5.5.tgz

[Root@code pub]# CD mongo-1.5.5

[Root@code mongo-1.5.5]# phpize (configuere file generated later)

[Root@code mongo-1.5.5]#./configure--enable-mongo=share--with-php-config=php-config

[Root@code mongo-1.5.5]# make && make install

5. Configure/etc/php.ini

Extension=mongo.so

Register_globals=on

6. Configure/etc/httpd/conf/httpd.conf

LoadModule php5_modulemodules/libphp5.so

Phpinidir "/etc/php.ini"

AddType application/x-httpd-php. php

AddType application/x-httpd-php. htm

AddType application/x-httpd-php. html

DirectoryIndex index.html index.html.var index.htmlindex.shtml index.cgi index.php index.phtml index.php3

http://www.bkjia.com/PHPjc/869181.html www.bkjia.com true http://www.bkjia.com/PHPjc/869181.html techarticle PHP+MONGODB Development Environment Construction (linux+apache+mongodb+php) I. Prepare the Linux environment (turn off Selinux,iptables, configure initialization operations such as IP) two. Prepare the software: 1. Apache: You can use Yum to install, ...

  • 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.