1、centos 50 编译安装apache 226+php525+mysql5046+Zend笔记centos 5.0 编译安装apache 2.2.6+php5.2.5+mysql5.0.46+Zend笔记V2.0 2007年10月8日 操作系统更新为centos 5.0 apache 更新为2.2.6版本, php更新为5.2.5,增加集成Suhosin补丁,mysql 更新为5.0.46, Zend Optimizer 更新为3.3.0。解决新平台下的一些问题。修正文字错误。v1.2 2007年2月12日 apache 更新为2.2.4版本,增加mod_ssl和openssl支持,增加ap
2、r和apr-util的编译, php更新为5.2.1,增加集成Suhosin补丁,mysql 更新为5.0.33, Zend Optimizer 更新为3.2.2,增加phpmyadmin。修改一些文字错误。v1.0 2007年1月11日先声明,我绝对是个Linux的菜鸟,以下的这些文字个人的安装笔记,是参考了网上许多高手的成功经验组合而成的,说实话我自己的东西不多 :)我想把这些经验写下来,既能够对其他跟我相同摸索的兄弟一个经验,也能够防止以后自己都忘记了,嘿嘿。所以假如某个大虾看到我借用了您的资源,请您不要生气。也欢迎大家进行指点。1、下载centos 5我是下载的DVD版本,大家也能够下
3、载服务器CD安装版本,其实都差不多。大家能够到这儿下载,速度很快的。当然也能够在windows下用BT或迅雷下载,速度也很不错的。下载后当然就刻录成光盘。我建议您刻录DVD啦,假如是菜鸟,也能够在图像界面进行学习,不会这么抓不住头脑。2、(1)安装CentOS 5作为服务器,不安装无需的组件,所以在选择组件的时候,除了选择FTP SERVER外取消任何组件的选择。也不要选web服务器。因为我们后面要手动编译安装。系统约定RPM包和源码包存放位置RPM包和源码包存放位置 /usr/local/src源码包编译安装位置(prefix) /usr/local/xxx脚本连同维护程式存放位置 /usr
4、/local/sbinMySQL 数据库位置 /var/lib/mysqlApache 网站根目录 /home/wwwApache 虚拟主机日志根目录 /data/logs/wwwyum RPM包信息文档 /etc/yum.list3、系统环境部署及调整(1). 检查系统是否正常# more /var/log/messages /检查有无系统内核级错误信息# demesg /检查硬件设备是否有错误信息# ifconfig /检查网卡配置是否正确# ping / 检查网络是否正常(2). 关闭无需的服务# export LANG=en_US /配置语言# setup /选择启动的服务进入syst
5、em service 选项。以space 键选定所需服务。以下仅列出需要启动的服务,未列出的服务一律关闭:crondirqbalance 仅当服务器CPU为S.M.P架构或支持双核心、HT技术时,才需开启,否则关闭。microcode_ctlnetworkvsftpdsshdsyslog(3)、修改/etc/yum.repos.d/CentOS-Base.repo,将镜象站点地址改为在中国的镜象站点地址。不然我们通过yum安装软件速度会极慢。修改如下:# CentOS-Base.repo# This file uses a new mirrorlist system developed by
6、Lance Davis for CentOS.# The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client. You should use this for CentOS updates# unless you are manually picking other mirrors.# If the mi
7、rrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead.#basename=CentOS-$releasever - Basebaseurl=gpgcheck=1gpgkey=http:/mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5protect=1#released updates updatesname=CentOS-$releasever - Updatesbaseurl=gpgcheck=1gpg
8、key=http:/mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5protect=1#packages used/produced in the build but not releasedaddonsname=CentOS-$releasever - Addonsbaseurl=gpgcheck=1gpgkey=http:/mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5protect=0#additional packages that may be usefulextrasname=CentOS-$re
9、leasever - Extrasbaseurl=gpgcheck=1gpgkey=http:/mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5protect=0#additional packages that extend functionality of existing packagescentosplusname=CentOS-$releasever - Plusbaseurl=gpgcheck=1enabled=0gpgkey=http:/mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5protec
10、t=1#contrib - packages by Centos Userscontribname=CentOS-$releasever - Contribbaseurl=gpgcheck=1enabled=0protect=0gpgkey=http:/mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5#packages in testingtestingname=CentOS-5 - Testingbaseurl=gpgcheck=1enabled=0protect=0保存。(2)更新系统,我们使用yum,然后执行:# yum upgrade建议更新任
11、何列出的程式,rhel 5.X的稳定性还要继续努力呢。(4)、定时校正服务器时间# yum install ntp# crontab -e0 23 * * * root /usr/sbin/ntpdate 210.72.145.44 /dev/null 2&1以上命令配置好后存盘。您的机器将在每天的23:00根据中国国家授时中央的NTP服务器时间自动校准时间。(5). 对TCP/IP网络参数进行调整,加强抗SYN Flood能力# echo net.ipv4.tcp_syncookies = 1 /etc/sysctl.conf /将net.ipv4.tcp_syncookies = 1写入s
12、ysctl.conf 文档# sysctl -p /查看(6)、FTP服务器的配置vi /etc/vsftpd/vsftpd.conf把anonymous_enable=YES注释掉不允许匿名登录。把chroot_list_enable=YESchroot_list_file=/etc/vsftpd.chroot_list前的注释去掉。把ftpd_banner=*前的注释去掉。后面改成您的欢迎信息(这样配置能够避免显示ftp服务器的版本信息)然后保存,service vsftpd start就能够了。这时应当添加用户,因为root默认不能通过FTP方式登录。# adduser username
13、# passwd userpassword这样对于我们上传一些文档到系统中很方便。4. 重新启动系统# init 65. 使用 yum 程式安装所需研发包(以下为标准的 RPM 包名称)# yum install gcc gcc-c+ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel#这里我们将编译GD所必须的一
14、些小软件比如libpng,libtiff,freetype,libjpeg,等先用RPM的方式一并安装好,避免手动编译浪费时间,同时也能避免很多错误,这几个小软件的编译很麻烦。这几个小软件编译错误了,GD当然安装不了,php5的编译当然也没戏了。所以我们抓大放小,对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。另外libxml2系统已默认安装了,所以我们无需手工编译了,直接安装他的研发包就行了。6. 源码编译安装所需包 (Source)(1) GD2# cd /usr/local/src# wget # tar xzvf gd-2.0.34.tar.gz# c
15、d gd-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 -ma
16、ndir=/usr/share/man /./configure 配置。# make /make 是用来编译的,他从 Makefile 中读取指令,然后编译。# make install /make install 是用来安装的,他也从 Makefile 中读取指令,安装到指定的位置。(2) Apache 日志截断程式# cd /usr/local/src# wget http:/cronolog.org/download/cronolog-1.6.2.tar.gz# tar xzvf cronolog-1.6.2.tar.gz# cd cronolog-1.6.2# ./configure
17、-prefix=/usr/local/cronolog# make# make install7、编译mysql 5.0.46mysql 5.0.46是企业版本,貌似双数版本都是企业版本了。个人觉得代码质量要比社区版本要好一些。大家能够下载,免费使用。并无需向mysql公司交钱。cd /usr/local/src# wget # tar xzvf mysql-5.0.46.tar.gz# cd mysql-5.0.46修改mysql 客户端最大连接数, 默认的只有100,远远达不到我们的需要。# vi sql/mysqld.cc搜索找到下面一行:max_connections, OPT_MAX
18、_CONNECTIONS,The number of simultaneous clients allowed., (gptr*) &max_connections,(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,0,将其中的100改为1500, 当然小点也能够,根据您的需要来,不建议改的太大。max_connections, OPT_MAX_CONNECTIONS,The number of simultaneous clients allowed., (gptr*) &max_connect
19、ions,(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=
20、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-pt
21、hread -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配置成功会提示:MySQL has a Web site at which carries details on thelatest release, upcoming features, and other information to
22、make yourwork or play with MySQL more productive. There you can also findinformation about mailing lists for MySQL discussion.Remember to check the platform specific part of the reference manual forhints about installing MySQL on your platform. Also have a look at thefiles in the Docs directory.Than
23、k you for choosing MySQL!/ 注意 ,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 这个环境参数只针对intel P4 芯片
24、,假如您的CPU是AMD的,注意不能使用。请查看相应的编译优化参数。否则程式会无法编译,即使编译成功也无法运行,嘿嘿。关于其他CPU的优化请看我的BLOG的一篇转贴:print.org/bbs/blogs/1/blog43.html# make编译的时间可能会比较长,毕竟优化的比较厉害。# make install编译安装完成后执行后续操作:# useradd mysql /添加 mysql 用户# cd /usr/local/mysql# bin/mysql_install_db -user=mysql# chown -R root:mysql . /配置权限,注意后面有一个 .# chow
25、n -R mysql /var/lib/mysql /配置 mysql 目录权限# chgrp -R mysql . /注意后面有一个 .# cp share/mysql/my-f /etc/f# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld /开机自动启动 mysql。# chmod 755 /etc/rc.d/init.d/mysqld# chkconfig -add mysqld# /etc/rc.d/init.d/mysqld start /启动 MySQL# bin/mysqladmin -u root password pa
26、ssword_for_root# service mysqld stop /关闭 MySQL8. 编译安装 Apache# cd /usr/local/src# wget # tar zxvf httpd-2.2.6.tar.gz# cd httpd-2.2.6依次安装apr和apr-util# cd srclib/apr# CHOST=i686-pc-linux-gnu CFLAGS=-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer CXXFLAGS
27、=-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 & make install# cd ./apr-util# CHOST=i686-pc-linux-gnu CFLAGS=-O3 -msse2 -mmmx -Wall -W -mfpmat
28、h=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 & make install
29、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=/u
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2