声明:此文章有部分内容参考网上的一些文章,文章中所有代码在Centos 6.2 X84 64位系统上经过测试。
一、下载软件包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
wget http://mozbuildtools.googlecode.com/files/libiconv-1.13.1.tar.gz
wget http://acelnmp.googlecode.com/files/mhash-0.9.9.9.tar.gz
wget http://mysql.ntu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.25a.tar.gz
wget http://sysoev.ru/nginx/nginx-0.8.46.tar.gz
wget http://www.php.net/get/php-5.2.14.tar.gz/from/this/mirror
wget http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz
wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0
wget http://pecl.php.net/get/memcache-2.2.5.tgz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
|
二、安装依赖软件包
1
|
yum -y install dialog ntp vim-enhanced vixie-cron gcc gcc-c++ gcc-g77 flex bison autoconf automake glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libtool* zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel net-snmp net-snmp-devel nss_ldap openldap-clients openldap-servers libtidy libtidy-devel wget libc-client libc-client-devel pcre pcre-devel
|
三、安装MySQL
1、安装cmake
1
2
3
|
tar zxvf cmake-2.8.4.tar.gz
cd $src_dir/cmake-2.8.4
./configure && make && make install
|
2、安装mysql 5.5
1
2
3
4
|
tar zxvf mysql-
5.5
.25a.tar.gz
cd mysql-
5.5
.25a
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=
1
-DWITH_ARCHIVE_STORAGE_ENGINE=
1
-DWITH_BLACKHOLE_STORAGE_ENGINE=
1
-DWITH_FEDERATED_STORAGE_ENGINE=
1
-DWITH_PARTITION_STORAGE_ENGINE=
1
-DMYSQL_TCP_PORT=
3306
-DENABLED_LOCAL_INFILE=
1
-DWITH_SSL=yes -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
gmake && make install
|
3、创建MySQL数据库存放目录
1
2
3
4
|
mkdir -p /usr/local/mysql/data
mkdir -p /usr/local/mysql /binlog/
mkdir -p /usr/local/mysql /relaylog/
chown -R mysql:mysql /usr/local/mysql
|
5、创建mysql配置文件和启动脚本
1
2
3
|
/bin/cp support-files/my-small.cnf /etc/my.cnf
/bin/cp support-files/mysql.server /etc/rc.d/init.d/mysqld
|
1
|
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql --defaults-file=/etc/my.cnf
|
四、安装PHP 5.3.16(php-fpm模式)
1、安装编译安装PHP 5.2.14所需的支持库:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
tar zxvf libiconv-
1.13
.
1
.tar.gz
cd libiconv-
1.13
.
1
/
./configure --prefix=/usr/local
make
make install
cd ../
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
tar zxvf mcrypt-
2.6
.
8
.tar.gz
cd mcrypt-
2.6
.
8
/
/sbin/ldconfig
./configure
make
make install
cd ../
|
2、编译安装PHP5
1
2
3
4
5
6
|
tar zxvf php-5.3.13.tar.gz
cd php-5.3.13
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/lib --with-mysql=/usr/local/mysql/bin/mysql_config --with-enable-sysvsem --enable-fpm --with-openssl --with-zlib --with-bz2 --with-curl --with-libxml-dir=/usr --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-iconv=/use/local/libiconv --with-ldap --with-mcrypt=/usr/local/libmcypt --with-zlib-dir --with-snmp --enable-zip --with-curlwrappers --with-imap --with-kerberos --with-imap-ssl --with-freetype-dir --with-mysql=/usr/local/mysql
make && make install
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
|
3、编译安装PHP5扩展模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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 ../
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 ../
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 ../
|
4、修改php.ini文件
手工修改:查找/usr/local /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"
再查找output_buffering = Off
修改为output_buffering = On
再查找; cgi.fix_pathinfo=0
修改为cgi.fix_pathinfo=0,防止Nginx文件类型错误解析漏洞。
5、配置eAccelerator加速PHP
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
引用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
accelerator.cache_dir="/usr/local/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"
|
五、安装Nginx 0.8.46
1、安装Nginx所需的pcre库: yum -y install pcre pcre-devel
2、安装Nginx
1
2
3
4
5
|
tar zxvf nginx-0.8.46.tar.gz
cd nginx-0.8.46/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
|
4、nginx配置文件模板
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
user nobody;
worker_processes 1;
pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 300;
proxy_connect_timeout 300;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
gzip on;
gzip_min_length 1000;
gzip_buffers 4 8k;
gzip_comp_level 3;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server
{
listen 80;
server_name status.chlinux.net;
location / {
stub_status on;
access_log off;
}
}
server {
listen 80;
server_name www.chlinux.net chlinux.net;
root html/;
index index.php index.html index.htm;
location / {
root html/;
index index.php index.html index.htm;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
location /nginx_status {
stub_status on;
access_log off;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi.conf;
}
}
|
本文转自1594cqb 51CTO博客,原文链接:http://blog.51cto.com/wolfchen/1204773,如需转载请自行联系原作者