环境搭建
该环境基于centos5.5
用到的软件:httpd-2.2.17.tar.bz2 
mysql-5.1.59.tar.gz
libmcrypt-2.5.8.tar.bz2


安装httpd
useradd apache
tar -xvf httpd-2.2.17.tar.bz2 
cd httpd-2.2.17
./configure  --with-prefix=/usr/local/apache2
make
make install
cp /usr/local/apache2/bin/apachectl  /etc/init.d/httpd
vi /usr/local/apache2/conf/httpd.conf 
//修改apache的运行帐号
User apache
Group apache   
//启动httpd服务器
service httpd start
lamp 环境搭建_休闲
出现图中的80端口则说明 httpd 安装成功


安装mysql
useradd mysql
tar -xvf mysql-5.1.59.tar.gz
cd mysql-5.1.59
./configure \
 --prefix=/usr/local/mysql \
 --localstatedir=/data/mysql/data \
 --with-comment=Source \
 --with-mysqld-user=mysql \
 --without-debug \
 --with-big-tables \
 --with-charset=utf8 \
 --with-extra-charsets=all \
 --with-pthread \
 --enable-static \
 --enable-thread-safe-client \
 --with-client-ldflags=-all-static \
 --with-mysqld-ldflags=-all-static \
 --enable-assembler  \
 --without-ndb-debug
make                //时间有点长,耐心等待
make install
cd /usr/local/mysql
chown -R mysql:mysql .
cp /root/mysql-5.1.59/support-files/my-medium.cnf /etc/my.cnf
bin/mysql_install_db --user=mysql
cp /root/mysql-5.1.59/support-files/mysql.server /etc/init.d/mysqld
bin/mysqld_safe --user=mysql &
Bin/mysql -uroot
 
lamp 环境搭建_休闲_02

安装链接库文件
yum install bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel  gd gd-devel libxml2 libxml2-devel
安装libmcrypt
tar xvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install

安装php
tar xvf php-5.3.6.tar.bz2
cd php-5.3.6
./configure
--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=/usr/ \
--with-gd=/usr/ \
--with-jpeg-dir \
--with-png-dir \
--with-bz2 \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir  \
--with-openssl \
--with-mcrypt=/usr/local/libmcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--disable-ipv6 \
--disable-cgi \
--disable-cli
  
Make 
Make test
Make install
apache支持php
Cd /usr/local/apache2/conf
Vi httpd.conf
LoadModule php5_module        modules/libphp5.so //把这行前面的"#"去掉。
<IfModule dir_module>
    DirectoryIndex index.html  index.php  //红色部分为新增部分
</IfModule>
 AddType application/x-compress .Z
 AddType application/x-gzip .gz .tgz
 AddType application/x-httpd-php .php    //同上,红色部分为新添加内容
重新启动httpd,出一下错误提示
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied 
Setenforce=0
chcon -t texrel_shlib_t /usr/local/apache2/modules/*.so
Service httpd restart
Vi /usr/local/apache2/htdocs/index.php
访问http://192.168.88.21/index.php
然后出现下图,则成功
 
lamp 环境搭建_休闲_04


谢谢大家支持
By: OuThink