一、获取相关开源程序
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
二、安装PHP 5.2.10(FastCGI模式)
1、编译安装PHP 5.2.10所需的支持库:
tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./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
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
2、编译安装初始化MySQL 5.1.47
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.1.47.tar.gz
cd mysql-5.1.47/
./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=innobase
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../
①初始化数据库
/usr/local/webserver/mysql/bin/mysql_install_db --user=mysql
数据库目录默认建立在/usr/local/webserver/mysql/var/下
②启动数据库并给root设置密码
/usr/local/webserver/mysql/share/mysql/mysql.server start
/usr/local/webserver/mysql/bin/mysqladmin password ******
③进入数据库
# /usr/local/web/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3664
Server version: 5.1.47 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
4 rows in set (0.01 sec)
3、编译安装PHP(FastCGI模式)
tar zxvf php-5.2.8.tar.gz
gzip -cd php-5.2.8-fpm-0.5.11.diff.gz | patch -d php-5.2.8 -p1
cd php-5.2.8/
./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 --without-pear
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
curl | /usr/local/webserver/php/bin/php
说明:go-pear为一个php的脚本文件
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.5.3.tar.bz2 #加速PHP用
cd eaccelerator-0.9.5.3/
/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 #生成连接mysql模块
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.2.2.tgz
cd imagick-2.2.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ../
5、修改php.ini文件
手工修改:查找/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"
再查找output_buffering = Off
修改为output_buffering = On
6、配置eAccelerator加速PHP:
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
[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"
8.创建www用户,并启动php-cgi
启动php-cgi进程,监听127.0.0.1的9000端口,进程数为200(如果服务器内存小于3GB,可以只开启64个进程),用户为
www:
(有权限问题,用root用户无法启动,提示用普通用户,用www用户./usr/local/webserver/php/logs/php-fpm.log没有写
权限,pid也会在这个目录中,要改变这个目录的所有者为www)
chown -R /usr/local/webserver/php/logs/
ulimit -SHn 65535
su - www
/usr/local/webserver/php/sbin/php-fpm start
# ps aux | grep php
www 6628 0.0 2.4 93368 3016 ? Ss 00:44 0:00 /usr/local/web/php/bin/php-cgi --fpm --
fpm-config /usr/local/web/php/etc/php-fpm.conf
www 6629 0.0 2.1 93368 2752 ? S 00:44 0:00 /usr/local/web/php/bin/php-cgi --fpm --
fpm-config /usr/local/web/php/etc/php-fpm.conf
www 6630 0.0 2.1 93368 2752 ? S 00:44 0:00 /usr/local/web/php/bin/php-cgi --fpm --
fpm-config /usr/local/web/php/etc/php-fpm.conf
www 6631 0.0 2.1 93368 2752 ? S 00:44 0:00 /usr/local/web/php/bin/php-cgi --fpm --
fpm-config /usr/local/web/php/etc/php-fpm.conf
www 6632 0.0 2.1 93368 2752 ? S 00:44 0:00 /usr/local/web/php/bin/php-cgi --fpm --
fpm-config /usr/local/web/php/etc/php-fpm.conf
www 6633 0.0 2.1 93368 2752 ? S 00:44 0:00 /usr/local/web/php/bin/php-cgi --fpm --
fpm-config /usr/local/web/php/etc/php-fpm.conf
root 6636 0.0 0.5 3908 696 pts/0 S+ 00:44 0:00 grep php
三、安装Nginx-0.7.62
1.安装支持正则的库
rpm -ivh pcre-devel-6.6-2.el5_1.7.i386.rpm
2.安装nginx
tar zxvf nginx-0.7.62.tar.gz
cd nginx-0.7.62
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --
with-http_ssl_module
make && make install
cd ../
3.配置nginx
vim /usr/local/webserver/nginx/conf/nginx.conf
user www www;
worker_processes 1;
#error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
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;
tcp_nodelay on;
keepalive_timeout 65;
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;
#gzip on;
server {
listen 80;
server_name localhost;
charset utf-8;
root /usr/local/web/nginx/html/upload;
index index.php index.html;
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location / {
if ($request_uri ~ index.html) {
proxy_pass ;
}
}
location /status/ {
stub_status on;
access_log off;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 8000;
server_name kaakoo.cn;
location / {
root html;
index index.html index.htm;
}
}
}
4.配置fastcgi (由nginx.conf文件中指向fcgi.conf)
vim /usr/local/webserver/nginx/conf/fcgi.conf
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;
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;
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;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
四.搭建Discuz
unzip Discuz_X1.5_SC_UTF8.zip
mv upload /usr/local/webserver/nginx/html/
在浏览器中访问
进行安装配置即可。