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