一,LAMP的安装流程:mysql、apache、php或者apache、mysql、php。php放到最后的原因是,php在编译安装的时候是依赖于前2者的。
二,Mysql的安装:
1.下载mysql,可以通过http://mirrors.sohu.com/下载mysql软件。
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz
2.解压并重命名
tar -zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz
三,安装apache
1,下载httpd并解压。
wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz
tar -zxvf httpd-2.2.31.tar.gz
2,编译前的参数配置
cd /usr/local/ httpd-2.2.31
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/usr/local/mysql \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-bz2 \
--with-openssl \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-sockets \
解决办法是:
yum install -y libxml2-devel
还有错误:
configure: error: Cannot find OpenSSL's <evp.h>
解决办法是:
yum install -y openssl openssl-devel
错误:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解决办法:
yum install -y bzip2 bzip2-devel
错误:
configure: error: png.h not found.
解决办法:
yum install -y libpng libpng-devel
错误:
configure: error: freetype.h not found.
解决办法:
yum install -y freetype freetype-devel
错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:
yum install -y epel-release
yum install -y libmcrypt-devel
因为centos6.x 默认的yum源没有libmcrypt-devel 这个包,只能借助第三方yum源。另外,这里安装的包都是*-devel的包。
4.3,编译
make
4.4,安装
make install
4.5 拷贝配置文件
cp /usr/local/src/php-5.3.28/ php.ini-production /usr/local/php/etc/php.ini
这里有2个文件,1个是production(生产环境),1个是development(测试环境)。
Apache主配置文件为:/usr/local/apache2/conf/httpd.conf
vim/usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:
AddType application/x-httpd-php .php 添加可以对php脚本解析,必须添加上对应的类型
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将该行改为:
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule> 增加对PHP的索引 自动索引页
<?php $link = mysql_connect('127.0.0.1','root',''); if ($link) echo "successful..."; else echo "Failure..."; mysql_close(); ?>