CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安

平台环境

严重参考: http://blog.s135.com/nginx_php_v6/

centos 6.2 64位 nginx-1.2.1 php-5.3.14 mysql-5.5.25

一.总体介绍

一、安装依赖库和开发环境

系统环境  CentOS release 5.5 (Final)   ,kernel  2.6.18-194.el5

 安装gcc的

安装 Nginx 、 PHP(FastCGI)   、 MySQL  、  wordpress
版本如下
 nginx-0.8.46    php-5.2.14   mysql-5.5.3-m3  wordpress-3.1.1-zh_CN

错误 提示:kernel-headers >= 2.2.1

二.安装准备

解决办法是,打开 /etc/yum.conf 然后找到这行: 

1.环境设置
sudo -s
LANG=C
yum -y install gcc gcc-c autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

exclude=kernel* 

2.下载软件 
注意,所有软件都下载到了 /home/root/data1下面  一共4个软件

修改为: 

mkdir -p /home/root/data1
cd   /home/root/data1
wget http://blog.s135.com/soft/[Linux](http://www.jikexueyuan.com/course/linuxsys/)/nginx_php/nginx/nginx-0.8.46.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz

exclude= 


三.安装PHP 5.2.14(FastCGI模式)

1.编译安装 PHP 5.2.14所需的支持库
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../

就可以安装 gcc 了。

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

 

tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

安装升级所需程序库

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

  1. sudo -s 
  2. LANG=C 
  3. yum -y install gcc gcc-c  autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers 

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

 

2.编译安装MySQL 5.5.3-m3
(1)

64位编译mysql5.5.25a可能会出现各种各样的问题,下面的库也一起安装吧,有部分重复的自己去掉

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3/
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
chmod w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../

  1. yum -y install bison gcc gcc-c  autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel 

(2) 创建MySQL数据库存放目录
mkdir  -p /media/raid10/mysql/3306/data/
mkdir  -p /media/raid10/mysql/3306/binlog/
mkdir  -p /media/raid10/mysql/3306/relaylog/
chown  -R mysql:mysql  /media/raid10/mysql/

三、下载所需程序

注意:因为要存放数据库文件,所以我把 这些文件,存放在 RAID10的设备上
实现 软RAID10,可以查看之前的文章共三篇
http://blog.csdn.net/longxibendi/archive/2011/04/20/6336912.aspx
http://blog.csdn.net/longxibendi/archive/2011/04/20/6336921.aspx
http://blog.csdn.net/longxibendi/archive/2011/04/20/6336947.aspx

  1. mkdir -p /data0/soft 
  2. cd /data0/soft 
  3. wget http://cn2.php.net/get/php-5.3.14.tar.gz/from/this/mirror 
  4. wget http://www.nginx.org/download/nginx-1.2.1.tar.gz 
  5. wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.25a.tar.gz 
  6. wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz 
  7. wget http://blog.s135.com/soft/[Linux](http://www.jikexueyuan.com/course/linuxsys/)/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz 
  8. wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz 
  9. wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz 
  10. wget http://pecl.php.net/get/memcache-3.0.6.tgz 
  11. wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2 
  12. wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz 
  13. wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz 
  14. wget http://pecl.php.net/get/imagick-2.3.0.tgz 
  15. wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz 
  16. wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz 

(3).以mysql用户帐号的身份建立数据表 /usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/media/raid10/mysql/3306/data --user=mysql

四、安装PHP 5.3.14

(4).创建my.cnf配置文件
vi /media/raid10/mysql/3306/my.cnf

  1. tar zxvf libiconv-1.14.tar.gz 
  2. cd libiconv-1.14/ 
  3. ./configure --prefix=/usr/local 
  4. make 
  5. make install 
  6. cd ../ 

[client]
character-set-server = utf8
port    = 3306
socket  = /tmp/mysql.sock

 

