系统:CentOS 6.5 最小化安装
(一)apache部分
解决依赖关系:
yum install pcre pcre-devel zlib zlib-devel libtool libtool-ltdl-devel
编译安装apr:
tar xf apr-*
cd apr-*
./configure --prefix=/usr/local/apr
make && make install
如果出现以下这个错误,请修改当前目录下的configure文件
找到$RM "$cfgfile",然后注释掉,重新配置,就可以编译了。
config.status: executing libtool commands
rm: cannot remove `libtoolT‘: No such file or directory
config.status: executing default commands
编译安装apr-util:
tar xf apr-util-*
cd apr-util-*
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
编译安装apache:
tar xf httpd-*
cd httpd-*
./configure --prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--enable-cache \
--enable-file-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-z= \
--with-pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--enable-modules=most \
--enable-mpms-shared=all
出现错误:
checking for OpenSSL... checking for user-provided OpenSSL base directory... none
checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
解决方案:
yum install openssl-devel
httpd的启动脚本:
#!/bin/bash
# Startup script for the Apache2.0.X Web Server
# Fixed by Comsenz - Nanu (nanu@discuz.com)
# chkconfig: - 85 15
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
INITLOG_ARGS=""
apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
prog=httpd
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $httpd -HUP
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog
{start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
为httpd启动脚本加上+x权限:
chmod +x /etc/rc.d/init.d/httpd
讲httpd加入服务列表:
chkconfig --add httpd
chkconfig httpd on
(二)MySQL部分
解决依赖关系:
yum install cmake ncurses ncurses-devel
添加MySQL用户:
groupadd mysql
useradd -r -g mysql mysql
编译安装MySQL:
tar xf mysql-*
cd mysql-*
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
修改属主属组:
chown -R root.mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/data
初始化MySQL:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/
提供MySQL配置文件:
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
加入服务列表:
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chown root /etc/rc.d/init.d/mysqld
启动MySQL:
service mysqld start
设置密码:
mysql> SET PASSWORD = PASSWORD(‘123456‘);
(三)PHP部分
解决依赖关系:
yum install gd gd-devel libxml2 libxml2-devel freetype freetype-devel
安装jpeg:
tar xf jpeg-*
cd jpeg-*
./configure --prefix=/usr/local/jpeg9 --enable-share --enable-static
make && make install
这个警告没事:
警告:configure: WARNING: unrecognized options: --enable-share
安装libpng:
tar xf libpng-*
cd libpng-*
./configure --prefix=/usr/local/libpng
make && make install
安装libmcrypt:
tar xf libmcrypt-*
cd libmcrypt-*
./configure --prefix=/usr/local/libmcrypt
make && make install
编译安装php:
tar xf php-*
cd php-*
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql/ \
--with-libxml-dir \
--with-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg/ \
--with-freetype-dir \
--with-gd \
--with-zlib-dir \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap \
--enable-mbstring=all \
--enable-sockets
make && make install
提供php的配置文件:
cp php.ini-development /usr/local/php/etc/php.ini
配置apache的配置文件,支持php
httpd.conf加入以下几行:
AddType application/x-httpd-php .php
Addtype application/x-httpd-php-source .phps
DirectoryIndex index.html index.php
测试php:
<?
phpinfo();
?>
测试MySQL:
<?php
$link=mysql_connect=(‘localhost‘,‘root‘,‘123456‘);
if ($link) echo "OK";
else "OFF";
mysql_close();
?>
本文出自 “小疯魔” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1634709
原文地址:http://xiaofengmo.blog.51cto.com/10116365/1634709