1、确认搭建LAMP所需的环境是否已经安装:

[root@localhost ~]#rpm -q make gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel bisonncurses-devel

备注:安装libpng时需要zlib-devel

          安装php时需要libtoollibtool-ltdllibtool-ltdl-devel

          安装mysql时需要bisonncurses-devel

 

 

2、如果没安装则yum安装:

[root@localhost~]#yum -y install make gcc gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel bison ncurses-devel

 

 

3、由于要使用编译安装,所以查看httpdmysqlphp是否安装:

[root@localhost ~]#rpm -q httpd mysql php

如果安装则卸载:

[root@localhost ~]#rpm -e httpd --nodeps

[root@localhost ~]#rpm -e mysql --nodeps

[root@localhost ~]#rpm -e php --nodeps

 

 

编译安装过程介绍:

       1)解压tar.gz为后缀的压缩软件包:LAMP环境搭建所需要的每个软件的软代码文件,都是以tar.gz.tgz提供给我们的打包压缩文件,所以我们必须将其解压再解包。命令如下:

       tar–zxvf *.tar.gz

       2)在linux系统中源代码包安装过程:LAMP环境搭建所需要的软件都是使用C语言开发的,所以安装源代码文件最少需要配置、编译和安装三个步骤

       配置(configure)、编译(make)、安装(makeinstall

 

 

4、编译安装libxml2

[root@localhostlinux]# tar -zxvf libxml2-2.6.30.tar.gz 

[root@localhostlinux]# cd libxml2-2.6.30 

[root@localhostlibxml2-2.6.30]# ./configure --prefix=/usr/local/libxml2

[root@localhostlibxml2-2.6.30]# make

[root@localhostlibxml2-2.6.30]# make install

 

 

5、编译安装libmcrypt

[root@localhostlinux]# tar -zxvf libmcrypt-2.5.8.tar.gz

[root@localhostlinux]# cd libmcrypt-2.5.8

[root@localhostlibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt 

[root@localhostlibmcrypt-2.5.8]# make

[root@localhostlibmcrypt-2.5.8]# make install

 

 

6、编译安装zlib

[root@localhostlinux]# tar -zxvf zlib-1.2.3.tar.gz

[root@localhostlinux]# cd zlib-1.2.3

[root@localhostzlib-1.2.3]# CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib/

(用64位元的方法进行编译)

[root@localhostzlib-1.2.3]# make

[root@localhostzlib-1.2.3]# make install

 

 

7、编译安装libpng

[root@localhostlinux]# tar -zxvf libpng-1.2.31.tar.gz

[root@localhostlinux]# cd libpng-1.2.31

[root@localhostlibpng-1.2.31]# ./configure --prefix=/usr/local/libpng \

>--enable-shared (建立共享库使用的GNUlibtool

[root@localhostlibpng-1.2.31]# make

[root@localhostlibpng-1.2.31]# make install

 

 

8、编译安装jpeg

[root@localhostlinux]# tar -zxvf jpegsrc.v6b.tar.gz

[root@localhostlinux]# cd jpeg-6b

[root@localhostjpeg-6b]# mkdir /usr/local/jpeg                    (创建jpeg软件的安装目录)

[root@localhostjpeg-6b]# mkdir /usr/local/jpeg/bin            (创建存放命令的目录)

[root@localhostjpeg-6b]# mkdir /usr/local/jpeg/lib             (创建jpeg库文件所在目录)

[root@localhostjpeg-6b]# mkdir /usr/local/jpeg/include      (创建存放头文件目录)

[root@localhostjpeg-6b]# mkdir -p /usr/local/jpeg/man/man1  (建立存放手册的目录)

[root@localhostjpeg-6b]# ./configure --prefix=/usr/local/jpeg \

>--enable-shared \    (建立共享库使用的GUNlibtool

>--enable-static        (建立静态库使用的GUNlibtool

[root@localhostjpeg-6b]# make

[root@localhostjpeg-6b]# make install

 

执行make时如果出现如下错误:

./libtool --mode=compile gcc-O2  -I. -c ./jcapimin.c

make: ./libtool: Command notfound

make: *** [jcapimin.lo] Error 127

解决方法:

默认已安装libtoollibtool-ltdl-devel(如需帮助请看过程2

[root@localhostjpeg-6b]# find / -name config.sub

/usr/share/libtool/config/config.sub

[root@localhostjpeg-6b]# find / -name config.guess

/usr/share/libtool/config/config.guess

[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.sub .

[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.guess .

也就是把libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件

make clean 再重新configure

 

 

9、编译安装freetype

[root@localhostlinux]# tar -zxvf freetype-2.3.5.tar.gz

[root@localhostlinux]# cd freetype-2.3.5

[root@localhostfreetype-2.3.5]# ./configure --prefix=/usr/local/freetype \

>--enable-shared    (建立共享库使用的GUNlibtool

[root@localhostfreetype-2.3.5]# make

[root@localhostfreetype-2.3.5]# make install

 

 

10、编译安装autoconf

[root@localhostlinux]# tar -zxvf autoconf-2.61.tar.gz

[root@localhostlinux]# cd autoconf-2.61

[root@localhostautoconf-2.61]# ./configure

[root@localhostautoconf-2.61]# make

[root@localhostautoconf-2.61]# make install

 

 

11、编译安装GD

[root@localhostlinux]# tar -zxvf gd-2.0.35.tar.gz

[root@localhostlinux]# cd gd-2.0.35

[root@localhostgd-2.0.35]# ./configure --prefix=/usr/local/gd \

>--with-zlib=/usr/local/zlib/ \      (指定zlib库文件的位置)

>--with-jpeg=/usr/local/jpeg/ \    (指定jpeg库文件的位置)

>--with-png=/usr/local/libpng/ \  (指定png库文件的位置)

>--with-freetype=/usr/local/freetype/     (指定freetype字体库的位置)

[root@localhostgd-2.0.35]# make

[root@localhostgd-2.0.35]# make install

 

执行make时如果出现如下错误:

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

make[2]: Leaving directory`/usr/src/linux/gd-2.0.35'

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

make[1]: Leaving directory`/usr/src/linux/gd-2.0.35'

make: *** [all]  Error 2

解决方法:

[root@localhostgd-2.0.35]# find / -name gd_png.c

/usr/src/linux/gd-2.0.35/gd_png.c

[root@localhostgd-2.0.35]# find / -name png.h

/usr/local/libpng/include/png.h

[root@localhostgd-2.0.35]# vi /usr/src/linux/gd-2.0.35/gd_png.c

#include "png.h"    

改为#include "/usr/local/libpng/include/png.h"    

 

 

12、编译安装apache

[root@localhostlinux]# tar -zxvf httpd-2.2.9.tar.gz

[root@localhostlinux]# cd httpd-2.2.9

[root@localhosthttpd-2.2.9]# ./configure --prefix=/usr/local/apache \

> --enable-so \       (以动态共享对象编译)

>--enable-rewrite  (基于规则的URL操控)

[root@localhosthttpd-2.2.9]# make

[root@localhosthttpd-2.2.9]# make install

apache加入开机启动↓

[root@localhosthttpd-2.2.9]# cp -vRp /usr/local/apache/bin/apachectl /etc/init.d/httpd

[root@localhosthttpd-2.2.9]# chmod +x /etc/init.d/httpd 

添加apache服务↓

[root@localhosthttpd-2.2.9]# chkconfig --add httpd

[root@localhosthttpd-2.2.9]# chkconfig --level 2345 httpd on

[root@localhosthttpd-2.2.9]# service httpd start

 

启动服务时,如果出现如下错误:

httpd: Could not reliablydetermine the server's fully qualified domain name, using localhost.localdomainfor ServerName

解决方法:

[root@localhosthttpd-2.2.9]# vi /usr/local/apache/conf/httpd.conf

添加上:ServerName localhost:80

 

执行chkconfig,如果出现如下错误:

service httpd does not supportchkconfig

解决方法:

[root@localhosthttpd-2.2.9]# vi /etc/rc.d/init.d/httpd

在文件第二行加入

#chkconfig:2345 10 90

#description:Activates/DeactivatesApache Web Server

保存后再执行chkconfig

 

 

13、编译安装mysql(最新版本都需要cmake编译安装)

 

编译安装 cmake

[root@localhostlinux]# tar -zxvf cmake-2.8.7.tar.gz

[root@localhostlinux]# cd cmake-2.8.7

[root@localhostcmake-2.8.7]# ./bootstrap

[root@localhostcmake-2.8.7]# gmake

[root@localhostcmake-2.8.7]# gmake install

 

编译安装 MySQL5.5.20

[root@localhostcmake-2.8.7]# groupadd mysql

[root@localhostcmake-2.8.7]# useradd -g mysql mysql

[root@localhostlinux]# tar -zxvf mysql-5.5.15.tar.gz

[root@localhostlinux]# cd mysql-5.5.15

[root@localhostmysql-5.5.15]#

cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \           (安装根目录)

> -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \   UNIX socket文件)

>-DDEFAULT_CHARSET=utf8 \     (默认字符集)

>-DDEFAULT_COLLATION=utf8_general_ci \  (默认编码)

>-DWITH_EXTRA_CHARSETS=utf8,gbk \         (额外的编码)

>-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \(启用PERFSCHEMA引擎支持)

>-DWITH_FEDERATED_STORAGE_ENGINE=1 \   (启用FEDERATED引擎支持)

> -DWITH_PARTITION_STORAGE_ENGINE=1\     (启用PARTITION引擎支持)

>-DWITH_ARCHIVE_STORAGE_ENGINE=1 \         (启用ARCHIVE引擎支持)

>-DWITH_READLINE=1 \(使用readline功能)

>-DMYSQL_DATADIR=/usr/local/mysql/data \  (数据库数据目录)

>-DMYSQL_TCP_PORT=3306                              TCP/IP端口)

[root@localhostmysql-5.5.15]# make

[root@localhostmysql-5.5.15]# make install

[root@localhostmysql-5.5.15]# cp -vRp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

修改配置文件↓

[root@localhostmysql-5.5.15]# vi /etc/my.cnf

     basedir=/usr/local/mysql

     datadir=/usr/local/mysql/data

     log-error=/usr/local/mysql/data/error.log

     pid-file=/usr/local/mysql/data/mysql.pid

初始化数据库文件↓

[root@localhostmysql-5.5.15]# /usr/local/mysql/scripts/mysql_install_db \

>--defaults-flie=/etc/my.cnf \

> --basedir=/usr/local/mysql/\

>--datadir=/usr/local/mysql/data \

>--pid-file=/usr/local/mysql/data/mysql.pid \

> --user=mysql

权限设置↓

[root@localhostmysql]# chown -R root .

[root@localhostmysql]# chown -R mysql data

[root@localhostmysql]# chgrp -R mysql .

mysql加入开机启动↓

[root@localhostmysql]# cp -vRp support-files/mysql.server /etc/init.d/mysqld

[root@localhostmysql]# chmod +x /etc/init.d/mysqld

添加mysql服务↓

[root@localhostmysql]# chkconfig --add mysqld

[root@localhostmysql]# chkconfig --level 345 mysqld on

[root@localhostmysql]# service mysqld start

配置mysql

[root@localhostmysql]# bin/mysql

mysql> deletefrom mysql.user where Host!='localhost'; (只留允许本机登录的帐号)

mysql> flushprivileges;  (刷新授权表)

mysql> setpassword for 'root'@'localhost'=password('123456');  (设置用户密码)

mysql> exit

[root@localhostmysql]# bin/mysql -h localhost -u root -p123456 (登录mysql

 

 

14、编译安装php

[root@localhostlinux]# tar -zxvf php-5.3.19.tar.gz

[root@localhostlinux]# cd php-5.3.19

[root@localhostphp-5.3.19]# ./configure --prefix=/usr/local/php \

>--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/jpeg/ \

>--with-freetype-dir=/usr/local/freetype/ \

> --with-gd=/usr/local/gd/\

>--with-mcrypt=/usr/local/libmcrypt/ \

>--with-mysqli=/usr/local/mysql/bin/mysql_config \

> --enable-soap\                  (变量激活SOAPweb services支持)

>--enable-mbstring=all \    (使多字节字符串支持)

>--enable-sockets                (变量激活socket通讯特性)

[root@localhostphp-5.3.19]# make

[root@localhostphp-5.3.19]# make install

[root@localhostphp-5.3.19]# cp -vRp php.ini-development /etc/php.ini

[root@localhostphp-5.3.19]# vi /usr/local/apache/conf/httpd.conf

添加上:

    AddType application/x-httpd-php .php

[root@localhostphp-5.3.19]# service httpd stop

[root@localhostphp-5.3.19]# service httpd start

[root@localhostphp-5.3.19]# vi /usr/local/apache/htdocs/phpinfo.php

添加内容为:

<?php

       phpinfo();

?>

打开浏览器进行访问,如果出现PHP版本界面,及安装成功。

CentOS 6.5下搭建LAMP环境详细步骤的更多相关文章

  1. 64位CentOS 6.0下搭建LAMP环境

    系统环境:Centos6.0 x64 1.确认搭建LAMP所需要的环境是否已经安装 [root@centos6 ~]# rpm -q make gcc gcc-c++ zlib-devel libai ...

  2. CentOS下搭建LAMP环境详解

    前言:在这里将介绍如何在CentOS下搭建LAMP环境(全部使用源码编译安装),用于web服务器开发. •LAMP: Linux + Apache + PHP + Mysql. •系统: CentOS ...

  3. linux下搭建lamp环境以及安装swoole扩展

    linux下搭建lamp环境以及安装swoole扩展   一.CentOS 6.5使用yum快速搭建LAMP环境 准备工作:先更新一下yum源  我安装的环境是:apache2.2.15+mysql5 ...

  4. Centos6.4版本下搭建LAMP环境

    Centos6.4版本下搭建LAMP环境 配置yum mkdir/mnt/cdrom mount/dev/cdrom  /mnt/cdrom 装载光盘 vi /etc/yum.repos.d/Cent ...

  5. Ubuntu18.04下搭建LAMP环境

    一.Apache2 web 服务器的安装 : 可以先更新一下服务器 1.sudo apt-get update             # 获取最新资源包 2.sudo apt-get upgrade ...

  6. CentOS6.5下搭建LAMP环境(源码编译方式)

    CentOS 6.5安装配置LAMP服务器(Apache+PHP5+MySQL) 学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP ,WAMP,MAMP等.这里我介 ...

  7. ubuntu server 14.04 LTS下搭建LAMP环境之最详细笔记之一U盘安装双系统

    前言: 一直在WIN上使用PHP,不喜欢用WAMP,每次都是手动在windows配置环境,偶尔有一次装了小红帽玩了两天,感觉不是很习惯就换了回来,过了没几天见讨论LAMP环境,于是安装了ubuntu的 ...

  8. 在Ubuntu Server下搭建LAMP环境学习记录

    更新于2015/6/16日,因图片地址失效,请在此地址查看:http://note.youdao.com/share/?id=1c249ae6dc6150cbf692adec67b23a33& ...

  9. CentOS 6.6 yum 搭建LAMP环境

    CentOS 查看操作系统版本 [root@oa ~]# cat /etc/redhat-releaseCentOS release 6.6 (Final) 参考linux centos yum安装L ...

随机推荐

  1. 【LeetCode OJ】Binary Tree Level Order Traversal II

    Problem Link: https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/ Use BFS from th ...

  2. HDU1005(矩阵快速幂)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 #include<cstdio> using namespace std; int ...

  3. JavaScript中__proto__与prototype的关系

    一.所有构造器/函数的__proto__都指向Function.prototype,它是一个空函数(Empty function) 1 2 3 4 5 6 7 8 9 Number.__proto__ ...

  4. Linux内核分析——跟踪分析Linux内核的启动过程

    万子惠 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程 实验部分 menu程序: cd LinuxKernel/ qemu -kernel linux-3.18.6/a ...

  5. RouteArea中AreaPrefix(Area 前缀)的使用

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  6. codeforces 199a

    link:http://codeforces.com/contest/342/problem/A 恩恩,读错题了.人家是at most 7,我理解成了at lease 7.好欢乐~ #include ...

  7. pcl点云文件格式

    PCD版本 在点云库(PCL)1.0版本发布之前,PCD文件格式有不同的修订号.这些修订号用PCD_Vx来编号(例如,PCD_V5.PCD_V6.PCD_V7等等),代表PCD文件的0.x版本号.然而 ...

  8. 编译llvm+clang

    第一步,下载llvm代码: git clone git@github.com:llvm-mirror/llvm.git 第二步,进入llvm/tools目录并下载clang代码 cd llvm/too ...

  9. Qt之QComboBox(基本应用、代理设置)(转)

    QComboBox下拉列表比较常用,用户可以通过选择不同的选项来实现不同的操作,如何实现自己的下拉列表呢? 很多人在问QComboBox如何设置选项的高度.代理等一些问题!今天就在此分享一下自己的一些 ...

  10. docvalues和Fieldcache

    Fieldcache:  docID->document->fieldvalue 无论是聚类排序关联等,首先都需要获得文档中某个字段的值,通过docID去获得整个document,然后再去 ...