[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user    = mysql
port    = 3306
socket  = /tmp/mysql.sock
basedir = /usr/local/webserver/mysql
datadir = /media/raid10/mysql/3306/data
log-error = /media/raid10/mysql/3306/mysql_error.log
pid-file = /media/raid10/mysql/3306/mysql.pid
open_files_limit    = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 20M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 20M
max_heap_table_size = 20M
long_query_time = 3
log-slave-updates
log-bin = /media/raid10/mysql/3306/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 20M
relay-log-index = /media/raid10/mysql/3306/relaylog/relaylog
relay-log-info-file = /media/raid10/mysql/3306/relaylog/relaylog
relay-log = /media/raid10/mysql/3306/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 10M
read_buffer_size = 1M
read_rnd_buffer_size = 6M
bulk_insert_buffer_size = 4M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 20M
myisam_repair_threads = 1
myisam_recover

  1. tar zxvf libmcrypt-2.5.8.tar.gz  
  2. cd libmcrypt-2.5.8/ 
  3. ./configure 
  4. make 
  5. make install 
  6. /sbin/ldconfig 
  7. cd libltdl/ 
  8. ./configure --enable-ltdl-install 
  9. make 
  10. make install 
  11. cd ../../ 

interactive_timeout = 120
wait_timeout = 120

skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

  1. tar zxvf mhash-0.9.9.9.tar.gz 
  2. cd mhash-0.9.9.9/ 
  3. ./configure 
  4. make 
  5. make install 
  6. cd ../ 

#master-host     =   192.168.1.2
#master-user     =   username
#master-password =   password
#master-port     =  3306

 

server-id = 1

  1. ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la 
  2. ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so 
  3. ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 
  4. ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 
  5. ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a 
  6. ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la 
  7. ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so 
  8. ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 
  9. ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 
  10. ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config 

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 20M
innodb_data_file_path = ibdata1:56M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 20M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0

 

#log-slow-queries = /media/raid10/mysql/3306/slow.log
#long_query_time = 10

  1. tar zxvf mcrypt-2.6.8.tar.gz 
  2. cd mcrypt-2.6.8/ 
  3. /sbin/ldconfig 
  4. ./configure 
  5. make 
  6. make install 
  7. cd ../ 

[mysqldump]
quick
max_allowed_packet = 32M

 

注意:由于用的虚拟机,只分配了512M内存,所以,相应的参数配置的很小。根据自己需求配置

五、编译安装MySQL 5.5.25a

(5).创建一个shell脚本,管理MySQL
vi  /media/raid10/mysql/3306/mysql
输入以下内容(这里的用户名是admin 密码是 12345678 ,接下来会创建这个用户并授权)

  1. tar zxvf cmake-2.8.8.tar.gz 
  2. cd cmake-2.8.8 
  3. ./configure 
  4. gmake  
  5. gmake install  
  6. cd ../ 

#!/bin/sh

mysql_port=3306
mysql_username="admin"
mysql_password="12345678"

64位系统安装cmake后执行cmake命令,如不能找到命令,是环境变量的问题,可到cmake目录再执行cmake命令  或添加环境变量,如能直接执行,此步可省略,设置环境变量# export PATH=/usr/local/bin:$PATH  

function_start_mysql()
{
    printf "Starting MySQL.../n"
    /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/media/raid10/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &
}

  1. /usr/sbin/groupadd mysql 
  2. /usr/sbin/useradd -g mysql mysql 
  3. tar zxvf mysql-5.5.25a.tar.gz 
  4. cd mysql-5.5.25a 

function_stop_mysql()
{
    printf "Stoping MySQL.../n"
    /usr/local/webserver/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
}

function_restart_mysql()
{
    printf "Restarting MySQL.../n"
    function_stop_mysql
    sleep 5
    function_start_mysql
}

  1. cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql 
  2. -DEXTRA_CHARSETS=all 
  3. -DWITH_READLINE=1 
  4. -DWITH_SSL=system 
  5. -DWITH_EMBEDDED_SERVER=1 
  6. -DENABLED_LOCAL_INFILE=1 
  7. -DWITH_INNOBASE_STORAGE_ENGINE=1 
  8. -DWITHOUT_PARTITION_STORAGE_ENGINE=1
  9. make 
  10. make intall 

function_kill_mysql()
{
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}

 

if [ "$1" = "start" ]; then
    function_start_mysql
elif [ "$1" = "stop" ]; then
    function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_kill_mysql
else
    printf "Usage: /media/raid10/mysql/${mysql_port}/mysql {start|stop|restart|kill}/n"
fi

  1. chmod  w /usr/local/webserver/mysql 
  2. chown -R mysql:mysql /usr/local/webserver/mysql 
  3. cd ../ 

(6).赋予shell脚本 mysql 执行权限

 

chmod x /media/raid10/mysql/3306/mysql

附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下几步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。
①、创建MySQL数据库存放目录

(7).启动MySQL

  1. mkdir -p /data0/mysql/3306/data/ 
  2. mkdir -p /data0/mysql/3306/binlog/ 
  3. mkdir -p /data0/mysql/3306/relaylog/ 
  4. chown -R mysql:mysql /data0/mysql/ 

/media/raid10/mysql/3306/mysql start

 #设置mysql我这里分两种方案,可以任选其一。

(8).通过以下命令登录管理MySQL服务器(提示输入密码直接回车,这是用root登录的)

方案一:

/usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock

(9).输入以下SQL语句,用于创建一个具有root权限的用户 ,用户名是 上面提到的 admin 密码  是 12345678  
 

#在support-files目录中有五个配置信息文件:这里我们选择内存1-2G的

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';

#my-small.cnf (内存<=64M)

因为接下来要安装wordpress,所以最好再加一条

#my-medium.cnf (内存 128M)

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'172.29.141.112' IDENTIFIED BY '12345678';

#my-large.cnf (内存 512M)

注意:
这里的 172.29.141.112 是允许 连接 MySQL服务器的客户端IP地址 ;
*.* 表示 所有 库和所有表   比如  blog.wordpress  表示 blog库的wordpress表

#my-huge.cnf (内存 1G-2G)

最后再加上

#my-innodb-heavy-4G.cnf (内存 4GB)

flush privileges ;

  1. cd /usr/local/webserver/mysql 
  2. cp ./support-files/my-huge.cnf /etc/my.cnf  
  3. vi /etc/my.cnf 

(10).停止 MySQL  (可选)
/media/raid10/mysql/3306/mysql stop

编辑配置文件,在 

或者用 root 停止

#在 [mysqld] 段增加

3.编译安装PHP(FastCGI模式)
tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
cd php-5.2.14/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../

4.编译安装PHP5扩展模块

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../

 

tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../

  1. datadir = /data0/mysql/3306/data #添加MySQL数据库路径 
  2. wait-timeout = 30 
  3. max_connections = 512 
  4. default-storage-engine = MyISAM 
  5. max_allowed_packet = 16M

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
cd ../

方案二:

tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../

关于my.cnf配置文件,我这里贴一个我配置的,仅作参考,可以忽略。如选择此方案,在/etc/my.cnf 里面输入下面的内容 

tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../

[client]

5.修改php.ini文件

default-character-set = utf8

手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
  修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
  并在此行后增加以下几行,然后保存:
  extension = "memcache.so"
  extension = "pdo_mysql.so"
  extension = "imagick.so"

port    = 3306

  再查找output_buffering = Off
  修改为output_buffering = On

socket  = /tmp/mysql.sock

  再查找; cgi.fix_pathinfo=0
  修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞。

[mysqld]

  自动修改:若嫌手工修改麻烦,可执行以下shell命令,自动完成对php.ini文件的修改:
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"/nextension = "memcache.so"/nextension = "pdo_mysql.so"/nextension = "imagick.so"/n#' /usr/local/webserver/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/webserver/php/etc/php.ini
sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" /usr/local/webserver/php/etc/php.ini
sed -i "s#; cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g" /usr/local/webserver/php/etc/php.ini

character-set-server = utf8

6.配置eAccelerator加速PHP:
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini

replicate-ignore-db = mysql

  按shift g键跳到配置文件的最末尾,加上以下配置信息:

replicate-ignore-db = test

[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

replicate-ignore-db = information_schema

7.创建www用户和组,以及供blog虚拟主机使用的目录:
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir  -p  /media/raid10/htdocs/blog
chmod  w  /media/raid10/htdocs/blog
chown  -R  www:www /media/raid10/htdocs/blog
mkdir  -p  /media/raid10/htdocs/www
chmod  w  /media/raid10/htdocs/www
chown  -R  www:www /media/raid10/htdocs/www

8.创建php-fpm配置文件(php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi):

  在/usr/local/webserver/php/etc/目录中创建php-fpm.conf文件:
rm -f /usr/local/webserver/php/etc/php-fpm.conf
vi /usr/local/webserver/php/etc/php-fpm.conf

user    = mysql

  输入以下内容(如果您安装 Nginx PHP 用于程序调试,请将以下的<value name="display_errors">0</value>改为<value name="display_errors">1</value>,以便显示PHP错误信息,否则,Nginx 会报状态为500的空白错误页):
<?xml version="1.0" ?>
<configuration>

port    = 3306

  All relative paths in this config are relative to php's install prefix

socket  = /tmp/mysql.sock

  <section name="global_options">

basedir = /usr/local/webserver/mysql

    Pid file
    <value name="pid_file">/usr/local/webserver/php/logs/php-fpm.pid</value>

datadir = /data0/mysql/3306/data

    Error log file
    <value name="error_log">/usr/local/webserver/php/logs/php-fpm.log</value>

log-error = /data0/mysql/3306/mysql_error.log

    Log level
    <value name="log_level">notice</value>

pid-file = /data0/mysql/3306/mysql.pid

    When this amount of php processes exited with SIGSEGV or SIGBUS ...
    <value name="emergency_restart_threshold">10</value>

#默认10240

    ... in a less than this interval of time, a graceful restart will be initiated.
    Useful to work around accidental curruptions in accelerator's shared memory.
    <value name="emergency_restart_interval">1m</value>

open_files_limit    = 9600

    Time limit on waiting child's reaction on signals from master
    <value name="process_control_timeout">5s</value>

#默认600

    Set to 'no' to debug fpm
    <value name="daemonize">yes</value>

back_log = 300

  </section>

#默认5000

  <workers>

max_connections = 2000

    <section name="pool">

#默认6000

      Name of pool. Used in logs and stats.
      <value name="name">default</value>

max_connect_errors = 3000

      Address to accept fastcgi requests on.
      Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
      <value name="listen_address">127.0.0.1:9000</value>

table_cache = 614

      <value name="listen_options">

table_open_cache = 614

        Set listen(2) backlog
        <value name="backlog">-1</value>

external-locking = FALSE

        Set permissions for unix socket, if one used.
        In Linux read/write permissions must be set in order to allow connections from web server.
        Many BSD-derrived systems allow connections regardless of permissions.
        <value name="owner"></value>
        <value name="group"></value>
        <value name="mode">0666</value>
      </value>

max_allowed_packet = 32M

      Additional php.ini defines, specific to this pool of workers.
      <value name="php_defines">
        <value name="sendmail_path">/usr/sbin/sendmail -t -i</value>
        <value name="display_errors">0</value>
      </value>

sort_buffer_size = 1M

      Unix user of processes
      <value name="user">www</value>

join_buffer_size = 1M

      Unix group of processes
      <value name="group">www</value>

#默认300

      Process manager settings
      <value name="pm">

thread_cache_size = 150

        Sets style of controling worker process count.
        Valid values are 'static' and 'Apache-like'
        <value name="style">static</value>

#双核的话设4,4核设8,此处禁止了

        Sets the limit on the number of simultaneous requests that will be served.
        Equivalent to Apache MaxClients directive.
        Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
        Used with any pm_style.
        <value name="max_children">128</value>

#thread_concurrency = 8

        Settings group for 'apache-like' pm style
        <value name="apache_like">

#默认512

          Sets the number of server processes created on startup.
          Used only when 'apache-like' pm_style is selected
          <value name="StartServers">20</value>

query_cache_size = 256M

          Sets the desired minimum number of idle server processes.
          Used only when 'apache-like' pm_style is selected
          <value name="MinSpareServers">5</value>

query_cache_limit = 2M

          Sets the desired maximum number of idle server processes.
          Used only when 'apache-like' pm_style is selected
          <value name="MaxSpareServers">35</value>

query_cache_min_res_unit = 2k

        </value>

default-storage-engine = MyISAM

      </value>

thread_stack = 192K

      The timeout (in seconds) for serving a single request after which the worker process will be terminated
      Should be used when 'max_execution_time' ini option does not stop script execution for some reason
      '0s' means 'off'
      <value name="request_terminate_timeout">0s</value>

transaction_isolation = READ-COMMITTED

      The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
      '0s' means 'off'
      <value name="request_slowlog_timeout">0s</value>

#默认246

      The log file for slow requests
      <value name="slowlog">logs/slow.log</value>

tmp_table_size = 128M

      Set open file desc rlimit
      <value name="rlimit_files">65535</value>

max_heap_table_size = 246M

      Set max core size rlimit
      <value name="rlimit_core">0</value>

long_query_time = 3

      Chroot to this directory at the start, absolute path
      <value name="chroot"></value>

log-slave-updates

      Chdir to this directory at the start, absolute path
      <value name="chdir"></value>

log-bin = /data0/mysql/3306/binlog/binlog

      Redirect workers' stdout and stderr into main error log.
      If not set, they will be redirected to /dev/null, according to FastCGI specs
      <value name="catch_workers_output">yes</value>

binlog_cache_size = 4M

      How much requests each process should execute before respawn.
      Useful to work around memory leaks in 3rd party libraries.
      For endless request processing please specify 0
      Equivalent to PHP_FCGI_MAX_REQUESTS
      <value name="max_requests">1024</value>

binlog_format = MIXED

      Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
      Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2 )
      Makes sense only with AF_INET listening socket.
      <value name="allowed_clients">127.0.0.1</value>

max_binlog_cache_size = 8M

      Pass environment variables like LD_LIBRARY_PATH
      All $VARIABLEs are taken from current environment
      <value name="environment">
        <value name="HOSTNAME">$HOSTNAME</value>
        <value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
        <value name="TMP">/tmp</value>
        <value name="TMPDIR">/tmp</value>
        <value name="TEMP">/tmp</value>
        <value name="OSTYPE">$OSTYPE</value>
        <value name="MACHTYPE">$MACHTYPE</value>
        <value name="MALLOC_CHECK_">2</value>
      </value>

max_binlog_size = 1G

    </section>

relay-log-index = /data0/mysql/3306/relaylog/relaylog

  </workers>

relay-log-info-file = /data0/mysql/3306/relaylog/relaylog

</configuration>

9.启动php-cgi进程,监听127.0.0.1的9000端口,进程数为128(如果服务器内存小于3GB,可以只开启64个进程),用户为www:

ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm start

relay-log = /data0/mysql/3306/relaylog/relaylog

注意:/usr/local/webserver/php/sbin/php-fpm还有其他参数,包括:start|stop|quit|restart|reload|logrotate,修改php.ini后不重启php-cgi,重新加载配置文件使用reload。

四.安装Nginx 0.8.46


1.安装Nginx所需的pcre库:

expire_logs_days = 30

tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../**

#默认256

2.安装Nginx

key_buffer_size = 64M

tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../

read_buffer_size = 1M

3.创建Nginx日志目录**

read_rnd_buffer_size = 16M

mkdir -p /media/raid10/logs
chmod w /media/raid10/logs
chown -R www:www /media/raid10/logs

4.创建Nginx配置文件

(1)在/usr/local/webserver/nginx/conf/目录中创建nginx.conf文件:
rm -f /usr/local/webserver/nginx/conf/nginx.conf
vi /usr/local/webserver/nginx/conf/nginx.conf

#默认64

输入以下内容:
user  www www;

bulk_insert_buffer_size = 32M

worker_processes 8;

#默认128

error_log  /media/raid10/logs/nginx_error.log  crit;

myisam_sort_buffer_size = 64M

pid        /usr/local/webserver/nginx/nginx.pid;

myisam_max_sort_file_size = 10G

#Specifies the value for maximum file descriptors that can be opened by this pro
cess.
worker_rlimit_nofile 65535;

myisam_repair_threads = 1

events
{
  use epoll;
  worker_connections 65535;
}

myisam_recover

http
{
  include       mime.types;
  default_type  application/octet-stream;

 

  #charset  gb2312;
     
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 8m;
     
  sendfile on;
  tcp_nopush     on;

interactive_timeout = 120

  keepalive_timeout 60;

wait_timeout = 120

  tcp_nodelay on;

 

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;

skip-name-resolve

  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;

#master-connect-retry = 10

  #limit_zone  crawler  $binary_remote_addr  10m;

slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

  server
  {
    listen       80;
    server_name  172.29.141.112 ;
    index index.html index.htm index.php;
    root  /media/raid10/htdocs/blog;

 

    #limit_conn   crawler  20;   
                           
    location ~ .*/.(php|php5)?$
    {     
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
   
    location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }

#master-host     =   192.168.1.2

    location ~ .*/.(js|css)?$
    {
      expires      1h;
    }   

#master-user     =   username

    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';
    access_log  /media/raid10/logs/access.log  access;
      }

