Php + mongodb development environment setup (linux + apache + mongodb + php) _ PHP Tutorial

Source: Internet
Author: User
Tags install mongodb
Php + mongodb development environment (linux + apache + mongodb + php ). Php + mongodb development environment (linux + apache + mongodb + php) I. prepare the linux environment (disable selinux, iptables, configure ip, and other initialization operations) 2. preparation Software: 1. apache: it can be installed using yum, and php + mongodb development environment (linux + apache + mongodb + php)

1. prepare the linux environment (disable selinux, iptables, configure ip, and other initialization operations)

2. prepare the software:

1. apache: it can be installed with yum or downloaded for source code compilation.

2. mongodb: currently linux is not integrated, so you need to download it.

My environment is linux, with 64-bit digits. download http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz, which is on mongodb.

3. php. php5 is used for development, so download the source code for compilation. Http://cn2.php.net/distributions/php-5.4.32.tar.gz

4. because php5 has to operate mongodb without an integrated driver, you have to download the driver (php extension) http://pecl.php.net/get/mongo-1.5.5.tgz.

III. Installation

Just like installing lamp (linux + apache + mysql + php. Apache and mysql can be installed first, but php must be followed by these two. Here we use the standard lamp sequence.

1. install apache: yuminstall httpd *-y

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

ServerName host ip address or host name: Listener port (format, configured according to your actual situation)

2. install mongodb:

First, create the required Directory:

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

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

Then install mongodb: The installation is simple, and you can decompress the archive.

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

Configure the environment variable so that the path does not need to be included 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

It takes effect only under source.

[Root @ code ~] # Source. bash_profile

3. install 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

Here -- the with-apxs2 will be

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

/Etc/httpd/modules/libphp5.so provides this feature for apache to load php.

Here -- with-apxs2 =/usr/sbin/apxs depends on the actual situation (the location of the apxs command Directory, If apache is compiled, go to the apache Directory.-here, we will also find it based on 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 related php commands do not need to carry 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

It takes effect only under source.

[Root @ code ~] # Source. bash_profile

4. install php extensions to support 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 (after generating the configuere file)

[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. var index.htmlindex.shtml index. cgi index. php index. phtml index. php3

Kernel (linux + apache + mongodb + php) 1. prepare the linux environment (disable selinux, iptables, configure ip, and other initialization operations) 2. preparation Software: 1. apache: can be installed with yum ,...

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.