64位CentOS 6.0下搭建LAMP环境详细步骤

   2015-11-29 0
核心提示:这篇文章主要介绍了系统环境:Centos6.0 x64的lamp运行环境配置教程,需要的朋友可以参考下

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

[root@centos6 ~]# rpm -q make gcc gcc-c++ zlib-devel libaio
备注:安装libpng时候需要zlib-devel
             安装mysql时候需要libaio
2、如果没安装则yum安装
[root@centos6 ~]# yum install make gcc gcc-c++ zlib-devel libaio -y
3、由于要使用编译安装,所以查看httpd、mysql、php是否安装,如果安装则卸载
[root@centos6 ~]# rpm -q httpd mysql php
4、编译安装libxml2
注:libxml2是一个xml的c语言版的解析器,不仅支持c语言,还支持c++、php、Pascal、Ruby、Tcl等语言的绑定
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libxml2-2.7.8.tar.gz
[root@centos6 LAMP]# cd ./libxml2-2.7.8
[root@centos6 libxml2-2.7.8]# ./configure  --prefix=/usr/local/libxml2/
[root@centos6 libxml2-2.7.8]# make;make install
5、编译安装LINK1>libmcrypt
注:libmcrypt是加密算法扩展库。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@centos6 LAMP]# cd ./libmcrypt-2.5.8
[root@centos6 libmcrypt-2.5.8]# ./configure  --prefix=/usr/local/libmcrypt/
[root@centos6 libmcrypt-2.5.8]# make;make install
6、编译安装zlib
注:zlib是提供数据压缩用的函式库
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf zlib-1.2.5.tar.gz
[root@centos6 LAMP]# cd ./zlib-1.2.5
[root@centos6 zlib-1.2.5]# ./configure  --prefix=/usr/local/zlib/
[root@centos6 zlib-1.2.5]# make ; make install
7、编译安装libpng
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf libpng-1.5.4.tar.gz
[root@centos6 LAMP]# cd ./libpng-1.5.4
[root@centos6 libpng-1.5.4]#
./configure --prefix=/usr/local/libpng/  --enable-shared
[root@centos6 libpng-1.5.4]# make ; make install
8、编译安装jpeg
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf jpegsrc.v8c.tar.gz
[root@centos6 LAMP]# cd ./jpeg-8c/
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/(创建jpeg软件的安装目录)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/bin/(创建存放命令的目录)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/lib/(创建jpeg库文件所在目录)
[root@centos6 jpeg-8c]# mkdir /usr/local/jpeg/include/(创建存放头文件目录)
[root@centos6 jpeg-8c]# mkdir -p /usr/local/jpeg/man/man1(建立存放手册的目录)
[root@centos6 jpeg-8c]#
 ./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)
[root@centos6 jpeg-8c]# make ; make install
9、编译安装freetype
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf freetype-2.4.6.tar.gz
[root@centos6 LAMP]# cd ./freetype-2.4.6
[root@centos6 freetype-2.4.6]#
 ./configure --prefix=/usr/local/freetype/ --enable-shared
[root@centos6 freetype-2.4.6]# make ;make install
10、      编译安装autoconf
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf autoconf-2.68.tar.gz
[root@centos6 LAMP]# cd ./autoconf-2.68
[root@centos6 autoconf-2.68]# ./configure
[root@centos6 autoconf-2.68]# make ; make install
11、      编译安装GD
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf gd-2.0.35.tar.gz
[root@centos6 LAMP]# cd ./gd-2.0.35
[root@centos6 gd-2.0.35]#
 ./configure --prefix=/usr/local/gd/ --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/
[root@centos6 gd-2.0.35]# make ; make install
12、      安装apache
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf httpd-2.2.19.tar.gz
[root@centos6 LAMP]# cd ./httpd-2.2.19
[root@centos6 httpd-2.2.19]#
 ./configure --prefix=/usr/local/apache/ --enable-so --enable-rewrite
