基于CentOS构建高性能的LAMP平台
作者:NetSeek http://www.linuxtone.org(IT运维|集群架构|性能调优)
欢迎转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明.
大纲:
一、系统安装
二、编译安装基本环境
三、配置虚拟主机及基本性能调优
四、基本安全设置
五、附录及相关介绍
一、系统安装
1. 分区
/boot 100M左右
SWAP 物理内存的2倍(如果你的物理内存大于4G以上,分配4G即可)
/usr/local 15G (用于安装软件)
/data 剩余所有空间
2. 系统初始化脚本(根据具体需求关闭不需要的服务)
- #vi init.sh
- -------------------cut begin-------------------------------------------
- #welcome
- cat << EOF
- +--------------------------------------------------------------+
- | === Welcome to Centos System init === |
- +--------------http://www.linuxtone.org------------------------+
- +----------------------Author:NetSeek--------------------------+
- EOF
- #disable ipv6
- cat << EOF
- +--------------------------------------------------------------+
- | === Welcome to Disable IPV6 === |
- +--------------------------------------------------------------+
- EOF
- echo "alias net-pf-10 off" >> /etc/modprobe.conf
- echo "alias ipv6 off" >> /etc/modprobe.conf
- /sbin/chkconfig --level 35 ip6tables off
- echo "ipv6 is disabled!"
- #disable selinux
- sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
- echo "selinux is disabled,you must reboot!"
- #vim
- sed -i "8 s/^/alias vi='vim'/" /root/.bashrc
- echo 'syntax on' > /root/.vimrc
- #zh_cn
- sed -i -e 's/^LANG=.*/LANG="zh_CN.GB18030"/' /etc/sysconfig/i18n
- #tunoff services
- #--------------------------------------------------------------------------------
- cat << EOF
- +--------------------------------------------------------------+
- | === Welcome to Tunoff services === |
- +--------------------------------------------------------------+
- EOF
- #---------------------------------------------------------------------------------
- for i in `ls /etc/rc3.d/S*`
- do
- CURSRV=`echo $i|cut -c 15-`
- echo $CURSRV
- case $CURSRV in
- crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local | mysqld )
- echo "Base services, Skip!"
- ;;
- *)
- echo "change $CURSRV to off"
- chkconfig --level 235 $CURSRV off
- service $CURSRV stop
- ;;
- esac
- done
- -------------------cut end-------------------------------------------
- #sh init.sh (执行上面保存的脚本,仍后重启)
二、编译安装基本环境
1. 安装准备
1) 系统约定
软件源代码包存放位置 /usr/local/src
源码包编译安装位置(prefix) /usr/local/software_name
脚本以及维护程序存放位置 /usr/local/sbin
MySQL 数据库位置 /data/mysql/data(可按情况设置)
Apache 网站根目录 /data/www/wwwroot(可按情况设置)
Apache 虚拟主机日志根目录 /data/www/logs(可按情况设置)
Apache 运行账户 www:www
2) 系统环境部署及调整
检查系统是否正常
# tail -n100 /var/log/messages (检查有无系统级错误信息)
# dmesg (检查硬件设备是否有错误信息)
# ifconfig(检查网卡设置是否正确)
# ping www.linuxtone.org (检查网络是否正常)
3) 使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)
#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#yum install ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel /
ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel /
gettext-devel pam-devel kernel
4) 定时校正服务器时钟,定时与中国国家授时中心授时服务器同步
# crontab -e
加入一行:
15 3 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
2. 编译安装软件包
源码编译安装所需包(Source)
1) GD2
# cd /usr/local/src
# tar xzvf gd-2.0.35.tar.gz
# cd gd-2.0.35
# ./configure --prefix=/usr/local/gd2
# make
# make install
2) LibXML2
# cd /usr/local/src
# tar xjvf libxml2-2.6.29.tar.bz2
# cd libxml2-2.6.29
# ./configure --prefix=/usr/local/libxml2
# make
# make install
3) LibMcrypt
# cd /usr/local/src
# tar xjvf libmcrypt-2.5.8.tar.bz2
# cd libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make
# make install
4) Apache日志截断程序
# cd /usr/local/src
# tar xzvf cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure --prefix=/usr/local/cronolog
# make
# make install
3. 升级OpenSSL和OpenSSH
# cd /usr/local/src
# tar xzvf openssl-0.9.8g.tar.gz
# cd openssl-0.9.8g
# ./config --prefix=/usr/local/openssl
# make
# make test
# make install
# cd ..
# tar xzvf openssh-5.0p1.tar.gz
# cd openssh-5.0p1
# ./configure /
"--prefix=/usr" /
"--with-pam" /
"--with-zlib" /
"--sysconfdir=/etc/ssh" /
"--with-ssl-dir=/usr/local/openssl" /
"--with-md5-passwords"
# make
# make install
1) 禁用 SSH V1 协议
找到#Protocol 2,1改为:Protocol 2
2) 禁用服务器端GSSAPI
找到以下两行,并将它们注释:
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
3) 禁用 DNS 名称解析
找到:#UseDNS yeas改为:UseDNS no
4)禁用客户端 GSSAPI
# vi /etc/ssh/ssh_config 找到:GSSAPIAuthentication yes 将这行注释掉。
最后,确认修改正确后重新启动 SSH 服务
# service sshd restart
# ssh -v
确认 OpenSSH 以及 OpenSSL 版本正确。
以上SSH配置可利用以下脚本自动修改:
- -------------------cut begin-------------------------------------------
- #init_ssh
- ssh_cf="/etc/ssh/sshd_config"
- sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' $ssh_cf
- sed -i "s/#UseDNS yes/UseDNS no/" $ssh_cf
- #client
- sed -i -e '44 s/^/#/' -i -e '48 s/^/#/' $ssh_cf
- echo "ssh is init is ok.............."
- -------------------cut end-------------------------------------------
1.下载软件编译安装
1)下载软件
# cd /usr/local/src
httpd-2.2.8.tar.gz
mysql-5.0.51b.tar.gz
php-5.2.6.tar.bz2
ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
2) 安装MySQL
查看分析你的CPU型号:
http://gentoo-wiki.com/Safe_Cflags 查找您的GCC编译参数.
确定系统CPU类型:
# cat /proc/cpuinfo | grep "model name"
执行后会看到系统中CPU的具体型号,记下CPU型号。
# tar zxvf mysql-5.0.51b.tar.gz
# cd mysql-5.0.51b
# vi mysql.sh
- -------------------cut begin-------------------------------------------
- CHOST="i686-pc-linux-gnu"
- CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
- CXXFLAGS="${CFLAGS}"
- ./configure /
- "--prefix=/usr/local/mysql" /
- "--localstatedir=/data/mysql/data" /
- "--with-comment=Source" /
- "--with-server-suffix=-LinuxTone" /
- "--with-mysqld-user=mysql" /
- "--without-debug" /
- "--with-big-tables" /
- "--with-charset=gbk" /
- "--with-collation=gbk_chinese_ci" /
- "--with-extra-charsets=all" /
- "--with-pthread" /
- "--enable-static" /
- "--enable-thread-safe-client" /
- "--with-client-ldflags=-all-static" /
- "--with-mysqld-ldflags=-all-static" /
- "--enable-assembler" /
- "--without-isam" /
- "--without-innodb" /
- "--without-ndb-debug"
- make && make install
- mkdir -p /data/mysql/data
- useradd mysql -d /data/mysql -s /sbin/nologin
- /usr/local/mysql/bin/mysql_install_db --user=mysql
- cd /usr/local/mysql
- chown -R root:mysql .
- chown -R mysql /data/mysql/data
- cp share/mysql/my-huge.cnf /etc/my.cnf
- cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
- chmod 755 /etc/rc.d/init.d/mysqld
- chkconfig --add mysqld
- /etc/rc.d/init.d/mysqld start
- cd /usr/local/mysql/bin
- for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done
- -------------------cut end---------------------------------------------
3) 编译安装Apache
# cd /usr/local/src
# tar zxvf httpd-2.2.8.tar.gz
# cd httpd-2.2.8
- # ./configure /
- "--prefix=/usr/local/apache2" /
- "--with-included-apr" /
- "--enable-so" /
- "--enable-deflate=shared" /
- "--enable-expires=shared" /
- "--enable-rewrite=shared" /
- "--enable-static-support" /
- "--disable-userdir"
- # make
- # make install
- # echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local
# cd /usr/local/src
# tar xjvf php-5.2.6.tar.bz2
# cd php-5.2.6
- # ./configure /
- "--prefix=/usr/local/php" /
- "--with-apxs2=/usr/local/apache2/bin/apxs" /
- "--with-config-file-path=/usr/local/php/etc" /
- "--with-mysql=/usr/local/mysql" /
- "--with-libxml-dir=/usr/local/libxml2" /
- "--with-gd=/usr/local/gd2" /
- "--with-jpeg-dir" /
- "--with-png-dir" /
- "--with-bz2" /
- "--with-freetype-dir" /
- "--with-iconv-dir" /
- "--with-zlib-dir " /
- "--with-openssl=/usr/local/openssl" /
- "--with-mcrypt=/usr/local/libmcrypt" /
- "--enable-soap" /
- "--enable-gd-native-ttf" /
- "--enable-memory-limit" /
- "--enable-ftp" /
- "--enable-mbstring" /
- "--enable-exif" /
- "--disable-ipv6" /
- "--disable-cgi" /
- "--disable-cli" #禁掉ipv6,禁掉cli模式,提升速度和安全性.
- # make
- # make install
- # mkdir /usr/local/php/etc
- # cp php.ini-dist /usr/local/php/etc/php.ini
#tar zxvf xcache-1.2.2.tar.gz
- #/usr/local/php-fcgi/bin/phpize
- ./configure --enable-xcache --enable-xcache-coverager --with-php-config=/usr/local/php/bin/php-config /
- --enable-inline-optimization --disable-debug
- -------------------cut begin-------------------------------------------
- [xcache-common]
- zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so
- [xcache.admin]
- xcache.admin.user = "admin"
- ;如何生成md5密码: echo -n "password"| md5sum
- xcache.admin.pass = "035d849226a8a10be1a5e0fec1f0f3ce" #密码为52netseek
- [xcache]
- ; Change xcache.size to tune the size of the opcode cache
- xcache.size = 24M
- xcache.shm_scheme = "mmap"
- xcache.count = 4
- xcache.slots = 8K
- xcache.ttl = 0
- xcache.gc_interval = 0
- ; Change xcache.var_size to adjust the size of variable cache
- xcache.var_size = 8M
- xcache.var_count = 1
- xcache.var_slots = 8K
- xcache.var_ttl = 0
- xcache.var_maxttl = 0
- xcache.var_gc_interval = 300
- xcache.test = Off
- xcache.readonly_protection = On
- xcache.mmap_path = "/tmp/xcache"
- xcache.coredump_directory = ""
- xcache.cacher = On
- xcache.stat = On
- xcache.optimizer = Off
- [xcache.coverager]
- xcache.coverager = On
- xcache.coveragedump_directory = ""
- -------------------cut end---------------------------------------------
# cd /usr/local/src
# tar xzvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# ./ZendOptimizer-3.3.3-linux-glibc23-i386/install.sh
安装Zend Optimizer过程的最后不要选择重启Apache。
2. 整合Apache与PHP及系统初化配置.
1)整合Apache与PHP
# vi /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加
AddType application/x-httpd-php .php
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将该行改为
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf (虚拟主机配置文件存放目录.)
#Include conf/extra/httpd-default.conf
去掉前面的“#”号,取消注释。
注意:以上 4 个扩展配置文件中的设置请按照相关原则进行合理配置!
修改完成后保存退出。
# /usr/local/apache2/bin/apachectl restart
2)查看确认L.A.M.P环境信息、提升 PHP 安全性
在网站根目录放置 info.php 脚本,检查phpinfo中的各项信息是否正确。
<?php
phpinfo();
?>
确认 PHP 能够正常工作后,在 php.ini 中进行设置提升 PHP 安全性,禁掉危险的函数.
# vi /etc/php.ini找到:disable_functions =设置为:phpinfo,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
3)脚本自动完成初始化配置(以上配置可以用脚本自动化完成)
#cat init_apache_php.sh
- -------------------cut begin-------------------------------------------
- #!/bin/bash
- #Written by :NetSeek http://www.linuxtone.org
- #init_httpd.conf
- http_cf="/usr/local/apache2/conf/httpd.conf"
- sed -i -e "s/User daemon/User www/" -i -e "s/Group daemon/Group www/" $http_cf
- sed -i -e '121 s/^/#/' -i -e '122 s/^/#/' $http_cf
- sed -i 's#DirectoryIndex index.html index.htm# DirectoryIndex index.phpindex.html index.htm#/g' $http_cf
- sed -i -e '374 s/^#//g' -i -e '389 s/^#//g' -i -e '392 s/^#//g' -i -e '401 s/^#//g' $http_cf
- #init_php(PHP安全设置及隐藏PHP版本)
- php_cf="/usr/local/php/etc/php.ini"
- sed -i '205 s#;open_basedir =#open_basedir = /data/www/wwwroot:/tmp#g' $php_cf
- sed -i '210 s#disable_functions =#disable_functions = phpinfo,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server#g' $php_cf
- sed -i '/expose_php/s/On/Off/' $php_cf
- sed -i '/display_errors/s/On/Off/' $php_cf
- -------------------cut end-------------------------------------------
1) 配置虚拟主机:
#vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
- NameVirtualHost *:80
- <VirtualHost *:80>
- ServerAdmin cnseek@gmail.com
- DocumentRoot "/data/www/wwwroot/linuxtone.org"
- ServerName www.linuxtone.org
- ServerAlias bbs.linxutone.org
- ErrorLog "logs/dummy-host.example.com-error_log"
- CustomLog "|/usr/sbin/cronolog /data/logs/access_www.linuxtone.org.%Y%m%d" combined
- </VirtualHost>
#vi /usr/local/apache2/conf/extra/httpd-default.conf
- Timeout 15
- KeepAlive Off
- MaxKeepAliveRequests 50
- KeepAliveTimeout 5
- UseCanonicalName Off
- AccessFileName .htaccess
- ServerTokens Prod
- ServerSignature Off
- HostnameLookups Off
- <IfModule mpm_prefork_module>
- ServerLimit 2000
- StartServers 10
- MinSpareServers 10
- MaxSpareServers 15
- MaxClients 2000
- MaxRequestsPerChild 10000
- </IfModule>
利用awstats分析网站日志:http://bbs.linuxtone.org/thread-56-1-1.html
忽略不需要的日志配置参考具体请据据具体问题分析:
LogFormat "%{X-Forwarded-For}i %l %u %t /"%r/" %>s %b /"%{Referer}i/" /"%{User-Agent}i/"" combined
#下面加入如下内容:
- # filter the localhost visit
- SetEnvIf Remote_Addr "127/.0/.0/.1" dontlog
- # filter some special directories
- SetEnvIf Request_URI "^ZendPlatform.*$" dontlog
- SetEnvIf Request_URI /.healthcheck/.html$ dontlog
- SetEnvIf Remote_Addr "::1" dontlog
- SetEnvIf Request_URI "/.getPing.php$" dontlog
- SetEnvIf Request_URI "^/error/.html$" dontlog
- SetEnvIf Request_URI "/.gif$" dontlog
- SetEnvIf Request_URI "/.jpg$" dontlog
- SetEnvIf Request_URI "/.css$" dontlog
- RewriteEngine on
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http://(www/.)?mydomain.com/.*$ [NC]
- RewriteRule /.(gif|jpg)$ http://网站域名/nolink.png [R,L]
1)iptables 封锁相关端口(推荐读CU白金大哥的两小时玩转iptables)
2)SSH全安(修改SSH端口限制来源IP登陆,或者参考http://bbs.linuxtone.org/thread-106-1-1.html)
3)Linux防Arp攻击策略(http://bbs.linuxtone.org/thread-41-1-1.html)
4)注意(还是那句老话:安全工作从细节做起!)
五、附录及相关介绍
1)参考文档(感谢):
Discuz!公司Nanu先生文章的相关链接:
http://bbs.linuxpk.com/thread-13325-1-2.html
http://www.discuz.net/thread-722804-1-1.html
配置全能WEB(05年文章参考):http://bbs.linuxpk.com/thread-437-1-2.html
LinuxTone.Org(Apache相关问题专题贴):http://bbs.linuxtone.org/thread-88-1-1.html
1)利用Nginx替代apache实现高性能的Web环境(第一版): http://bbs.linuxtone.org/thread-7-1-1.html
第二版详细安全配置近期更新,请实时关注:http://bbs.linuxtone.org/(网站服务器版)
2)关于LinuxTone.Org(IT运维专家论坛):
目标:期望和大家一起努力打造一个专注IT运维,Linux集群架构的开放互动讨论平台!期待您的加入!
我们很乐意把平时工作中遇到的问题和得到的经验与大家共同 分享相互学习!
如果你是Linux爱好者?
如果你目前在网站服务器方面遇到很多头痛的问题?
如果你目前的站就使用了Linux?或者你想将你的Linux的apache迁于至高性能的 Nginx?
如果您使用的是WAMP(即Windows平台的AMP)平台想选移LAMP?
如果你目前的网站需要优化进一步提升硬件性能?
如果你目前的网站需要 负载均衡集群架构方案? 请联系我们!
我们愿意抽出空余时间免费热心为你解答相关问题,协助你完成所有相关工作!共同分享!共同进步!
同时也热情期待你能加入http://www.linuxtone.org 帮我一起完善论坛建设工作,完成每版置顶的手册形成可操作性
强的文档及方案,方便大家一起学习进步!联系方式:QQ:67888954 MSN:cnseek@msn.com Gtalk:cnseek@gmail.com
===============================================
centos 5.2中安装LAMP
wget至以下目录:/tmp
----------------------
网站如下:
http://www.apache.org
http://www.php.net
http://www.mysql.com
http://www.shanghuo.net/?action=show&id=241
http://blog.chinaunix.net/u/249/showart_1842843.html
版本:
httpd-2.2.11.tar.gz
php-5.2.9.tar.gz
mysql-5.1.31.tar.gz
ZendOptimizer-3.3.3
phpMyAdmin-3.1.3.tar.gz
apache:
wget http://apache.freelamp.com/httpd/httpd-2.2.11.tar.gz
php :wget http://cn2.php.net/get/php-5.2.9.tar.gz/from/cn.php.net/mirror
mysql:wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.31.tar.gz/from/http://mysql.easynet.be/
Zend Optimizer v3.3:
wget http://downloads.phpchina.com/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
phpmyadmin:
wget http://nchc.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.1.3-all-languages.tar.gz
proftpd:
wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++
1、mysql
#wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.31.tar.gz/from/http://mysql.easynet.be/
#tar -zxvf mysql-5.1.31.tar.gz
#cd mysql-5.1.31
#./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all --enable-assembler --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
#make;make install
#groupadd mysql
#useradd -g mysql mysql
#cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
#sed -i 's/skip-federated/#skip-federated/g' /etc/my.cnf
#/usr/local/mysql/bin/mysql_install_db --user=mysql
#chmod +w /usr/local/mysql
#chown -R mysql /usr/local/mysql/var
#chgrp -R mysql /usr/local/mysql/.
#cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
#chmod 755 /etc/init.d/mysql
#chkconfig --level 345 mysql on
#service mysql start
# /usr/local/mysql/bin/mysqladmin -u root -p password
设置root密码,但出错:mysql“Access denied for user 'root'@'localhost'”
解决:
#/etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &;
#mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>
加入环境变量:
export PATH=$PATH:/usr/local/mysql/bin //临时修改的
若要永久生效
#echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile //永久修改的
#source /etc/profile
2、apache
#tar -zxf httpd-2.2.11.tar.gz
#cd httpd-2.2.11
#./configure --prefix=/usr/local/apache2 --enable-modules=so --enable-rewrite
#make; make install
安装完后
# vi /usr/local/apache/conf/httpd.conf
找到 prefork.c 下的
MaxClients 150
改为
ServerLimit 2000
MaxClients 1000
apache默认工作在prefork.c模式下,并发进程为150,超过后就无法访问,150是远远不够的,所以这里按自己网站的需求改, 如1000
由于apache默认最大并发进程是 256 所以要先设置 ServerLimit 2000 将服务器可设的最大并发数设为2000, 然后再设置最大并发数 MaxClients 1000
找到 #ServerName www.example.com:80 在其下设置 ServerName 如下
ServerName www.mysite.com
基中 www.mysite.com 为你网站名,也可用IP代替
找到 DocumentRoot "/usr/local/apache/htdocs"
设置你的 WEB 服务器的根目录 如
DocumentRoot "/myweb"
找到 DirectoryIndex index.html index.html.var 改为
DirectoryIndex index.html index.php index.htm
找到 ForceLanguagePriority Prefer Fallback 在其下加上
AddDefaultCharset gb2312
改完后保存(vi 的用法请查 Linux vi 命令)
用下面命令启动WEB服务器
# /usr/local/apache/bin/apachectl start
查看自己的站点是否正常 http://www.mysite.com 也可用IP
用 # /usr/local/apache/bin/apachectl stop 可停止服务
此时在浏览器中试试,可能无法访问,这是因为防火墙默认设置全部禁止访问的原因,运行lokkit设置就OK了~
如何更改了目录:则:加上这一句
Order allow ,deny
Allow from all
3、PHP
安装GD库(让PHP支持GIF,PNG,JPEG)
首先下载 jpeg6,libpng,freetype 并安装模块
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/freetype/freetype-2.3.9.tar.gz
wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
安装 jpeg6
建立目录
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# cd /tmp
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make; make install
安装libpng
# cd /tmp
# tar -zxf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scrīpts/makefile.std makefile
# make; make install
安装 freetype
# cd /root/soft
# tar -zxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
# make;make install
安装最新的GD库
# cd /tmp
# tar -zxf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
# make; make install
由于php5需libxml2的支持, 所以先下载并安装libxml2
# cd /tmp
# wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.30.tar.gz
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# ./configure --prefix=/usr/local/libxml2
# make; make install
安装 libxslt
# cd /tmp
# wget http://ftp.gnome.org/pub/gnome/sources/libxslt/1.1/libxslt-1.1.22.tar.gz
# tar -zxf libxslt-1.1.22.tar.gz
# cd libxslt-1.1.22
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make; make install
终于要安装PHP了:
# tar -zxf php-5.2.3.tar.gz
# cd php-5.2.3
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-ftp --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/lib --with-png --with-freetype-dir=/usr/local/freetype --enable-mbstring
# make
# make install
其中./configure 后的
--prefix=/usr/local/php5
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
是必要的选项
--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
这是让PHP支持GD库的配置选项
配置 httpd.conf 让apache支持PHP
# vi /usr/local/apache/conf/httpd.conf
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps在你Web目录里建一内容为 PHP文件, 输入URL地址查看PHP配置是否正确
安装 phpmyadmin
下载
# tar zxvf phpMyAdmin-2.11.2-all-languages.tar.gz
# mv phpMyAdmin-2.11.2-all-languages /usr/local/httpd/htdocs/phpmyadmin
# cd /usr/local/httpd/htdocs/phpmyadmin
# cp ./libraries/config.default.php ./config.inc.php
#vi config.inc.php
$cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin';
$cfg['Servers'][$i]['auth_type'] = 'http';
安装zend:
# tar zxvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz
# cd ZendOptimizer-3.2.2-linux-glibc21
# ./install.sh
OK,成功~!
转载:http://lifestylezhu.blogspot.com/2009/03/mysql.html