Centos6.0 x64下搭建LAMP环境

 系统环境:Centos6.0 x64

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、编译安装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搭建成功

时间: 2024-08-01 02:16:31

Centos6.0 x64下搭建LAMP环境的相关文章

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

这篇文章主要介绍了系统环境: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

教你在64位CentOS 6.0下搭建LAMP环境

系统环境:Centos6.0 x64 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

CentOS6.2系统环境下部署LAMP环境步骤

最近买了创宇云的云服务器,准备拿来这折腾一下,用来学习centOS的相关知识,这里就记录一下centOS下部署lamp环境的步骤. 本机环境:CentOS6.2 32位 一般来说,在centOS下安装环境有两种方式,第一种是使用yum命令自动安装软件,第二种是下载源码包自己进行编译安装,这里主要介绍的是使用yum命令进行安装 1.安装apache 使用命令 yum install httpd,然后根据提示,最好输入Y同意安装即可. 安装完成后,使用 /ect/init.d/httpd start

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

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.

阿里云ECS CentOs7.3下搭建LAMP环境(Apache2.4 + Mysql5.7 + PHP5.6 + Laravel5.2)

硬件是阿里云服务器ECS,安装阿里云提供的系统Linux CentOs7.3.LAMP环境搭建,再安装Laravel5.2框架. 硬件没什么好说的,不是很懂,买就是了. 至于系统为什么选择CentOs? 因为CentOs是公认的,个人服务器最合适的系统. 为什么选择7.3版本? 两个原则: 1.选公认的最稳定版本CentOs6.5,可惜阿里云默认的没有提供: 2.选最新的版本,因为已经修复以前的bug. 现在开始吧! LAMP安装有顺序:先安装Apache或Mysql,最后安装PHP. 1.安装

详解CentOS5.5 下搭建 PHP 环境(最佳的LAMP环境)_Linux

本文详细阐述在 Linux 系统中搭建 PHP 环境,由于 PHP 就是由 C 语言编写的,最初也是运行在 Linux 系统中,所以Linux 是 PHP 的最佳环境. 关于本文中使用到的软件,请点击此链接下载. CentOS5.5现在官方已经不再提供,推荐大家使用centos6以上版本: centos6.8下载地址:http://www.jb51.net/softs/499124.html centos7.2下载地址:http://www.jb51.net/softs/499109.html

linux的ubuntu和centos下快速搭建LAMP环境

  在linux下安装lamp环境,下面为大家分别介绍在ubuntu和centos下面快速安装LAMP环境的方法. 首先,让我们了解一下什么是LAMP环境(一下摘自百度百科): Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台.随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成

在CentOS6.4中安装配置LAMP环境的详细步骤

原文:在CentOS6.4中安装配置LAMP环境的详细步骤 本文详细介绍了CentOS6.4系统中安装LAMP服务并对其进行配置的过程,即安装Apache+PHP+Mysql,参照了网上大神的设置,其他Linux发行系统可以参考~ 在本文中部分命令操作需要root权限,输入'su -'命令后输入密码即可切换root身份. 一.修改设置对安装做准备 1. 防火墙设置 设置/etc/sysconfig/iptables文件允许80端口和3306端口.因为80端口是http协议所使用的端口,如果防火墙

Centos7搭建LAMP环境(源码)

Centos7搭建LAMP环境(源码) 一.下载需要的软件源码 1. 下载Httpd,MySQL,PHP的源码安装包,选择自己需要的版本,后续的一些安装配置也是多数参考的官网的文档.链接地址:http://httpd.apache.org/,https://www.mysql.com/,http://www.php.net/. 2. 下图是我的主要安装源码包:(选择好你需要的版本和依赖我们就可以开始安装) 3. 下载所有需要的包后,上传到你的服务器. 4. 关闭防火墙和安全软件 二.Apache