[root@centos6 httpd-2.2.19]# make ; make install
[root@centos6 LAMP]# /usr/local/apache/bin/apachectl start
[root@centos6 LAMP]#
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@centos6 LAMP]# chmod +x /etc/init.d/httpd
[root@centos6 ~]# chkconfig --add httpd
注意:如果提示service httpd does not support chkconfig错误
解决办法:编辑/etc/rc.d/init.d/httpd在文件第二行加入
           #chkconfig:2345 10 90
           #description:Activates/Deactivates Apache Web Server
[root@centos6 ~]# chkconfig --level 2345 httpd on
[root@centos6 LAMP]# service httpd restart
开机自动启动apache的另一种方法:
修改/etc/rc.local文件
# vim /etc/rc.local
在文件中添加/usr/local/apache/bin/apachectl start
13、      编译安装mysql
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf mysql-5.5.15-linux2.6-x86_64.tar.gz
[root@centos6 LAMP]# cd ./mysql-5.5.15-linux2.6-x86_64
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# groupadd mysql
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# useradd -r -g mysql mysql(创建mysql用户,并将用户指定至mysql组)
[root@centos6 mysql-5.5.15-linux2.6-x86_64]# cd /usr/local/
[root@centos6 local]# ln -s /tmp/LAMP/mysql-5.5.15-linux2.6-x86_64 mysql
[root@centos6 local]# cd ./mysql/
[root@centos6 mysql]# chown -R mysql .(将该目录的用户权限全部更改为mysql用户)
[root@centos6 mysql]# chgrp -R mysql .(将该目录的用户组全部改为mysql用户组)
[root@centos6 mysql]# ./scripts/mysql_install_db --user=mysql(将mysql目录的数据库使用权限指定为mysql)
[root@centos6 mysql]# chown -R root .
[root@centos6 mysql]# chown -R mysql data
[root@centos6 mysql]# cp support-files/my-medium.cnf  /etc/my.cnf(将当前目录下的配置文件拷贝到系统配置文件下,并更名为my.cnf)
[root@centos6 mysql]# cp support-files/mysql.server  /etc/init.d/mysqld
[root@centos6 mysql]# chmod +x /etc/init.d/mysqld
[root@centos6 mysql]# chkconfig --add mysqld
[root@centos6 mysql]# chkconfig --level 345 mysqld on
[root@centos6 mysql]# service mysqld restart
[root@centos6 mysql]#
 /usr/local/mysql/bin/mysqladmin -u root password '123456'(设置root用户登录mysql的密码)
[root@centos6 mysql]# /usr/local/mysql/bin/mysql -u root –p(进入并访问mysql数据)
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.5.15-log MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>(成功登录mysql)
14、      编译安装php
[root@centos6 LAMP]# pwd
/tmp/LAMP
[root@centos6 LAMP]# tar -zxvf php-5.3.7.tar.gz
[root@centos6 LAMP]# cd ./php-5.3.7
[root@centos6 php-5.3.7]#
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache/bin/apxs --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg/ --with-freetype-dir=/usr/local/freetype/--with-gd-dir=/usr/local/gd/--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
[root@centos6 php-5.3.7]# make ; make install
[root@centos6 php-5.3.7]#
 cp php.ini-development /usr/local/php/lib/php.ini
#vim /usr/local/php/lib/php.ini
 //这里需要将register_globals=Off更改on模式,还有时间格式改为本地
15、      更改apache的配置文件,达到解析php文件的目的
    [root@centos6 ~]# vim /usr/local/apache/conf/httpd.conf
 AddType application/x-compress .Z
 AddType application/x-gzip .gz .tgz
 Addtype application/x-httpd-php .php .phtml
     Addtype application/x-httpd-php-source .phps
添加上面绿色内容,表示apache服务中可以解析php格式文件
接下来要检查apache目录下生成的php动态连接库文件,在目录/usr/local/apache/modules,找到是否存在 libphp5.so文件
16、     验证
     [root@centos6 ~]# vim /usr/local/apache/htdocs/index.php
     添加内容为
<?php
    echo phpinfo();
?>
在客服端验证,出现下图说明php搭建成功
 