#master-password =   password

}

#master-port     =  3306

(2).在/usr/local/webserver/nginx/conf/目录中创建fcgi.conf文件:
vi /usr/local/webserver/nginx/conf/fcgi.conf

 

输入以下内容:

server-id = 1

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;

 

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

innodb_additional_mem_pool_size = 16M

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

innodb_buffer_pool_size = 512M

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

innodb_data_file_path = ibdata1:256M:autoextend

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

5.启动Nginx

ulimit -SHn 65535
/usr/local/webserver/nginx/sbin/nginx

innodb_file_io_threads = 4

五.配置开机自动启动Nginx PHP
vi /etc/rc.local

innodb_thread_concurrency = 8

  在末尾增加以下内容:

innodb_flush_log_at_trx_commit = 2

ulimit -SHn 65535
/usr/local/webserver/php/sbin/php-fpm start
/usr/local/webserver/nginx/sbin/nginx

六.优化Linux内核参数

innodb_log_buffer_size = 16M

具体参考http://blog.csdn.net/longxibendi/archive/2011/04/23/6343686.aspx
vi  /etc/sysctl.conf

innodb_log_file_size = 128M

# http://blog.csdn.net/longxibendi/archive/2011/04/23/6343686.aspx
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog =  32768
net.core.somaxconn = 32768

