CentOS5.6下编译PHP5.3.6 + apache2.2.19 + mysql5.5.13

安装centos时,最好选择文本模式,而且只安装basic,SSH,ftp,其它什么都不要安装。


1. 升级系统,没啥好说的:

sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2.编译安装MySQL 5.5.13
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13/
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make && make install
chmod +w /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql
cd ../



附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,则执行以下几步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。

①、创建MySQL数据库存放目录
mkdir -p /data0/mysql/3306/data/
mkdir -p /data0/mysql/3306/binlog/
mkdir -p /data0/mysql/3306/relaylog/
chown -R mysql:mysql /data0/mysql/


②、以mysql用户帐号的身份建立数据表:
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/data0/mysql/3306/data --user=mysql


③、创建my.cnf配置文件:
vi /data0/mysql/3306/my.cnf

输入以下内容:

[client]
character-set-server = utf8
port    = 3306
socket  = /tmp/mysql.sock

[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user    = mysql
port    = 3306
socket  = /tmp/mysql.sock
basedir = /usr/local/webserver/mysql
datadir = /data0/mysql/3306/data
log-error = /data0/mysql/3306/mysql_error.log
pid-file = /data0/mysql/3306/mysql.pid
open_files_limit    = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /data0/mysql/3306/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /data0/mysql/3306/relaylog/relaylog
relay-log-info-file = /data0/mysql/3306/relaylog/relaylog
relay-log = /data0/mysql/3306/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover

interactive_timeout = 120
wait_timeout = 120

skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

#master-host     =   192.168.1.2
#master-user     =   username
#master-password =   password
#master-port     =  3306

server-id = 1

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0

#log-slow-queries = /data0/mysql/3306/slow.log
#long_query_time = 10

[mysqldump]
quick
max_allowed_packet = 32M


  ④、创建管理MySQL数据库的shell脚本:
vi /data0/mysql/3306/mysql

输入以下内容(这里的用户名admin和密码12345678接下来的步骤会创建):
#!/bin/sh

mysql_port=3306
mysql_username="admin"
mysql_password="12345678"

function_start_mysql()
{
    printf "Starting MySQL...\n"
    /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/data0/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &
}

function_stop_mysql()
{
    printf "Stoping MySQL...\n"
    /usr/local/webserver/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
}

function_restart_mysql()
{
    printf "Restarting MySQL...\n"
    function_stop_mysql
    sleep 5
    function_start_mysql
}

function_kill_mysql()
{
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}

if [ "$1" = "start" ]; then
    function_start_mysql
elif [ "$1" = "stop" ]; then
    function_stop_mysql
elif [ "$1" = "restart" ]; then
function_restart_mysql
elif [ "$1" = "kill" ]; then
function_kill_mysql
else
    printf "Usage: /data0/mysql/${mysql_port}/mysql {start|stop|restart|kill}\n"
fi

⑤、赋予shell脚本可执行权限:
chmod +x /data0/mysql/3306/mysql


⑥、启动MySQL:
/data0/mysql/3306/mysql start


⑦、通过命令行登录管理MySQL服务器(提示输入密码时直接回车):
/usr/local/webserver/mysql/bin/mysql -u root -p -S /tmp/mysql.sock


⑧、输入以下SQL语句,创建一个具有root权限的用户(admin)和密码(12345678):
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';


⑨、(可选)停止MySQL:
/data0/mysql/3306/mysql stop



3。编译安装apache2.2.19
./configure -–prefix=/usr/local/webserver/apache2 --enable-module=so --enable-rewrite  --enable-ssl --enable-deflate  --enable-cache  --enable-file-cache --enable-mem-cache  --enable-disk-cache --enable-mods-shared=all --enable-static-rotatelogs --enable-static-ab --enable-expires=shared  --enable-userdir
make && make install
小结:加上--enable-authn-dbm=shared 后,会出现要安装apr、apr-util的东东,不知道是什么;而且没有生成so文件
其实,直接--enable-modules=all,省事,用不到的功能再从httpd.conf中注释掉就OK了。下次就用这个。

4。编译PHP5.3.6
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-curl  --with-curlwrappers --with-mhash --with-mcrypt --with-openssl --with-gd --with-iconv-dir=/usr/local  --with-zlib  --with-ldap --with-ldap-sasl  --with-xmlrpc --with-jpeg-dir --with-png-dir --with-freetype-dir --with-libxml-dir --enable-bcmath --enable-pdo --enable-soap  --enable-xml --enable-mbstring --enable-mbregex  --enable-sockets --enable-zip  --enable-shmop --enable-sysvsem   --enable-pcntl  --enable-gd-native-ttf  --enable-inline-optimization  –-enable-sqlite-utf8  --enable-fpm --without-pear --disable-rpath --disable-safe-mode --disable-phar

make ZEND_EXTRA_LIBS=’-liconv’
make install

上面画底线的是我下载了它的库,但没有安装,加上此句会报错的;删除线的是PHP5.3.6根本没有这个选项,但网上居以然有出现,害人呀;删除线+下划线是与apxs2不能同时出现。

附上官方相关信息:http://gcov.php.net/viewer.php?version=PHP_5_3&func=system

5。给apache加上信息。
vi /usr/local/webserver/apache/conf/httpd.conf
这时,你会发现LoadModule php5_module        modules/libphp5.so自动加上这句了。
然后 找个地方加上 AddType application/x-httpd-php .php,重启apache就OK了。



好累呀。
300*300
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00609 秒