标签: CentOS LAMP
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • 用Xshell设置CentOS密钥登录
    用Xshell设置CentOS密钥登录
    今天带来设置X shell 密钥登录  因为用的中文x shell 所以按照中文设置很简单1.点击工具(Tools)------新建用户密钥生成向导(New User key Wizard)(附图)2.然后出现下图时,记得密钥类型 选择RSA.其实选择DSA ,也能实现,二者其实是不同的算法。(我用的R
    03-08
  • 如何在 CentOS 7 / RHEL 7 终端服务器上安装 KVM
    如何在 CentOS 7 / RHEL 7 终端服务器上安装 KV
    如何在 CnetOS 7 或 RHEL 7(Red Hat 企业版 Linux)服务器上安装和配置 KVM(基于内核的虚拟机)?如何在 CentOS 7 上设置 KVM 并使用云镜像 / cloud-init 来安装客户虚拟机?基于内核的虚拟机(KVM)是 CentOS 或 RHEL 7 的虚拟化软件。KVM 可以将你的服务
    03-08
  • centOS下安装Adobe Flash Player
    centOS下安装Adobe Flash Player
    centOS下安装Adobe Flash Player  2009-10-09 11:29:33|  分类:linux|  标签: |订阅 写出来就这么简单几步,当初刚接触Linux的时候搜索了很长时间,找了很多资料,总是出现这样那样的问题,最后终于摸索出最简单最有效的安装的方法。 随便打开一个带
    03-08
  • Red Hat Linux、rhel 和 Fedora Core 以及 Cent
    Red Hat Linux、rhel 和 Fedora Core 以及 Centos 区别与联系1. Red Hat LinuxLinux是GNU/Linux的缩写,通常指各种Linux发行版的通称,Red Hat Linux是redhat最早发行的个人版本的linux, 其1。0版本于1994年11月3日发行。虽然其历史不及其它linux发行
    02-10
  • CentOS 下的apache服务器配置与管理
    一、WEB服务器与Apache1、web服务器与网址2、Apache的历史3、补充http://www.netcraft.com/可以查看apache服务器的市场占有率同时必须注意的是ngnix,正处于强势增长的上升时期,大有和apache一争天下的感觉,真是后生可畏~~~二、Apache服务器的管理命令1、命
    02-10
  • 如何在Fedora或CentOS上使用Samba共享
    如何在Fedora或CentOS上使用Samba共享
    如今,无论在家里或者是办公场所,不同的电脑之间共享文件夹已不是什么新鲜事了。在这种趋势下,现代操作系统通过网络文件系统的方式使得电脑间数据的交换变得简单而透明。如果您工作的环境中既有微软的Windows又有Linux,那么,一个共享文件及目录的方式便是
    02-10
  • CentOS 6.9下KVM虚拟机网络Bridge(网桥)方式与NAT方式详解(转)
    CentOS 6.9下KVM虚拟机网络Bridge(网桥)方式
    摘要:KVM虚拟机网络配置的两种方式:NAT方式和Bridge方式。Bridge方式的配置原理和步骤。Bridge方式适用于服务器主机的虚拟化。NAT方式适用于桌面主机的虚拟化。NAT的网络结构图:Bridge的网络结构见图:一、Bridge方式问题客户机安装完成后,需要为其设置网
    02-10
  • 使用KVM的命令行方式安装centos7虚拟机
    使用KVM的命令行方式安装centos7虚拟机
    1.宿主机上已经安装KVM软件,参考网址:https://www.cnblogs.com/sanduzxcvbnm/p/15538881.html2.已经上传centos7镜像到宿主机里非必要前提条件,可做可不做1.kvm修改默认存储路径2.kvm设置桥接网络挂载U盘,把U盘里存放的iso系统镜像挂载到宿主机里[root@nkgt
    02-10
  • 部署Node.js项目(CentOS) node项目搭建
    部署Node.js项目(CentOS) node项目搭建
    操作步骤步骤 1:创建ECS实例选择操作系统为公共镜像CentOS7.2。使用root用户登录Linux实例。步骤2:部署Node.js环境—二进制文件安装该部署过程使用的安装包是已编译好的二进制文件,解压之后,在bin文件夹中就已存在node和npm,无需手工编译。安装步骤:1、
    02-10
  • centos安装python与jdk centos安装python3.7
    centos安装python与jdk centos安装python3.7
    安装python#压缩包安装[root@china ~]# yum -y install zlib*Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun
    02-10
点击排行