一. 准备linux环境(关闭selinux,iptables,配置ip等初始化操作) 二. 准备软件: 1. apache:可以用yum来装,也可以下载源码编译。 2. mongodb:现在的linux没有集成,所以要下载。 三. 安装 就像安装lamp(linux+apache+mysql+php)一样的顺序。apache和mysql不管谁先安装都可以,但是php必须得在这两个后面。这里就采用标准的,lamp顺序。 1. 安装apache:yuminstall httpd* –y 安装好后修改配置文件/etc/httpd/conf/httpd.conf ServerName 主机ip或主机名:监听端口 (格式,根据自己的实际情况配置) 2. 安装mongodb: 先建立所需目录: [iyunv@code ~]# mkdir /data/mongodb/db –p [iyunv@code ~]# mkdir /data/mongodb/logs –p 然后安装mongodb:安装很简单,解压归档就可以了 [iyunv@code pub]# tar -xvf mongodb-linux-x86_64-1.6.4.tar.gz-C /usr/local/ 接着配置环境变量,使得使用命令的时候不需要带上路径 [iyunv@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 最后要source下才生效 [iyunv@code ~]# source .bash_profile 3. 安装php5 [iyunv@code pub]# tar -xvf php-5.4.32.tar.gz [iyunv@code pub]# cd php-5.4.32 [iyunv@code php-5.4.32]# ./configure --prefix=/usr/local/php--with-config-file-path=/etc --with-apxs2=/usr/sbin/apxs 这里--with-apxs2之后将会在 [iyunv@code ~]# ls /etc/httpd/modules/libphp5.so
/etc/httpd/modules/libphp5.so有这个提供给apache加载php使用 这里的--with-apxs2=/usr/sbin/apxs根据实际情况决定(apxs命令目录所在位置,如果apache是编译的话,就要去apache目录下找—这里也根据实际情况) [iyunv@code php-5.4.32]# make && make install [iyunv@code php-5.4.32]# cp php.ini-production /etc/php.ini 配置环境变量,使得php相关命令不需要带上路径 [iyunv@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 最后要source下才生效 [iyunv@code ~]# source .bash_profile 4. 安装php扩展,对mongodb的支持 [iyunv@code pub]# tar -xvf mongo-1.5.5.tgz [iyunv@code pub]# cd mongo-1.5.5 [iyunv@code mongo-1.5.5]# phpize(之后生成configuere文件) [iyunv@code mongo-1.5.5]# ./configure --enable-mongo=share--with-php-config=php-config [iyunv@code mongo-1.5.5]# make && make install 5. 配置/etc/php.ini extension=mongo.so
register_globals=On 6. 配置/etc/httpd/conf/httpd.conf LoadModule php5_module modules/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
|