php mongodb ngnix,linux nginx+php+mongodb安装

安装准备,新建目录

mkdir -p

/home/download

mkdir -p /home/server

mkdir -p

/home/workspace

一、安装nginx

1、下载nginx

cd /home/download;

wget

http://nginx.org/download/nginx-1.0.5.tar.gz

2、解压

tar zxvf

nginx-1.0.5.tar.gz;

3、配置

cd

/home/download/nginx-1.0.5;

./configure

--prefix=/home/server/nginx-1.0.5;

4、安装

make;

make install;

ln -s /home/server/nginx-1.0.5/

/home/nginx

cd /home/nginx;

vi /etc/profile, 添加alias

ngx='/home/nginx/sbin/nginx' #非必须步骤

source /etc/profile

此时即可使用ngx -t 和ngx -s

reload启动和重新加载nginx, 利用pkill nginx停止nginx

*执行第3步是可能出现错误

注:如果出现./configure: error: the

HTTP rewrite module requires the PCRE library.则执行下列脚本:

wget

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz

tar -zvxf pcre-8.12.tar.gz ; cd

pcre-8.12

./configure

make; make install

启动nginx

/home/nginx/sbin/nginx -c

/home/server/nginx-1.0.5/conf/nginx.conf

停止nginx

/home/nginx/sbin/nginx -s

stop

重启nginx

/home/nginx/sbin/nginx -s

reload

如果要安装purge模块

cd /home/download

wget

http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz

tar zxvf

ngx_cache_purge-1.3.tar.gz

./configure

--prefix=/home/server/nginx-1.0.5

--add-module=/home/download/ngx_cache_purge-1.3

--with-http_stub_status_module

二、安装PHP

cd /home/download;

wget

http://cn.php.net/distributions/php-5.3.6.tar.gz

tar zxvf

php-5.3.6.tar.gz;

cd php-5.3.6; ./configure

--prefix=/home/server/php-5.3.6 --enable-fpm

--enable-mbstring

make;

make install;

ln -s /home/server/php-5.3.6/

/home/server/php; cd /home/server/php;

cd etc;  cp

php-fpm.conf.default php-fpm.conf

vi php-fpm.conf,

修改pm.start_servers, pm.min_spare_servers, pm.max_spare_servers.

简单点取消注释即可

启动php:

/home/server/php/sbin/php-fpm

vi /etc/profile; 添加alias

rsphp='pkill php-fpm;

/home/server/php/sbin/php-fpm' #可选

source

/etc/profile

启动php时出现错误

[/home/server/php-5.3.28/etc/php-fpm.conf:190]

value is NULL for a ZEND_INI_PARSER_ENTRY

解决:

是copy错了php-fpm.conf 文件。

默认是没有此文件的,但是在php安装目录下/etc下有php-fpm.conf.default,这个才是你需要的。 cp 一个成

php-fpm.conf,启动php吧

*nginx+php的整合配置*

vi /home/server/nginx-1.0.5/conf/nginx.conf

将如下几行的注释去掉,并将scripts改成$document_root

location ~ \.php$ {

root  html;  #这是你网站的根目录

fastcgi_pass  127.0.0.1:9000;

#这里指定了fastcgi进程侦听的端口,nginx就是通过这里与php交互的

fastcgi_index

index.php;

fastcgi_param SCRIPT_FILENAME

$document_root/$fastcgi_script_name;

include  fastcgi_params;

}

安装PHP eaccelerator

cd /home/download;

wget

http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2

tar jxvf eaccelerator-0.9.6.1.tar.bz2; cd

eaccelerator-0.9.6.1;

/home/server/php/bin/phpize

./configure --enable-eaccelerator=shared

--with-php-config=/home/server/php/bin/php-config

make; make install

mkdir /tmp/eaccelerator

chmod 0777 /tmp/eaccelerator

vi /home/server/php/lib/php.ini (如果没有,cp /home/download/php-5.3.6/php.ini-production

/home/server/php/lib/php.ini)

添加:

extension="eaccelerator.so" eaccelerator.shm_size="16"

eaccelerator.cache_dir="/tmp/eaccelerator"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.log_file = "/tmp/eaccelerator/eaccelerator.log"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="0"

eaccelerator.shm_prune_period="0"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

重启php, php -v 查看eaccelerator是否安装成功

三、安装mongodb

cd /home/download;

wget

http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.1.tgz

tar -zxvf mongodb-linux-x86_64-2.6.1.tgz

mv /home/download/mongodb-linux-x86_64-2.6.1 /home/server/mongodb-2.6.1;

cd

/home/server/mongodb-2.6.1;

启动mongodb后台进程:

mkdir -p

/home/mongodata/;

/home/server/mongodb-2.6.1/bin/mongod

--port=27017 --dbpath=/home/mongodata

--logpath=/home/mongodata/mongodb.log &

安装MongoDB的PHP驱动

sudo pecl install mongo

(/home/server/php/bin/pecl install

mongo)

vi /home/server/php/lib/php.ini;

添加extension=mongo.so,重启php即可

注:如果出现phpize: command not

found,则执行

apt-get install

php5-dev

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值