CentOS 5.5 编译安装Apache+MySQL+PHP
在百度空间,写过一篇完整的,一步步照着运行就ok的博文,结果空间被百度kill了,无奈,只能先转一片,改日把里面的mysql5.1再换成5.5的版本,用cmake编译的
#检查并卸载
rpm-qa|grephttpd
rpm-ehttpd
rpm-qa|grepmysql
rpm-emysql
rpm-qa|grepphp
rpm-ephp
yum-yremovehttpd
#查找最快的源
yum-yinstallyum-fastestmirror
yum-yupdate
yum-yinstallpatchmakegccgcc-c++gcc-g77flexbisonfile
yum-yinstalllibtoollibtool-libsautoconfkernel-devel
yum-yinstalllibjpeglibjpeg-devellibpnglibpng-devellibpng10libpng10-develgdgd-devel
yum-yinstallfreetypefreetype-devellibxml2libxml2-develzlibzlib-devel
yum-yinstallglib2glib2-develbzip2bzip2-devellibeventlibevent-devel
yum-yinstallncursesncurses-develcurlcurl-devele2fsprogs
yum-yinstalle2fsprogs-develkrb5krb5-devellibidnlibidn-devel
yum-yinstallopensslopenssl-develvim-minimalnanosendmail
yum-yinstallfonts-chinesegettextgettext-devel
yum-yinstallncurses-devel
yum-yinstallgmp-develpspell-devel
yum-yinstallunzip
wget-chttp://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz
tarzxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8/
./configure
make&&makeinstall
/sbin/ldconfig
cdlibltdl/
./configure--enable-ltdl-install
make&&makeinstall
cdhttp://www.cnblogs.com/
wget-chttp://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz
tarzxvfmhash-0.9.9.9.tar.gz
cdmhash-0.9.9.9/
./configure
make&&makeinstall
cd../
wget-chttp://soft.vpser.net/web/libiconv/libiconv-1.13.tar.gz
tarzxvflibiconv-1.13.tar.gz
cdlibiconv-1.13/
./configure--prefix=/usr/local
make&&makeinstall
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
wget-chttp://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz
tarzxvfmcrypt-2.6.8.tar.gz
cdmcrypt-2.6.8/
./configure
make&&makeinstall
cd../
#安装mysql
wget-chttp://soft.vpser.net/datebase/mysql/mysql-5.1.44.tar.gz
wget-chttp://soft.vpser.net/web/pdo/PDO_MYSQL-1.0.2.tgz
tar-zxvfmysql-5.1.44.tar.gz
cdmysql-5.1.44/
./configure--prefix=/usr/local/mysql--with-extra-charsets=all--enable-thread-safe-client--enable-assembler--with-charset=utf8--enable-thread-safe-client--with-extra-charsets=all--with-big-tables--with-readline--with-ssl--with-embedded-server--enable-local-infile
make&&makeinstall
cd../
groupaddmysql
useradd-gmysqlmysql
cp/usr/local/mysql/share/mysql/my-medium.cnf/etc/my.cnf
/usr/local/mysql/bin/mysql_install_db--user=mysql
chown-Rmysql/usr/local/mysql/var
chgrp-Rmysql/usr/local/mysql/.
cp/usr/local/mysql/share/mysql/mysql.server/etc/init.d/mysql
chmod755/etc/init.d/mysql
chkconfig--level345mysqlon
echo"/usr/local/mysql/lib/mysql">>/etc/ld.so.conf
echo"/usr/local/lib">>/etc/ld.so.conf
ldconfig
ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
ln-s/usr/local/mysql/include/mysql/usr/include/mysql
/etc/init.d/mysqlstart
/usr/local/mysql/bin/mysqladmin-urootpassword$mysqlrootpwd
/etc/init.d/mysqlrestart
/etc/init.d/mysqlstop
chkconfigmysql-ndboff
chkconfigmysql-ndb-mgmoff
#安装apache
wgethttp://soft.vpser.net/web/apache/httpd-2.2.11.tar.gz
tarzxvfhttpd-2.2.11.tar.gz
cdhttpd-2.2.11
./configure--prefix=/usr/local/apache--enable-so--enable-cgi--enable-info--enable-rewrite--enable-speling--enable-usertrack--enable-deflate--enable-ssl
make
makeinstall
cd../
./configure//配置源代码树
--prefix=/usr/local/apache2//体系无关文件的顶级安装目录PREFIX,也就Apache的安装目录。
--enable-module=so//打开so模块,so模块是用来提DSO支持的apache核心模块
--enable-deflate=shared//支持网页压缩
--enable-expires=shared//支持HTTP控制
--enable-rewrite=shared//支持URL重写
--enable-cache//支持缓存
--enable-file-cache//支持文件缓存
--enable-mem-cache//支持记忆缓存
--enable-disk-cache//支持磁盘缓存
--enable-static-support//支持静态连接(默认为动态连接)
--enable-static-htpasswd//使用静态连接编译htpasswd-管理用于基本认证的用户文件
--enable-static-htdigest//使用静态连接编译htdigest-管理用于摘要认证的用户文件
--enable-static-rotatelogs//使用静态连接编译rotatelogs-滚动Apache日志的管道日志程序
--enable-static-logresolve//使用静态连接编译logresolve-解析Apache日志中的IP地址为主机名
--enable-static-htdbm//使用静态连接编译htdbm-操作DBM密码数据库
--enable-static-ab//使用静态连接编译ab-ApacheHTTP服务器性能测试工具
--enable-static-checkgid//使用静态连接编译checkgid
--disable-cgid//禁止用一个外部CGI守护进程执行CGI脚本
--disable-cgi//禁止编译CGI版本的PHP
--disable-userdir//禁止用户从自己的主目录中提供页面
--with-mpm=worker//让apache以worker方式运行
--enable-authn-dbm=shared//对动态数据库进行操作。Rewrite时需要。
具体编译参数参考:
http://lamp.linux.gov.cn/Apache/ApacheMenu/install.html
#安装php
wgethttp://soft.vpser.net/web/php/php-5.2.10.tar.gz
tarzxvfphp-5.2.10.tar.gz
cdphp-5.2.10/
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/local/apache/bin/apxs--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-iconv-dir=/usr/local/libiconv--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-force-cgi-redirect--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear
#如果下面两行不用,可尝试换此行#--lcrypt--liconv#make&&makeinstall
makeZEND_EXTRA_LIBS='-liconv'
makeinstall
mkdir-p/usr/local/php/etc
cpphp.ini-dist/usr/local/php/etc/php.ini
cd../
#phpextensions
sed-i's#output_buffering=Off#output_buffering=On#'/usr/local/php/etc/php.ini
sed-i's/post_max_size=8M/post_max_size=50M/g'/usr/local/php/etc/php.ini
sed-i's/upload_max_filesize=2M/upload_max_filesize=50M/g'/usr/local/php/etc/php.ini
sed-i's/;date.timezone=/date.timezone=PRC/g'/usr/local/php/etc/php.ini
#安装zend
wgethttp://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
tarzxvfZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mkdir-p/usr/local/zend/
cpZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so/usr/local/zend/
cat>>/usr/local/php/etc/php.ini<<EOF
[ZendOptimizer]
zend_optimizer.optimization_level=1
zend_extension="/usr/local/zend/ZendOptimizer.so"
EOF
#添加用户和建网站根目录
groupaddwww
useradd-gwwwwww
mkdir-p/home/wwwroot
chmod+w/home/wwwroot
chown-Rwww:www/home/wwwroot
#安装phpmyadmin
cd/home/wwwroot
wgethttp://soft.vpser.net/datebase/phpmyadmin/phpmyadmin.tar.gz
tarzxvfphpmyadmin.tar.gz
cd~
#安装PHP加速缓存插件eAccelerator
wgethttp://soft.vpser.net/web/eaccelerator/eaccelerator-0.9.5.3.tar.bz2
tarjxvfeaccelerator-0.9.5.3.tar.bz2
cdeaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-config
make
makeinstall
cd../
mkdir-p/usr/local/eaccelerator_cache
cat>>/usr/local/php/etc/php.ini<<EOF
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.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"
eaccelerator.keys="disk_only"
eaccelerator.sessions="disk_only"
eaccelerator.content="disk_only"
EOF
####################
#启动apache
/usr/local/apache/bin/apachectl-kstart
#重启apache
#/usr/local/apache/bin/apachectl-krestart
#启动ssl
#/usr/local/apache/bin/apachectl-kstartssl
#启动mysql
/etc/init.d/mysqlstart
#开机启动
vi/etc/rc.local
#然后
ulimit-SHn51200
/etc/init.d/mysqlstart
/usr/local/apache/bin/apachectl-kstart
#检查配置
#/usr/local/apache/bin/apachectlconfigtest
#检测Apache运行模块
#/usr/local/apache/bin/httpd-l
相关推荐
一种用于互联网下载包的打包及安装工具.它生成具有.RPM. Package Manager的缩写,类似。rpm –qa #查询已安装的 rpm 列表。rpm -q 软件包名 #查看是否已经安装。rpm