您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > centos下搭建LAMP环境
1、确认搭建LAMP所需要的环境是否已经安装[root@centos6~]#rpm-qmakegccgcc-c++zlib-devellibaio备注:安装libpng时候需要zlib-devel安装mysql时候需要libaio2、如果没安装则yum安装[root@centos6~]#yuminstallmakegccgcc-c++zlib-devellibaio-y3、由于要使用编译安装,所以查看httpd、mysql、php是否安装,如果安装则卸载[root@centos6~]#rpm-qhttpdmysqlphp4、编译安装libxml2注:libxml2是一个xml的c语言版的解析器,不仅支持c语言,还支持c++、php、Pascal、Ruby、Tcl等语言的绑定[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvflibxml2-2.7.8.tar.gz[root@centos6LAMP]#cd./libxml2-2.7.8[root@centos6libxml2-2.7.8]#./configure--prefix=/usr/local/libxml2/[root@centos6libxml2-2.7.8]#make;makeinstall5、编译安装libmcrypt注:libmcrypt是加密算法扩展库。支持DES,3DES,RIJNDAEL,Twofish,IDEA,GOST,CAST-256,ARCFOUR,SERPENT,SAFER+等算法。[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvflibmcrypt-2.5.8.tar.gz[root@centos6LAMP]#cd./libmcrypt-2.5.8[root@centos6libmcrypt-2.5.8]#./configure--prefix=/usr/local/libmcrypt/[root@centos6libmcrypt-2.5.8]#make;makeinstall6、编译安装zlib注:zlib是提供数据压缩用的函式库[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvfzlib-1.2.5.tar.gz[root@centos6LAMP]#cd./zlib-1.2.5[root@centos6zlib-1.2.5]#./configure--prefix=/usr/local/zlib/[root@centos6zlib-1.2.5]#make;makeinstall7、编译安装libpng[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvflibpng-1.5.4.tar.gz[root@centos6LAMP]#cd./libpng-1.5.4[root@centos6libpng-1.5.4]#./configure--prefix=/usr/local/libpng/--enable-shared[root@centos6libpng-1.5.4]#make;makeinstall8、编译安装jpeg[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvfjpegsrc.v8c.tar.gz[root@centos6LAMP]#cd./jpeg-8c/[root@centos6jpeg-8c]#mkdir/usr/local/jpeg/(创建jpeg软件的安装目录)[root@centos6jpeg-8c]#mkdir/usr/local/jpeg/bin/(创建存放命令的目录)[root@centos6jpeg-8c]#mkdir/usr/local/jpeg/lib/(创建jpeg库文件所在目录)[root@centos6jpeg-8c]#mkdir/usr/local/jpeg/include/(创建存放头文件目录)[root@centos6jpeg-8c]#mkdir-p/usr/local/jpeg/man/man1(建立存放手册的目录)[root@centos6jpeg-8c]#./configure--prefix=/usr/local/jpeg/--enable-shared--enable-static(建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)[root@centos6jpeg-8c]#make;makeinstall9、编译安装freetype[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvffreetype-2.4.6.tar.gz[root@centos6LAMP]#cd./freetype-2.4.6[root@centos6freetype-2.4.6]#./configure--prefix=/usr/local/freetype/--enable-shared[root@centos6freetype-2.4.6]#make;makeinstall10、编译安装autoconf[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvfautoconf-2.68.tar.gz[root@centos6LAMP]#cd./autoconf-2.68[root@centos6autoconf-2.68]#./configure[root@centos6autoconf-2.68]#make;makeinstall11、编译安装GD[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvfgd-2.0.35.tar.gz[root@centos6LAMP]#cd./gd-2.0.35[root@centos6gd-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@centos6gd-2.0.35]#make;makeinstall12、安装apache[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvfhttpd-2.2.19.tar.gz[root@centos6LAMP]#cd./httpd-2.2.19[root@centos6httpd-2.2.19]#./configure--prefix=/usr/local/apache/--enable-so--enable-rewrite[root@centos6httpd-2.2.19]#make;makeinstall[root@centos6LAMP]#/usr/local/apache/bin/apachectlstart[root@centos6LAMP]#cp/usr/local/apache/bin/apachectl/etc/init.d/httpd[root@centos6LAMP]#chmod+x/etc/init.d/httpd[root@centos6~]#chkconfig--addhttpd注意:如果提示servicehttpddoesnotsupportchkconfig错误解决办法:编辑/etc/rc.d/init.d/httpd在文件第二行加入#chkconfig:23451090#description:Activates/DeactivatesApacheWebServer[root@centos6~]#chkconfig--level2345httpdon[root@centos6LAMP]#servicehttpdrestart开机自动启动apache的另一种方法:修改/etc/rc.local文件#vim/etc/rc.local在文件中添加/usr/local/apache/bin/apachectlstart13、编译安装mysql[root@centos6LAMP]#pwd/tmp/LAMP[root@centos6LAMP]#tar-zxvfmysql-5.5.15-linux2.6-x86_64.tar.gz[root@centos6LAMP]#cd./mysql-5.5.15-linux2.6-x86_64[root@centos6mysql-5.5.15-linux2.6-x86_64]#groupaddmysql[root@centos6mysql-5.5.15-linux2.6-x86_64]#useradd-r-gmysqlmysql(创建mysql用户,并将用户指定至mysql组)[root@centos6mysql-5.5.15-linux2.6-x86_64]#cd/usr/local/[root@centos6local]#ln-s/tmp/LAMP/mysql-5.5.15-linux2.6-x86_64mysql[root@centos6local]#cd./mysql/[root@centos6mysql]#chown-Rmysql.(将该目录的用户权限全部更改为mysql用户)[root@centos6mysql]#chgrp-Rmysql.(将该目录的用户组全部改为mysql用户组)[root@centos6mysql]#./scripts/mysql_install_db--user=mysql(将mysql目录的数据库使用权限指定为mysql)[root@centos6mysql]#chown-Rroot.[root@centos6mysql]#chown-Rmysqldata[root@centos6mysql]#cpsupport-files/my-medium.cnf/etc/my.cnf(将当前目录下的配置文件拷贝到系统配置文件下,并更名为my.cnf)[root@centos6mysql]#cpsupport-files/mysql.server/etc/init.d/mysqld[root@centos6mysql]#chmod+x/etc/init.d/mysqld[root@centos6mysql]#chkconfig--addmysqld[root@centos6mysql]#chkconfig--level345mysqldon[root@centos6mysql]#servicemysqldrestart[root@centos6mysql]#/usr/local/mysql/bin/mysqladmin-urootpassword'123456'(设置root用户登录mysql的密码)[root@centos6mysql]#/usr/local/mysql/bin/mysql-uroot–p(进入并访问mysql数据)Enterpassword:WelcometotheMySQLmonitor.Commandsendwith;org.YourMySQLconnectionidis2Serverversion:5.5.15-logMySQLCommunityServer(GPL)Copyright(c)2000,2010,Oracleand/oritsaffiliates.Allrightsreserved.Oracleisaregisteredtra
本文标题:centos下搭建LAMP环境
链接地址:https://www.777doc.com/doc-2904235 .html