innodb_log_files_in_group = 3

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

innodb_max_dirty_pages_pct = 90

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

innodb_lock_wait_timeout = 120

net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1

innodb_file_per_table = 0

net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800

#log-slow-queries = /data0/mysql/3306/slow.log

#net.ipv4.tcp_fin_timeout = 30
#net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024  65535

#long_query_time = 10

#http://blog.csdn.net/longxibendi/archive/2011/04/23/6343686.aspx 

[mysqldump]

使配置立即生效:
/sbin/sysctl -p

quick

七.在不停止Nginx服务的情况下平滑变更Nginx配置
  1.修改/usr/local/webserver/nginx/conf/nginx.conf配置文件后,请执行以下命令检查配置文件是否正确:
/usr/local/webserver/nginx/sbin/nginx -t

max_allowed_packet = 32M

  如果屏幕显示以下两行信息,说明配置文件正确:
  the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
  the configuration file /usr/local/webserver/nginx/conf/nginx.conf was tested successfully

[myisamchk]

  2.平滑重启:
  (1)对于Nginx 0.8.x版本,现在平滑重启Nginx配置非常简单,执行以下命令即可:
/usr/local/webserver/nginx/sbin/nginx -s reload

#默认256

  (2)对于Nginx 0.8.x之前的版本,平滑重启稍微麻烦一些,按照以下步骤进行即可。输入以下命令查看Nginx主进程号:
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'

