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
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
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
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
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是否安装成功