centos6.5 编译lamp(亲测)

1,安装文件分享: http://pan.baidu.com/s/1ntig3ED
 
2,安装gcc
yum install gcc gcc-c++ gcc-g77
 
3,卸载老版本的http,MySQL,PHP
rpm -qa | grep http
rpm -qa | grep mysql
rpm -qa | grep php
卸载命令:rmp -e xxx --nodeps
 
4,所有文件目录:
chmod -R 777 /usr/local/src
 
 

  1、卸载安装 apr

yum remove apr apr-util

cd /usr/local/src/apr-1.5.0

./configure --prefix=/usr/local/apr-httpd/ && make && make install

 

2,安装apr-util-1.5.3.tar.gz
       cd /usr/local/src/apr-util-1.5.3
       ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install
3,安装limxml2
      cd libxml2-2.9.0
      ./configure --prefix=/usr/local/libxml2
      make && make install
4,安装libmcrypt
     cd /usr/local/src/libmcrypt-2.5.8
     ./configure --prefix=/usr/local/libmcrypt
     make && make instll
5,安装zlib
     cd /usr/local/src/zlib-1.2.7
     ./configure
     make && make install
6,安装libpng
     cd /usr/local/src/libpng-1.2.50
     ./configure --prefix=/usr/local/libpng
    make && make install
如果错误:/usr/local/lib/libz.a: could not read symbols: Bad value

/usr/local/lib/libz.a: could not read symbols: Bad value

一般是64 位 电脑才会出现。

 
     

解决方法如下:

cd zlib-1.2.3 //进入zlib目录

CFLAGS="-O3 -fPIC" ./configure   //使用64位元的方法进行编译

make

make install

make clean
7,安装jpeg8
    cd /usr/local/src/jpeg-9a
    mkdir /usr/local/jpeg8
    mkdir /usr/local/jpeg8/bin
    mkdir /usr/local/jpeg8/lib
    mkdir /usr/local/jpeg8/include
   mkdir -p /usr/local/jpeg8/man/man1
   ./configure \
   --prefix=/usr/local/jpeg8/ \
  --enable-share \
   --enable-static
make && make install
8,安装freetype
   cd /usr/local/src/freetype-2.1.10 
   ./configure --prefix=/usr/local/freetype
  make && make install
9,安装autoconf
   cd /usr/local/src/autoconf-2.69
  ./configure 
make && make install
10,安装GD
    cd /usr/local/src/libgd-2.1.1
    ./configure  --prefix=/usr/local/gd2 --enable-m4-pattern_allow --with-zlib-/usr/local/zlib/  --with-jpeg=/usr/local/jpeg8/    --with-png=/usr/local/libpng/   --with-freetype=/usr/local/freetype/
make && make install

  如果报错:

make[2]: *** [gd_png.lo] Error 1

make[2]: Leaving directory `/tmp/gd-2.0.35'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/tmp/gd-2.0.35'

make: *** [all] Error 2

解决方案:

vi gd_png.c

找到#include "png.h"改成#include "/usr/local/libpng/include/png.h"

 

11,安装pcre

   cd /usr/local/src/pcre-8.12

   ./configure --prefix=/usr/local/pcre

  make && make install

 

12,安装Apache

   cd /usr/local/src/httpd-2.4.3

   ./configure \

   --prefix=/usr/local/apache \

--enable-mods-shared=all \

 --enable-deflate \

--enable-speling \

--enable-cache \

--enable-file-cache \

--enable-disk-cache \

--enable-mem-cache \

--enable-so \

--enable-expires=shared \

--enable-rewrite=shared \

--enable-static-support \

--sysconfdir=/etc/httpd \

--with-z=/usr/local/zlib/ \

--with-apr=/usr/local/apr-httpd/ \

--with-apr-util=/usr/local/apr-util-httpd/ \

--with-pcre=/usr/local/pcre/ \

--disable-userdir

make && make install

 

vi /etc/httpd/httpd.conf

加上下面一行,重启apache

ServerName localhost:80

echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local

 

13,安装MySQL

 
cd /usr/local/src/mysql-5.6.15-linux-glibc-2.5-x86_64
 groupadd mysql
 useradd -r -g mysql mysql
cd /usr/local/
ln -s  /usr/local/src/mysql-5.6.15-linux-glibc-2.5-x86_64  mysql
 cd ./mysql/
chown -R mysql .
 chgrp -R mysql .
 ./scripts/mysql_install_db --user=mysql
 chown -R root .
 chown -R mysql data
cp support-files/my-default.cnf  /etc/my.cnf
 cp support-files/mysql.server  /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
 chkconfig --add mysqld
 chkconfig --level 345 mysqld on
service mysqld restart
 /usr/local/mysql/bin/mysqladmin -u root password '123456'(设置root用户登录mysql的密码)
/usr/local/mysql/bin/mysql -u root –p(进入并访问mysql数据)

 

 

14,安装PHP

  cd /usr/local/src/php-5.5.7

  ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-png-dir=/usr/local/libpng/ --with-jpeg-dir=/usr/local/jpeg8/ --with-freetype-dir=/usr/local/freetype/ --with-zlib-dir=/usr/local/zlib/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets

make && make install

 

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-png-dir=/usr/local/libpng/ --with-jpeg-dir=/usr/local/jpeg8/ --with-freetype-dir=/usr/local/freetype/ --with-zlib-dir=/usr/local/zlib/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --with-gd=/usr/local/gd2/  

总是报错:make: *** [ext/gd/gd.lo] 错误 1(待解决)

cd /usr/local/src/php-5.5.7 
cp php.ini-development /usr/local/php/etc/php.ini
修改php.ini 把;date.timezone 前面的分号去掉,改成date.timezone ="PRC"
vi /etc/httpd/http.conf
AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz(下面添加)

AddType application/x-httpd-php .php .html

 

/usr/local/apache/bin/apachectl stop

/usr/local/apache/bin/apachectl start

 

/url/local/apache/htdocs/index.php

<?php

phpinfo();

?>

    
 
 
 

你可能感兴趣的:(centos6)