key_buffer_size = 128M

  屏幕显示的即为Nginx主进程号,例如:
  6302
  这时,执行以下命令即可使修改过的Nginx配置文件生效:
kill -HUP 6302

#默认256

  或者无需这么麻烦,找到Nginx的Pid文件:
kill -HUP `cat /usr/local/webserver/nginx/nginx.pid`

sort_buffer_size = 128M

   或者
ps -ef | grep nginx | grep -v grep | xargs kill {}/;

read_buffer = 2M

   或者

write_buffer = 2M

kill  1  `cat /usr/local/webserver/nginx/nginx.pid`

[mysqlhotcopy]

八.编写每天定时切割Nginx日志的脚本
  1、创建脚本/usr/local/webserver/nginx/sbin/cut_nginx_log.sh
vi /usr/local/webserver/nginx/sbin/cut_nginx_log.sh

interactive-timeout

  输入以下内容:
引用
#!/bin/bash
# This script run at 00:00

 

# The Nginx logs path
logs_path="/usr/local/webserver/nginx/logs/"

以上配置文件仅作1.5G内存主机参考

mkdir -p ${logs_path}$(date -d "yesterday" "%Y")/$(date -d "yesterday" "%m")/
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" "%Y")/$(date -d "yesterday" "%m")/access_$(date -d "yesterday" "%Y%m%d").log
kill -USR1 `cat /usr/local/webserver/nginx/nginx.pid`

