Apache+Mysql+Php整合安装
2007-01-15 by kenthy#qingdaonews.com
#########################################################################################
系统环境: Thizlinux Server 7.0 [ 2.4.22-3Thiz ]
LAMP版本:
httpd-2.2.0.tar.gz
mysql-4.0.26.tar.gz
php-4.4.4.tar.bz2
#########################################################################################
一、卸载旧版的apache、mysql、php
# cd /etc/init.d
# cp -pr httpd httpd.bak
# cp -pr mysqld mysqld.bak
# rpm -e --nodeps apache
# rpm -e --nodeps MySQL-client
# rpm -e --nodeps MySQL-server
# rpm -e --nodeps MySQL-devel
# rpm -e --nodeps MySQL-shared
# rpm -e --nodeps php-imap
# rpm -e --nodeps php-mysql
# rpm -e --nodeps php-pgsql
# rpm -e --nodeps php-ldap
# rpm -e --nodeps php
# rm -rf /etc/httpd/
# rm -rf /var/lib/mysql/
二、编译安装mysql
# groupadd mysql
# useradd -d /opt/mysql -g mysql -s /bin/false mysql
# chmod 755 /opt/mysql
# tar –zxvf mysql-4.0.26.tar.gz -C /usr/src/
# cd /usr/src/mysql-4.0.26
# ./configure –prefix=/opt/mysql
# make && make install
# /opt/mysql/bin/mysql_install_db
# echo '/opt/mysql/lib/mysql' >> /etc/ld.so.conf
# /sbin/ldconfig
# chown -R mysql:mysql /opt/mysql
# ln -s /opt/mysql/bin/mysql /usr/bin/
# ln -s /opt/mysql/bin/mysqladmin /usr/bin/
# ln -s /opt/mysql/bin/mysqld_safe /usr/bin/
# mysqld_safe &
# mysqladmin -u root password '123456'
# mysql -u root -p
mysql> show databases;
mysql>quit
三、编译安装apache
# groupadd -g 48 apache
# useradd -u 48 -g 48 -d /var/www -s /bin/false apache
# tar zxvf httpd-2.2.0 -C /usr/src/
# cd /usr/src/httpd-2.2.0
# ./configure --prefix=/opt/httpd --enable-echo --enable-module=most --enable-so --enable-shared=max --enable-authz-user --enable-auth-basic --enable-example --enable-charset-lite --enable-mime-magic --enable-proxy --enable-ssl --enable-static-htpasswd --enable-cgi --enable-vhost-alias --enable-userdir --enable-alias
# make && make install
# mv /opt/httpd/htdocs /var/www/html
# chown -R root:root /var/www
# chmod -R 755 /var/www
# vi /opt/httpd/conf/httpd.conf
ServerName mail.example.com
DirectoryIndex index.php index.html
DocumentRoot "/var/www"
…………
LoadModule php4_module modules/libphp4.so
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 20971520
AddDefaultCharset GB18030
AddType application/x-httpd-php .php
四、编译安装php
#tar zxvf php-4.4.4.tar.bz2 -C /usr/src
#cd /usr/src/php-4.4.4
# ./configure --prefix=/opt/httpd/ --enable-memory-limit --enable-debug --enable-versioning --enable-dio --enable-dba --enable-ftp --enable-dbx --with-gd --with-apxs2=/opt/httpd/bin/apxs --with-mysql=/opt/mysql --with-openssl --with-mime-magic --with-config-file-path=/opt/httpd/conf --with-zlib-dir
#make && make install
# cp php.ini-dist /opt/httpd/conf/php.ini
# vi /opt/httpd/conf/php.ini
max_execution_time = 60
max_input_time = 60
memory_limit = 50M
file_uploads = On
upload_max_filesize = 10M
post_max_size = 8M
session.auto_start = 1
四、创建phpinfo测试页
# vi /var/www/html/info.php
phpinfo();
?>;
# /usr/sbin/apache start
访问 查看服务器apache/php信息
五、编写httpd、mysqld自启动脚本 [可以参考备份的httpd.bak、mysqld.bak脚本进行修改]
# vi /etc/init.d/httpd
# chmod 755 /etc/init.d/httpd
# chkconfig --add httpd
# chkconfig --level 345 httpd on
# vi /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
[httpd、mysqld简单脚本内容]
###########################################################################
#########/etc/init.d/httpd#########
#!/bin/bash
# chkconfig: - 85 15
# description:Start and stop apache server
# config: /opt/httpd/conf/httpd.conf
. /etc/rc.d/init.d/functions
basedir=/opt/httpd
apachectl=$basedir/bin/apachectl
httpd=$basedir/bin/httpd
start() {
echo "Starting apache server......"
$apachectl start
}
stop() {
echo "Stopping apache server......"
$apachectl stop
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: httpd {start|stop|restart}"
exit 1
esac
#########################################
#########/etc/init.d/mysqld#########
#!/bin/sh
# chkconfig: 2345 90 90
# Description: Start and stop MySQL server
basedir=/opt/mysql
bindir=$basedir/bin
export PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
case "$1" in
'start')
echo "Starting mysqld daemon........"
cd $basedir
$bindir/mysqld_safe &
;;
'stop')
mysqld_pid=`ps ax | grep mysqld | grep -v grep | awk '{print $1}'`
echo "Killing mysqld with pid $mysqld_pid"
kill -9 $mysqld_pid
;;
'restart')
$0 stop
$0 start
;;
*)
echo "Usage: $0 start|stop|restart"
exit 1
;;
esac
#########################################
阅读(842) | 评论(0) | 转发(0) |