centos50编译安装apache226+php525+mysql5046+Zend笔记.docx
《centos50编译安装apache226+php525+mysql5046+Zend笔记.docx》由会员分享,可在线阅读,更多相关《centos50编译安装apache226+php525+mysql5046+Zend笔记.docx(15页珍藏版)》请在冰豆网上搜索。
centos50编译安装apache226+php525+mysql5046+Zend笔记
centos5.4编译安装apache2.2.6+php5.2.5+mysql5.0.46+ea笔记
RPM包和源码包存放位置/usr/local/src
源码包编译安装位置(prefix)/usr/local/xxx
脚本以及维护程序存放位置/usr/local/sbin
MySQL数据库位置/var/lib/mysql
Apache网站根目录/home/www
3、系统环境部署及调整
(1).检查系统是否正常
more/var/log/messages//检查有无系统内核级错误信息
demesg//检查硬件设备是否有错误信息
ifconfig//检查网卡设置是否正确
ping//检查网络是否正常
(2).关闭不需要的服务
exportLANG='en_US'//设置语言
setup//选择启动的服务
进入systemservice选项。
以space键选定所需服务。
以下仅列出需要启动的服务,未列出的服务一律关闭:
crond
irqbalance仅当服务器CPU为S.M.P架构或支持双核心、HT技术时,才需开启,否则关闭。
microcode_ctl
network
vsftpd
sshd
syslog
然后执行:
yumupgrade
建议更新所有列出的程序,rhel5.X的稳定性还要继续努力呢。
定时校正服务器时间
yuminstallntp
crontab-e
023***root/usr/sbin/ntpdate210.72.145.44>/dev/null2>&1
以上命令设置好后存盘。
您的机器将在每天的23:
00根据中国国家授时中心的NTP服务器时间自动校准时间。
(5).对TCP/IP网络参数进行调整,加强抗SYNFlood能力
echo'net.ipv4.tcp_syncookies=1'>>/etc/sysctl.conf//将net.ipv4.tcp_syncookies=1写入sysctl.conf文件
sysctl-p//查看
FTP服务器的配置
vi/etc/vsftpd/vsftpd.conf
把anonymous_enable=YES注释掉不允许匿名登录。
把chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
前的注释去掉。
把ftpd_banner=*前的注释去掉。
后面改成你的欢迎信息(这样设置可以避免显示ftp服务器的版本信息)
然后保存,servicevsftpdstart就可以了。
这时应当添加用户,因为root默认不能通过FTP方式登录。
adduserusername
passwduserpassword
这样对于我们上传一些文件到系统中很方便。
重新启动系统
init6
使用yum程序安装所需开发包(以下为标准的RPM包名称)
yum–yinstallgccgcc-c++gcc-g77flexbisonautoconfautomakebzip2-develzlib-develncurses-devellibjpeg-devellibpng-devellibtiff-develfreetype-develpam-developenssl-devellibxml2-devel
这里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg,等先用RPM的方式一并安装好,避免手动编译浪费时间,同时也能避免很多错误,这几个小软件的编译很麻烦。
这几个小软件编译错误了,GD当然安装不了,php5的编译当然也没戏了。
所以我们抓大放小,对这些小牛鬼蛇神采取快速简洁的方式进行安装。
并且对服务器的性能也不能产生什么影响。
另外libxml2系统已经默认安装了,所以我们不需要手工编译了,直接安装它的开发包就行了。
6.源码编译安装所需包(Source)
(1)GD2
#cd/usr/local/src
#wget
#tarxzvfgd-2.0.34.tar.gz
#cdgd-2.0.34
#CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"./configure--prefix=/usr/local/gd2--mandir=/usr/share/man//./configure配置。
#make//make是用来编译的,它从Makefile中读取指令,然后编译。
#makeinstall//makeinstall是用来安装的,它也从Makefile中读取指令,安装到指定的位置。
(2)Apache日志截断程序
#cd/usr/local/src
#wgethttp:
//cronolog.org/download/cronolog-1.6.2.tar.gz
#tarxzvfcronolog-1.6.2.tar.gz
#cdcronolog-1.6.2
#./configure--prefix=/usr/local/cronolog
#make
#makeinstall
7、编译mysql5.0.46
mysql5.0.46是企业版本,貌似双数版本都是企业版本了。
个人觉得代码质量要比社区版本要好一些。
大家可以下载,免费使用。
并不需要向mysql公司交钱。
cd/usr/local/src
#wget
#tarxzvfmysql-5.0.46.tar.gz
#cdmysql-5.0.46
修改mysql客户端最大连接数,默认的只有100,远远达不到我们的要求。
#visql/mysqld.cc
搜索找到下面一行:
{"max_connections",OPT_MAX_CONNECTIONS,
"Thenumberofsimultaneousclientsallowed.",(gptr*)&max_connections,
(gptr*)&max_connections,0,GET_ULONG,REQUIRED_ARG,100,1,16384,0,1,
0},
将其中的100改为1500,当然小点也可以,根据你的需要来,不建议改的太大。
{"max_connections",OPT_MAX_CONNECTIONS,
"Thenumberofsimultaneousclientsallowed.",(gptr*)&max_connections,
(gptr*)&max_connections,0,GET_ULONG,REQUIRED_ARG,1500,1,16384,0,1,
0},
保存。
#CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"./configure--prefix=/usr/local/mysql--localstatedir=/var/lib/mysql--with-comment=Source--with-server-suffix=-enterprise-gpl--with-mysqld-user=mysql--without-debug--with-big-tables--with-charset=utf8--with-collation=utf8_general_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-innodb--without-ndb-debug--without-isam
配置成功会提示:
MySQLhasaWebsiteatwhichcarriesdetailsonthe
latestrelease,upcomingfeatures,andotherinformationtomakeyour
workorplaywithMySQLmoreproductive.Thereyoucanalsofind
informationaboutmailinglistsforMySQLdiscussion.
Remembertochecktheplatformspecificpartofthereferencemanualfor
hintsaboutinstallingMySQLonyourplatform.Alsohavealookatthe
filesintheDocsdirectory.
ThankyouforchoosingMySQL!
//注意,CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"这个环境参数只针对intelP4芯片,如果你的CPU是AMD的,注意不能使用。
请查看相应的编译优化参数。
否则程序会无法编译,即使编译成功也无法运行,嘿嘿。
关于其他CPU的优化请看我的BLOG的一篇转贴:
print.org/bbs/blogs/1/blog43.html
#make
编译的时间可能会比较长,毕竟优化的比较厉害。
#makeinstall
编译安装完成后执行后续操作:
#useraddmysql//添加mysql用户
#cd/usr/local/mysql
#bin/mysql_install_db--user=mysql
#chown-Rroot:
mysql.//设置权限,注意后面有一个"."
#chown-Rmysql/var/lib/mysql//设置mysql目录权限
#chgrp-Rmysql.//注意后面有一个"."
#cpshare/mysql/my-f/etc/f
#cpshare/mysql/mysql.server/etc/rc.d/init.d/mysqld//开机自动启动mysql。
#chmod755/etc/rc.d/init.d/mysqld
#chkconfig--addmysqld
#/etc/rc.d/init.d/mysqldstart//启动MySQL
#bin/mysqladmin-urootpassword"password_for_root"
#servicemysqldstop//关闭MySQL
8.编译安装Apache
#cd/usr/local/src
#wget
#tarzxvfhttpd-2.2.6.tar.gz
#cdhttpd-2.2.6
依次安装apr和apr-util
#cdsrclib/apr
#CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"./configure--prefix=/usr/local/apr--enable-threads--enable-other-child--enable-static
#make&&makeinstall
#cd../apr-util
#CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr/--with-mysql=/usr/local/mysql
#make&&makeinstall
cd/usr/local/src/httpd-2.2.6
#CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"./configure--prefix=/usr/local/apache2--enable-mods-shared=all--with-mysql=/usr/local/mysql--enable-cache--enable-file-cache--enable-mem-cache--enable-disk-cache--enable-static-support--enable-static-htpasswd--enable-static-htdigest--enable-static-rotatelogs--enable-static-logresolve--enable-static-htdbm--enable-static-ab--enable-static-checkgid--disable-cgid--disable-cgi--with-apr=/usr/local/apr/--with-apr-util=/usr/local/apr-util/--enable-ssl--with-ssl=/usr/include/openssl
#make
#makeinstall
#echo'/usr/local/apache2/bin/apachectlstart'>>/etc/rc.local//将apachectl的调用加入到你的系统启动文件中。
注解:
./configure//配置源代码树
--prefix=/usr/local/apache2//体系无关文件的顶级安装目录PREFIX,也就Apache的安装目录。
--enable-module=so//打开so模块,so模块是用来提DSO支持的apache核心模块
--enable-mods-shared=all//编译全部的模板,对于不需要我们可以在httpd.conf去掉。
--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
--enable-ssl//编译ssl模块。
我们不再使用worker模式编译apache,worker模式和php貌似有一些不协调不稳定之处。
所以使用了默认的perfork模式。
将apache设置成开机自启动:
在/etc/rc.d/rc.local文件中加入一行
/usr/local/apache2/bin/apachectlstart
这样每次重新启动系统以后,apache也会随系统一起启动.
或者
#cp/usr/local/apache2/bin/apachectl/etc/rc.d/init.d/httpd
然后vi/etc/rc.d/init.d/httpd添加(#!
/bin/sh下面)
#chkconfig:
23451090
#description:
Activates/DeactivatesApacheWebServer
最后,运行chkconfig把Apache添加到系统的启动服务组里面:
#chkconfig--addhttpd
#chkconfighttpdon
9、编译php5.2.5-devel。
php5.2.4有点小BUG,无法在centos5上正常编译,官方已经在php5.2.5中修复了。
所以我们使用php5.2.5进行编译。
Suhosin是php增强型安全补丁,可以编译到静态内核中,也可以编译成php动态扩展。
我个人强烈你建议安装成静态内核。
Suhosin已经进入freebsd和gentoo的ports。
下面的以下先说静态安装步骤。
当然你也可以在安装php后将它编译成php的动态扩展。
#cd/usr/local/src
#wget
wgethttp:
//www.hardened-
#tarzxvfphp-5.2.5.tar.gz
#gunzipsuhosin-patch-5.2.1-0.9.6.2.patch.gz
#cdphp-5.2.5
#CHOST="i686-pc-linux-gnu"CFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"CXXFLAGS="-O3-msse2-mmmx-Wall-W-mfpmath=sse-funroll-loops-mcpu=pentium4-march=pentium4-pipe-fomit-frame-pointer"./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-pear=/usr/share/php--with-zlib-dir--with-bz2--with-libxml-dir=/usr--with-gd=/usr/local/gd2--enable-gd-native-ttf--enable-gd-jis-conv--with-freetype-dir--with-jpeg-dir--with-png-dir--with-ttf=shared,/usr--enable-mbstring--with-mysql=/usr/local/mysql