#生成授权表

  2、设置crontab,每天凌晨00:00切割nginx访问日志
crontab -e

  1. ./scripts/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/data0/mysql/3306/data --user=mysql #生成mysql系统数据库 

  输入以下内容:
引用
00 00 * * * /bin/bash  /usr/local/webserver/nginx/sbin/cut_nginx_log.sh

#更改密码

九.安装 wordpress
(1)下载 
cd /home/root/data1
wget http://cn.wordpress.org/wordpress-3.1.1-zh_CN.tar.gz

  1. /usr/local/webserver/mysql/bin/mysqladmin -u root password '12345678'  

(2)解压 、赋权
tar zxvf wordpress-3.1.1-zh_CN.tar.gz  -C  /media/raid10/htdocs/blog/
chmod 777 -R /media/raid10/htdocs/blog/

#开启mysql

(3)创建数据库
/usr/local/webserver/mysql/bin/mysql -u admin -p -S /tmp/mysql.sock
(注意密码是 12345678)
MySQL>create database blog;
MySQL>flush privileges;

  1. /usr/local/webserver/mysql/bin/mysqld_safe & 

(4)修改 wp-config-sample.php
mv /media/raid10/htdocs/blog/wordpress/wp-config-sample.php   /media/raid10/htdocs/blog/wordpress/wp-config.php
vi /media/raid10/htdocs/blog/wordpress/wp-config.php  修改数据库名,用户,密码,数据库IP
比如我的修改后的文件部分内容是

