设为首页 收藏本站
查看: 934|回复: 0

64位CentOS 6.0下搭建LAMP环境

[复制链接]

尚未签到

发表于 2015-8-19 08:16:33 | 显示全部楼层 |阅读模式
  系统环境:Centos6.0 x64
  1、确认搭建LAMP所需要的环境是否已经安装

[iyunv@centos6 ~]# rpm -q make gcc gcc-c++ zlib-devel libaio
备注:安装libpng时候需要zlib-devel
             安装mysql时候需要libaio
2、如果没安装则yum安装
[iyunv@centos6 ~]# yum install make gcc gcc-c++ zlib-devel libaio -y
3、由于要使用编译安装,所以查看httpd、mysql、php是否安装,如果安装则卸载
[iyunv@centos6 ~]# rpm -q httpd mysql php
4、编译安装libxml2
注:libxml2是一个xml的c语言版的解析器,不仅支持c语言,还支持c++、php、Pascal、Ruby、Tcl等语言的绑定
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf libxml2-2.7.8.tar.gz
[iyunv@centos6 LAMP]# cd ./libxml2-2.7.8
[iyunv@centos6 libxml2-2.7.8]# ./configure  --prefix=/usr/local/libxml2/
[iyunv@centos6 libxml2-2.7.8]# make;make install
5、编译安装libmcrypt
注:libmcrypt是加密算法扩展库。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf libmcrypt-2.5.8.tar.gz
[iyunv@centos6 LAMP]# cd ./libmcrypt-2.5.8
[iyunv@centos6 libmcrypt-2.5.8]# ./configure  --prefix=/usr/local/libmcrypt/
[iyunv@centos6 libmcrypt-2.5.8]# make;make install
6、编译安装zlib
注:zlib是提供数据压缩用的函式库
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf zlib-1.2.5.tar.gz
[iyunv@centos6 LAMP]# cd ./zlib-1.2.5
[iyunv@centos6 zlib-1.2.5]# ./configure  --prefix=/usr/local/zlib/
[iyunv@centos6 zlib-1.2.5]# make ; make install
7、编译安装libpng
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf libpng-1.5.4.tar.gz
[iyunv@centos6 LAMP]# cd ./libpng-1.5.4
[iyunv@centos6 libpng-1.5.4]#
./configure --prefix=/usr/local/libpng/  --enable-shared
[iyunv@centos6 libpng-1.5.4]# make ; make install
8、编译安装jpeg
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf jpegsrc.v8c.tar.gz
[iyunv@centos6 LAMP]# cd ./jpeg-8c/
[iyunv@centos6 jpeg-8c]# mkdir /usr/local/jpeg/(创建jpeg软件的安装目录)
[iyunv@centos6 jpeg-8c]# mkdir /usr/local/jpeg/bin/(创建存放命令的目录)
[iyunv@centos6 jpeg-8c]# mkdir /usr/local/jpeg/lib/(创建jpeg库文件所在目录)
[iyunv@centos6 jpeg-8c]# mkdir /usr/local/jpeg/include/(创建存放头文件目录)
[iyunv@centos6 jpeg-8c]# mkdir -p /usr/local/jpeg/man/man1(建立存放手册的目录)
[iyunv@centos6 jpeg-8c]#
./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)
[iyunv@centos6 jpeg-8c]# make ; make install
9、编译安装freetype
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf freetype-2.4.6.tar.gz
[iyunv@centos6 LAMP]# cd ./freetype-2.4.6
[iyunv@centos6 freetype-2.4.6]#
./configure --prefix=/usr/local/freetype/ --enable-shared
[iyunv@centos6 freetype-2.4.6]# make ;make install
10、      编译安装autoconf
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf autoconf-2.68.tar.gz
[iyunv@centos6 LAMP]# cd ./autoconf-2.68
[iyunv@centos6 autoconf-2.68]# ./configure
[iyunv@centos6 autoconf-2.68]# make ; make install
11、      编译安装GD
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf gd-2.0.35.tar.gz
[iyunv@centos6 LAMP]# cd ./gd-2.0.35
[iyunv@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/
[iyunv@centos6 gd-2.0.35]# make ; make install
12、      安装apache
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf httpd-2.2.19.tar.gz
[iyunv@centos6 LAMP]# cd ./httpd-2.2.19
[iyunv@centos6 httpd-2.2.19]#
./configure --prefix=/usr/local/apache/ --enable-so --enable-rewrite
[iyunv@centos6 httpd-2.2.19]# make ; make install
[iyunv@centos6 LAMP]# /usr/local/apache/bin/apachectl start
[iyunv@centos6 LAMP]#
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[iyunv@centos6 LAMP]# chmod +x /etc/init.d/httpd
[iyunv@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
[iyunv@centos6 ~]# chkconfig --level 2345 httpd on
[iyunv@centos6 LAMP]# service httpd restart
开机自动启动apache的另一种方法:
修改/etc/rc.local文件
# vim /etc/rc.local
在文件中添加/usr/local/apache/bin/apachectl start
13、      编译安装mysql
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf mysql-5.5.15-linux2.6-x86_64.tar.gz
[iyunv@centos6 LAMP]# cd ./mysql-5.5.15-linux2.6-x86_64
[iyunv@centos6 mysql-5.5.15-linux2.6-x86_64]# groupadd mysql
[iyunv@centos6 mysql-5.5.15-linux2.6-x86_64]# useradd -r -g mysql mysql(创建mysql用户,并将用户指定至mysql组)
[iyunv@centos6 mysql-5.5.15-linux2.6-x86_64]# cd /usr/local/
[iyunv@centos6 local]# ln -s /tmp/LAMP/mysql-5.5.15-linux2.6-x86_64 mysql
[iyunv@centos6 local]# cd ./mysql/
[iyunv@centos6 mysql]# chown -R mysql .(将该目录的用户权限全部更改为mysql用户)
[iyunv@centos6 mysql]# chgrp -R mysql .(将该目录的用户组全部改为mysql用户组)
[iyunv@centos6 mysql]# ./scripts/mysql_install_db --user=mysql(将mysql目录的数据库使用权限指定为mysql)
[iyunv@centos6 mysql]# chown -R root .
[iyunv@centos6 mysql]# chown -R mysql data
[iyunv@centos6 mysql]# cp support-files/my-medium.cnf  /etc/my.cnf(将当前目录下的配置文件拷贝到系统配置文件下,并更名为my.cnf)
[iyunv@centos6 mysql]# cp support-files/mysql.server  /etc/init.d/mysqld
[iyunv@centos6 mysql]# chmod +x /etc/init.d/mysqld
[iyunv@centos6 mysql]# chkconfig --add mysqld
[iyunv@centos6 mysql]# chkconfig --level 345 mysqld on
[iyunv@centos6 mysql]# service mysqld restart
[iyunv@centos6 mysql]#
/usr/local/mysql/bin/mysqladmin -u root password '123456'(设置root用户登录mysql的密码)
[iyunv@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
[iyunv@centos6 LAMP]# pwd
/tmp/LAMP
[iyunv@centos6 LAMP]# tar -zxvf php-5.3.7.tar.gz
[iyunv@centos6 LAMP]# cd ./php-5.3.7
[iyunv@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
[iyunv@centos6 php-5.3.7]# make ; make install
[iyunv@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文件的目的
    [iyunv@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、     验证
     [iyunv@centos6 ~]# vim /usr/local/apache/htdocs/index.php
     添加内容为
<?php
    echo phpinfo();
?>
在客服端验证,出现下图说明php搭建成功

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-100880-1-1.html 上篇帖子: 在ubuntu搭建lamp环境 下篇帖子: Ubuntu分支Linux操作系统安装LAMP环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表