說明:
RPM包和源碼包存放位置 /usr/local/src
源碼包編譯安裝位置(prefix) /usr/local/xxx
腳本以及維護程序存放位置 /usr/local/sbin
MySQL 數據庫位置 /var/lib/mysql
Apache 網站根目錄 /usr/loca/apache2/htdocsl
Apache 虛擬主機日志根目錄 /data/logs/www
yum RPM包信息文件 /etc/yum.list
●mysql 5.0.46安裝配置
mysql 5.0.46是企業版本,貌似雙數版本都是企業版本了。個人覺得代碼質量要比社區版本要好一些。大家可以下載,免費使用。并不需要向mysql公司交錢。
cd /usr/local/src
# wget http://mirror.provenscaling.com/mysql/enterprise/source/5.0/mysql-5.0.46.tar.gz
# tar xzvf mysql-5.0.46.tar.gz
# cd mysql-5.0.46
修改mysql 客戶端最大連接數, 默認的只有100,遠遠達不到我們的要求。
# vi sql/mysqld.cc
搜索找到下面一行:
{"max_connections", OPT_MAX_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_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,
0},
保存。
# ./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
配置成功會提示:
MySQL has a Web site at http://www.mysql.com/ which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.
Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.
Thank you for choosing MySQL!
# make
編譯的時間可能會比較長,畢竟優化的比較厲害。
# mamake ske install
編譯安裝完成后執行后續操作:
# useradd mysql //添加 mysql 用戶
# cd /usr/local/mysql
# bin/mysql_install_db --user=mysql
# chown -R root:mysql . //設置權限,注意后面有一個 "."
# chown -R mysql /var/lib/mysql //設置 mysql 目錄權限
# chgrp -R mysql . //注意后面有一個 "."
# cp share/mysql/my-medium.cnf /etc/my.cnf
# 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 "password_for_root"
# service mysqld stop //關閉 MySQL
● 編譯安裝 Apache
# cd /usr/local/src
# wget http://www.ip97.com/apache.org/httpd/httpd-2.2.6.tar.gz
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
依次安裝apr和apr-util
# cd srclib/apr
# ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make && make install
# cd ../apr-util
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
# make && make install
#cd /usr/local/src/httpd-2.2.6
# ./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 --enable-mod_cgi --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
# make
# make install
注解:
./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 - Apache HTTP 服務器性能測試工具
--enable-static-checkgid //使用靜態連接編譯 checkgid
--disable-cgid //禁止用一個外部 CGI 守護進程執行CGI腳本
--disable-cgi //禁止編譯 CGI 版本的 PHP
我們不再使用worker模式編譯apache,worker模式和php貌似有一些不協調不穩定之處。所以使用了默認的perfork模式。