#通过命令行登录管理MySQL服务器(提示输入密码时直接回车,上处修改密码了的话这里要输入的):

// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress 数据库的名称 */
define('DB_NAME', 'blog');

  1. /usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock 
  2. show databases; 
  3. exit; 

/** MySQL 数据库用户名 */
define('DB_USER', 'admin');

#设置开机启动

/** MySQL 数据库密码 */
define('DB_PASSWORD', '12345678');

  1. vi /etc/rc.d/rc.local 

/** MySQL 主机 */
define('DB_HOST', '172.29.141.112');

#加入

注意:这里的DB_HOST对应的IP是,安装数据库的系统IP

  1. /usr/local/webserver/mysql/bin/mysqld_safe & 

(5)安装,运行 install.php
http://172.29.141.112/wordpress/install.php
或者  http://172.29.141.112/wordpress/wp-admin/install.php

 

根据前面设置的用户名和密码安装即可

可以暂时停止mysql

 

/usr/local/webserver/mysql/bin/mysqladmin -u root -p shutdown

然后就可以访问 http://172.29.141.112/wordpress/  了,

//mysql安装到此截止了,php请看下一章

 

附:常用mysql命令:

注意 :  如果想让非本机用户访问 需要打开防火墙 http服务 。默认只允许 SSH服务

(1)查看用户信息

十.参考内容

select user,host,password from mysql.user;

 http://blog.s135.com/nginx_php_v6/

(2)输入以下SQL语句,创建一个具有root权限的用户(admin)和密码(12345678):

 http://nginx.org/en/docs/  Nginx 详细信息

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678';

 http://wiki.nginx.org/NginxChs

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';

 http://blog.csdn.net/longxibendi/archive/2011/04/23/6343686.aspx
《实战Nginx:取代Apache的高性能Web服务器》  作者 张宴
《互联网运营智慧(高可用可扩展网站技术实战)》  作者 田逸
《Linux系统管理技术手册第二版》
《鸟哥的Linux私房菜第三版基础篇》

(3)创建数据库

声明:本文档可以随意更改,但必须署名原作者

