tongy 发表于 2013-7-22 09:29:22

总结CentOS 6.0下搭建LAMP环境(源码安装)

一、搭建环境:(事先可以先yumgroupinstall “Development Tools”)1、CentOS6.0虚拟机(最小安装)2、SecureCRT (yum install lrzsz)
二、准备工作:1、源码包

2、安装gcc、gcc-c++编译器(yum安装)
若虚拟机能联网,直接输入命令yum installgcc和yum install gcc-c++;若不能联网,将centos光盘镜像挂载上,修改yum的本地源,使机器从本地源yum方式安装
3、检查机器上是否已经安装了mysql、php、apache,使用命令rpm -qa mysql。若安装了,则使用命令rpm -e 包的全名--nodeps卸载4、关闭selinux,清空防火墙规则
5、开放80、3306、22端口因为默认情况下,防火墙的80、3306、22端口是关闭的,这样的话对于客户机访问虚拟机上的web,会出现访问不到的现象。所以要开启。serviceiptables stop#/sbin/iptables-I INPUT -p tcp --dport 80 -j ACCEPT //那是大写的英文字母I,不是数字1
#/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT然后保存:
#/etc/rc.d/init.d/iptables save重启防火墙serviceiptables restart
6、在linux下建立目录lamp,存放上传的源码
7.将源码包放到lamp下
8、解包因为包很多,这里编写shell脚本/lamp/tar.sh进行解包#vi tar.sh#!/bin/shcd/lampls*.tar.gz>ls.listforTARin`catls.list`dotar-zxvf$TARdone
#chmod +x tar.sh执行脚本tar.sh进行解包
9、将源码包*.tar.gz全都删除三、安装过程:cd/lamp/libxml2-2.6.30./configure--prefix=/usr/local/libxml2/makemakeinstall
cd/lamp/libmcrypt-2.5.8./configure--prefix=/usr/local/libmcrypt/makemakeinstall
cd/lamp/libmcrypt-2.5.8/libltdl./configure--enable-ltdl-installmakemakeinstall
cd/lamp/zlib-1.2.3./configuremakemakeinstall
cd/lamp/libpng-1.2.31./configure--prefix=/usr/local/libpng/makemakeinstall
mkdir/usr/local/jpeg6mkdir/usr/local/jpeg6/binmkdir/usr/local/jpeg6/libmkdir/usr/local/jpeg6/includemkdir-p/usr/local/jpeg6/man/man1cd/lamp/jpeg-6b./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-staticmakemakeinstall
cd/lamp/freetype-2.3.5./configure--prefix=/usr/local/freetype/makemakeinstall
cd/lamp/autoconf-2.61./configuremakemakeinstall
cd/lamp/gd-2.0.35./configure--prefix=/usr/local/gd2/--with-jpeg=/usr/local/jpeg6/--with-freetype=/usr/local/freetype/makemakeinstall
cd/lamp/httpd-2.2.9./configure--prefix=/usr/local/apache2/--sysconfdir=/etc/httpd/--with-included-apr--disable-userdir--enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--enable-static-supportmakemakeinstall
/usr/local/apache2/bin/apachectlstartecho"/usr/local/apache2/bin/apachectlstart">>/etc/rc.d/rc.sysinit

pache启动报错(98)Address already in use:make_sock: could not bind to...解决方法:ps -aux | grep apacheroot      96960.00.03320   564 ?       S    Oct10   0:28 tail -f /var/log/apache2/error.log
www-data 109230.00.3 189642228 ?       S    02:05   0:00 /usr/sbin/apache2 -k start
www-data 109240.00.3 189642228 ?       S    02:05   0:00 /usr/sbin/apache2 -k start
www-data 109250.00.3 189642228 ?       S    02:05   0:00 /usr/sbin/apache2 -k start
ehuuhui113330.00.5 103283532 pts/1    T    03:040:00 vi 001-eaa-apache

#kill -9 10923
#kill -9 10924#kill -9 10925
/usr/local/apache2/bin/apachectl restartok了
httpd: Could not reliably determine the server'sfully qualified domain name, using 127.0.0.1 for ServerName

解决办法非常简单:

#vim /etc/httpd/httpd.conf找到#ServerName www.example.com:80   把#去掉,再重启apache即可没事了。

