模板编辑器环境搭建

操作系统:CentOS 6.x 64位

编辑器框架:php5.5 + mongodb-org-3.2 + lighttpd-1.4.39

 

1. 安装mongodb-org-3.2

 

(1)添加yum的mongodb仓库

sudo vim /etc/yum.repos.d/mongodb-org-3.2.repo

添加以下内容:

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

(2)使用yum进行安装
sudo yum install -y mongodb-org

注意:如果SecureCRT的mongo壳下的退格键有问题,那么修改SecureCRT的选项 –> 会话选项 –> 终端 –> 仿真 –> 终端,将其改为linux

注意:启动mongodb时可能出现如下警告提示:

2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten]
2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten]
2016-06-16T22:15:01.057+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.

 

解决方法为,使用root用户执行下面命令后重启mongodb:

echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
echo "mongod soft nofile 64000
mongod hard nofile 64000
mongod soft nproc 32000
mongod hard nproc 32000" >> /etc/security/limits.conf

 

2. 升级到php5.5

(1)卸载php5.4-

sudo yum remove php php-cli php-common php-devel php-pear php-process php-xml

(2)安装webtatic-release

CentOS 6.x

sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

CentOS 7.x

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

(3)使用yum进行安装

sudo yum install -y php55w php55w-devel php55w-pear

3. 安装mongodb的php驱动mongodb

确保已安装依赖软件:gcc、openssl-devel

sudo pecl install mongodb

添加"extension=mongodb.so"到/etc/php.ini

4. 创建项目时添加mongodb的php驱动的高级接口PHPLIB,项目已存在时跳过此步

(1)安装composer

wget https://getcomposer.org/installer

php installer #如果执行不成功,可多执行几遍试试

mv composer.phar ~/bin/composer

(2)在项目根目录加载PHPLIB

composer require "mongodb/mongodb=^1.0.0"

5. 安装lighttpd

(1)确保已安装依赖软件:bzip2-devel

(2)下载并解压lighttpd源码包

wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.39.tar.gz

tar -zxvf lighttpd-1.4.39.tar.gz

cd lighttpd-1.4.39

(3)配置、构建和安装

./configure

make

sudo make install

(4)初始化脚本

sed -e 's/FOO/lighttpd/g' doc/initscripts/rc.lighttpd.redhat > /etc/init.d/lighttpd

chmod a+rx /etc/init.d/lighttpd

cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd

mkdir -p /etc/lighttpd

cp -R doc/config/conf.d/ doc/config/*.conf doc/config/vhosts.d/ /etc/lighttpd/

chkconfig lighttpd on

注意:/etc/init.d/lighttpd中的lighttpd命令所在位置可能不正确,需要修改

6.添加lighttpd用户

sudo groupadd lighttpd

sudo useradd -g lighttpd -M -s /sbin/nologin lighttpd

7.配置lighttpd

配置文件:/etc/lighttpd/lighttpd.conf

(1)url配置

url.rewrite += (
    "^/tpleditor/[^/]*$" => "/tpleditor/main.php",
    "^/tpleditor/([^/]+)/(.*)$" => "/tpleditor/app/$1/$2",
)
#只可访问main.php和app目录中的文件

 

(2)fastcgi配置

fastcgi.server = ( ".php" =>    # 文件扩展。Lighttpd内部提供FastCGI加载均衡
                   ( "php-local" =>     # 可选。用于mod_status统计,指示处理该文件扩展的后台处理器
                     (
                       "socket" => "/tmp/php-fastcgi-1.socket",
                       #"host" => "127.0.0.1",   # 指定socket或者host+port
                       #"port" => 9999,
                       "bin-path" => "/usr/bin/php-cgi",    # 如果本地FastCGI没有运行,该路径本地FastCGI将被启动
                     )
                   ),
                )

 

 

posted @ 2012-12-27 02:30  草谷子  阅读(663)  评论(0编辑  收藏  举报