/usr/local/webserver/mysql/bin/mysql -u admin -p -S /tmp/mysql.sock

作者:凤凰舞者 qq:578989855

(注意密码是 12345678)

 

MySQL>create database blog;

版权声明:本文为博主原创文章,未经博主允许不得转载。

MySQL>flush privileges;


查询用户下的数据库

SHOW DATABASES; 

查询数据库编码:SHOW VARIABLES LIKE 'character%';

3、编译安装PHP(FastCGI模式)如果是64位操作系统,需要先进行下步工作

 如果是64位操作系统,需要先进行下步工作

 

解决没有安装 patch 工具问题,

解决imagemagick问题     

解决 configure: error: libjpeg.(a|so) not found  错误

解决configure: error: libpng.(a|so) not found

解决  configure: error: Cannot find ldap libraries in /usr/lib  错误,上面的错误也可用这种方法解决

  1. yum install patch 
  2. yum -y install perl-CPAN 
  3. ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so 
  4. ln -s /usr/lib64/libpng.so /usr/lib/libpng.so 
  5. ln -s /usr/lib64/libldap.so /usr/lib/libldap.so 
  1. tar zxvf php-5.3.14.tar.gz 
  2. cd php-5.3.14/ 
  3. ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so /usr/lib64/ 
  4. ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 
32位系统应该是下面的,为免出错,可以全做
  1. ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so /usr/lib/ 
  2. ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18 
  1. ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap 
  1. make ZEND_EXTRA_LIBS='-liconv' 
  2. make install 
  1. cp php.ini-production /usr/local/webserver/php/etc/php.ini 
  2. cd ../ 

4、编译安装PHP5扩展模块

  1. tar zxvf memcache-3.0.6.tgz 
  2. cd memcache-3.0.6/ 
  3. /usr/local/webserver/php/bin/phpize 
  4. ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 
  5. make 
  6. make install 
  7. cd ../ 
  1. tar jxvf eaccelerator-0.9.6.1.tar.bz2 
  2. cd eaccelerator-0.9.6.1/ 
  3. /usr/local/webserver/php/bin/phpize 
  4. ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config 
  5. make 
  6. make install 
  7. cd ../ 
  1. tar zxvf PDO_MYSQL-1.0.2.tgz 
  2. cd PDO_MYSQL-1.0.2/ 
  3. /usr/local/webserver/php/bin/phpize 
  4. ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql 
  5. make 
  6. make install 
  7. cd ../ 
  1. tar zxvf ImageMagick.tar.gz 
  2. cd ImageMagick-6.5.1-2/ 
  3. ./configure 
  4. make 
  5. make install 
  6. cd ../ 
  1. tar zxvf imagick-2.3.0.tgz 
  2. cd imagick-2.3.0/ 
  3. /usr/local/webserver/php/bin/phpize 
  4. ./configure --with-php-config=/usr/local/webserver/php/bin/php-config 
  5. make 
  6. make install 
  7. cd ../ 

 5、修改php.ini

手工修改:查找/usr/local/webserver/php/etc/php.ini中的找到

找到:;date.timezone =

修改为:date.timezone = PRC #设置时区

找到:expose_php = On

修改为:expose_php = OFF #禁止显示php版本的信息

找到:display_errors = On

修改为:display_errors = OFF #关闭错误提示

 

查找extension_dir = "./"

修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/"

  并在此行后增加以下几行,然后保存:

  extension = "memcache.so"

  extension = "pdo_mysql.so"

  extension = "imagick.so"

查找

short_open_tag = Off

修改

short_open_tag = On

 

6、配置eAccelerator加速PHP:

  1. mkdir -p /usr/local/webserver/eaccelerator_cache 
  2. chmod 777  /usr/local/webserver/eaccelerator_cache 
  3. vi /usr/local/webserver/php/etc/php.ini 

 按shift g键跳到配置文件的最末尾,加上以下配置信息:

[eaccelerator]

zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"

eaccelerator.shm_size="64"

eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

本文由美洲杯在哪买球发布于计算机教程,转载请注明出处:CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安

TAG标签:
Ctrl+D 将本页面保存为书签,全面了解最新资讯,方便快捷。