linux下apache+mysql+php安装

介绍

apache+mysql+php这是个很经典的组合,当然在很大一部分情况下也会附属上svn、memcache、redis之类的,这里只是简单的介绍下前三种组合的安装程序,在具体项目中,安装方法可能有些许的不同,不过思路上是一样的。
这里我们需要提前说一下apache、mysql、php、的版本,分别为:httpd-2.2.22.tar.gz,mysql- 5.5.27.tar.gz,php-5.4.4.tar.gz,不同的版本相互之间的依赖是不一样的,安装方法也有区别,(比如说mysql,新版的安 装都是用cmake,而旧版的直接用make就ok了)

准备

安装之前要先准备好相应的安装包,下载地址如下
httpd-2.2.22.tar.gz 下载地址:http://httpd.apache.org/download.cgi#apache22
mysql-5.5.27.tar.gz 下载地址:http://dev.mysql.com/downloads/mirror.php?id=408971(要先注册登录才能下载)
php-5.4.4.tar.gz 下载地址:http://cn.php.net/downloads.php
安装php还需要一些附加的组件扩展,这里也一并把地址给大家! 这些可以通过yum安装,更快,更方便!
curl-7.27.0_11547.tar.gz 下载地址:http://curl.haxx.se/latest.cgi?curl=tar.gz
jpegsrc.v8.tar.gz 下载地址:http://www.ijg.org/files/
libpng-1.2.31.tar.gz 下载地址:http://sourceforge.net/projects/libpng/files/
freetype-2.4.9.tar.gz 下载地址:http://sourceforge.net/projects/freetype/files/freetype2/2.4.9/
zlib-1.2.6.tar.gz 下载地址:http://sourceforge.net/projects/libpng/files/zlib/
gettext-0.18.1.1.tar.gz 下载地址:http://gnu.yubis.org/gettext/
gd-2.0.35.tar.gz 下载地址:http://fossies.org/unix/www/gd-2.0.35.tar.gz/
libxml2-2.7.8.tar.gz 下载地址:http://download.chinaunix.net/download/0007000/6095.shtml
libmcrypt-2.5.7.tar.gz 下载地址:ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz

安装

安装apache
# tar –zvxf httpd-2.2.22.tar.gz
# cd httpd-2.2.22
# ./configure –prefix=/usr/local/httpd/ –enable-modules=all –enable-mods-shared=all –enable-ssl –enable-http –enable-rewrite –with-apr=/usr/local/apr/ –with-apr-util=/usr/local/apr-util/
# make && make install
安装mysql
# tar –zvxf mysql-5.5.27.tar.gz
# cd mysql-5.5.27
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
# gmake && make install
# cp mysql-5.5.27/support-files/my-huge.cnf /etc/my.cnf 拷贝解压后目录mysql-5.5.27/support-files
安装默认库文件
# /usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data //(看到两个ok就安装没有问题了)
# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig –add mysqld
# service mysqld start
如果没有用yum安装php的扩展,在安装php之前必须都安装好了,这样php才能更好的为我们服务,至于那些的安装,这里就不费口舌了,相信大家都会了,我们直接进入php的安装环节
安装php
# tar –zvxf php-5.4.4.tar.gz
# cd php-5.4.4
# ./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/httpd/bin/apxs –with-mysql=/usr/local/mysql –with-curl –with-libxml-dir –enable-ftp –with-config-file-path=/usr/local/php5/etc –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curlwrappers –enable-mbregex –enable-zip –with-mcrypt –with-gd –enable-soap //如果没有用yum安装,参数需要指定安装路径
# make && make install
# cp php.ini-production /usr/local/php5/etc/php.ini
修改httpd.conf
添加php支持
添加:index.php
添加:AddType application/x-httpd-php.php
AddType application/x-httpd-php-source.phps
修改ServerName
ServerName 192.168.1.217

到这里就基本安装好了,重启下apache,就可以写测试文件了!
#cd /usr/local/httpd/htdocs
vim index.php
<?php
echo phpinfo();
?>
保存后退出,就可以看到php的相关信息了!

posted @ 2013-12-17 13:28  樰梅  阅读(320)  评论(0编辑  收藏  举报