cd/lamp/ncurses-5.6./configure--with-shared--without-debug--without-ada--enable-overwritemakemakeinstall
groupaddmysqluseradd-gmysqlmysqlcd/lamp/mysql-5.0.41./configure--prefix=/usr/local/mysql/--with-extra-charsets=allmakemakeinstall
cpsupport-files/my-medium.cnf/etc/my.cnf/usr/local/mysql/bin/mysql_install_db--user=mysqlchown-Rroot/usr/local/mysqlchown-Rmysql/usr/local/mysql/varchgrp-Rmysql/usr/local/mysql
/usr/local/mysql/bin/mysqld_safe--user=mysql&
cp/lamp/mysql-5.0.41/support-files/mysql.server/etc/rc.d/init.d/mysqldchownroot.root/etc/rc.d/init.d/mysqldchmod755/etc/rc.d/init.d/mysqldchkconfig--addmysqldchkconfig--listmysqldchkconfig--levels245mysqldoff
cd/lamp/php-5.2.6./configure--prefix=/usr/local/php/--with-config-file-path=/usr/local/php/etc/--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql/--with-libxml-dir=/usr/local/libxml2/--with-jpeg-dir=/usr/local/jpeg6/--with-freetype-dir=/usr/local/freetype/--with-gd=/usr/local/gd2/--with-mcrypt=/usr/local/libmcrypt/--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-soap--enable-mbstring=all--enable-socketsmakemakeinstall
出现libltdl.so.3:cannotopen shared object file:No such file or directory执行ln -s /usr/local/lib/libltdl.so.3/usr/lib/libltdl.so.3即可
cpphp.ini-dist/usr/local/php/etc/php.iniecho"Addtypeapplication/x-httpd-php.php.phtml">>/etc/httpd/httpd.conf/usr/local/apache2/bin/apachectlrestart
2、配置mysqlcd /usr/local/mysqlbin/mysqladmin version//简单的测试bin/mysqladmin varibles//查看所有mysql参数bin/mysql -u root//没有密码可以直接登录本机服务器mysql> DELETE FROM mysql.userWHERE Host='localhost' AND User='';mysql> FLUSH PRIVILEGES;mysql> SET PASSWORD FOR'root'@'localhost' = PASSWORD('123456');
3、安装zend加速器
mkdir /usr/local/php/etc
cp php.ini-dist /usr/local/php/etc/php.ini //更改之前设定的php.ini的配置文件位置,安装zend要用
进入Zend包的目录
./install-tty
4、phpmyadmin的安装与配置
cd /lampcp -a phpMyAdmin-3.0.0-rc1-all-languages/usr/local/apache2/htdocs/phpMyAdmin//拷贝目录到指定位置(网站主目录/usr/local/apache2/htdocs/phpMyAdmin下) cd /usr/local/apache2/htdocs/phpMyAdmincp config.sample.inc.phpconfig.inc.php
进入/usr/local/apache2/htdocs/phpMyAdmin修改配置文件config.inc.php,将$cfg['blowfish_secret'] = '' 空格处填上登录phpmyadmin的密码,例如:$cfg['blowfish_secret'] ='123456'
测试
登入名称:root密码:123456
测试成功
php测试脚本cd /usr/local/apache2/htdocs/vi index.htmlIt works!
mv index.html index.php
整合apache和php
vi /etc/httpd/httpd.conf修改apache的配置文件,添加:
AddType application/x-httpd-php.php
AddTypeapplication/x-httpd-php-source .phps
注意将这两行添加在其它AddType后面,确保文件中有下面一段,如果没有的话就添加在所有LoadModule之后
LoadModule php5_module       modules/libphp5.so
找到DirectoryIndex index.html 这一行,在其后面写上index.php
保存退出
apachectl restart重启apache现在可以测试一下了测试显示apache和php运行正常完成搭建lamp

搜诶符合你 发表于 2013-7-22 20:29:50

如果有一双眼睛陪我一同哭泣,就值得我为生命受苦。

神甫 发表于 2013-7-23 00:10:09

沙发!沙发!

寂寞大萝卜 发表于 2013-7-23 05:29:53

丑,但是丑的特别,也就是特别的丑!

菜蜂 发表于 2013-7-23 08:31:39

长大了娶唐僧做老公,能玩就玩一玩,不能玩就把他吃掉。

云深处 发表于 2013-7-23 14:31:02

为中华而努力读书!一包中华好多钱啊~~~

大湖之子 发表于 2013-7-24 04:32:53

我是来刷分的,嘿嘿
页: [1]
查看完整版本: 总结CentOS 6.0下搭建LAMP环境(源码安装)