Linux服務器開發環境搭建 Nginx+PHP+MongoDB

Linux服務器開發環境搭建 Nginx+PHP+MongoDB

注意把php.ini  mv/php/conf

 

[日期:2012-05-19] 來源:Linux社區  作者:ruilinux [字體:大 中 小]  

 

Linux服務器開發環境搭建 Nginx+PHP+MongoDB

 

mkdir -p /home/trlinux/download

 

mkdir -p /home/trlinux/server

 

mkdir -p /home/trlinux/work

 

--------------------------------------------------------------------------------

 

1. 安裝Nginx

 

cd /home/trlinux/download;

 

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

 

tar zxvf nginx-1.0.5.tar.gz

 

cd /home/trlinux/download/nginx-1.0.5

 

./configure --prefix=/home/trlinux/server/nginx-1.0.5

 

make

 

make install

 

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

 

cd /home/nginx;

 

vim /etc/profile, 添加alias nginxtr='/home/nginx/sbin/nginx';  #這個隨意

 

source /etc/profile

 

這個時候你可以使用nginxtr -t nginxtr -s reload啓動和重新加載nginx

 

註釋:編譯報錯:./configure: error: the HTTP rewrite module requires the PCRE library.則安裝pcre~

 

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

 

如果要安裝purge模塊

 

ngx_cache_purge 通過這個模塊是的nginx可以像squid使用purge指令手動清除指定URL的緩存頁面。

 

安裝purge模塊

 

cd /home/trlinux/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/trlinux/server/nginx-1.0.5 --add-module=/home/download/ngx_cache_purge-1.3 --with-http_stub_status_module

 

--------------------------------------------------------------------------------

 

2. 安裝PHP

 

cd /home/trlinux/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/trlinux/server/php-5.3.6 --enable-fpm --enable-mbstring

 

make

 

make install

 

ln -s /home/trlinux/server/php-5.3.6/ /home/trlinux/server/php; cd /home/server/php

 

cd etc

 

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

 

vim php-fpm.conf, 修改pm.start_servers, pm.min_spare_servers, pm.max_spare_servers. 簡單點取消註釋即可

 

php: /home/server/php/sbin/php-fpm 啓動下php~

 

vim /etc/profile  添加alias trphp='pkill php-fpm; /home/server/php/sbin/php-fpm'

 

source /etc/profile

 

--------------------------------------------------------------------------------

 

3. 安裝PHP eaccelerator

 

eAccelerator 是一個開源並且免費的 PHP 加速器,優化器,編碼器,同時也能夠爲 PHP提供動態內容緩存。它能夠將 PHP 腳本緩存爲已編譯狀態以達到提升 PHP 腳本運行性能的目的,因此傳統的預編譯幾乎被消除。eAccelerator 也能夠優化 PHP 腳本以提升 PHP腳本的執行速度。eAccelerator 可有效降低服務器負載並且提高 PHP 程序速度達 1-10 倍。

 

cd /home/trlinux/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

 

cp /home/trlinux/download/php-5.3.6/php.inproduction /home/trlinux/server/php/lib/php.ini

 

vim /home/trlinux/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 -v  重啓php查看eaccelerator是否安裝成功

 

4. 安裝mongodb

 

cd /home/trlinux/download

 

wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz

 

tar zxvf mongodb-linux-i686-1.8.2.tgz

 

mv /home/trlinux/download/mongodb-linux-i686-1.8.2 /home/trlinux/server/mongodb-1.8.2 cd /home/trlinux/server/mongodb-1.8.2

 

啓動mongodb後臺進程:

 

mkdir -p /home/mongodata/

 

/home/trlinux/server/mongodb-1.8.2/bin/mongod --port=27017 --dbpath=/home/mongodata --logpath=/home/mongodata/mongodb.log &

 

--------------------------------------------------------------------------------

 

5. 安裝MongoDBPHP驅動

 

sudo pecl install mongo (/home/trlinux/server/php/bin/pecl install mongo)

 

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

 

添加extension=mongo.so

 

重啓php即可

 

報錯了...phpize: command not found

 

執行:

 

apt-get install php5-dev

 

--------------------------------------------------------------------------------

 

6. 安裝resin

 

cd /home/trlinux/download

 

wget http://www.caucho.com/download/resin-3.1.9.tar.gz

 

tar zxvf resin-3.1.9.tar.gz

 

cd resin-3.1.9

 

./configure --prefix=/home/resin

 

okay~ 大功告成!

 

本篇文章來源於 Linux公社網站(www.linuxidc.com)  原文鏈接:http://www.linuxidc.com/Linux/2012-05/60659p2.htm

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章