Home  >  Article  >  Backend Development  >  php+mongodb development environment construction (linux+apache+mongodb+php)_PHP tutorial

php+mongodb development environment construction (linux+apache+mongodb+php)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:20:11860browse

php+mongodb development environment construction (linux+apache+mongodb+php)

1. Prepare the linux environment (turn off selinux, iptables, configure ip and other initialization operations)

2. Preparing software:

1. apache: You can use yum to install it, or you can download the source code to compile.

2. mongodb: The current Linux is not integrated, so you need to download it.

My environment is Linux, bit 64, download http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz, others are on the mongodb official website.

3. php, php5 is used for development here, so download the source code and compile it. http://cn2.php.net/distributions/php-5.4.32.tar.gz

4. Because php5 needs to operate mongodb and does not have an integrated driver, you have to download the driver (php extension) http ://pecl.php.net/get/mongo-1.5.5.tgz

3. Installation

is the same as installing lamp(linux+apache+mysql+php). No matter which one is installed first, apache or mysql can be installed first, but php must be installed after these two. The standard lamp order is used here.

1. Install apache: yuminstall httpd* –y

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

ServerName host ip or host name: listening port (format, according to your own actual configuration)

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 very simple, just unzip the archive

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

Then configure the environment variables so that you do not need to bring the path 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, it must be sourced to take effect

[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--with-apxs2 will be followed by

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

/etc/httpd /modules/libphp5.so has this provided for apache to load php using

The --with-apxs2=/usr/sbin/apxs here is determined according to the actual situation (the location of the apxs command directory, if apache is compiled , you have to go to the apache directory to find it - this is also 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 php related commands do not need to bring 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 It only takes effect under source

[root@code ~]# source .bash_profile

4. Install php extension, 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 (generate the configurere file 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/869181.htmlTechArticlephp+mongodb development environment setup (linux+apache+mongodb+php) 1. Prepare the linux environment (turn off selinux, iptables, configure ip and other initialization operations) 2. Preparation software: 1. apache: You can use yum to install...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn