總結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空防火牆規則


580、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/sh

cd/lamp

ls*.tar.gz>ls.list

forTARin`catls.list`

do

tar-zxvf$TAR

done


#chmod +x tar.sh

行腳本tar.sh行解包


9*.tar.gz全都

三、安裝過程:

cd/lamp/libxml2-2.6.30

./configure--prefix=/usr/local/libxml2/

make

makeinstall


cd/lamp/libmcrypt-2.5.8

./configure--prefix=/usr/local/libmcrypt/

make

makeinstall


cd/lamp/libmcrypt-2.5.8/libltdl

./configure--enable-ltdl-install

make

makeinstall


cd/lamp/zlib-1.2.3

./configure

make

makeinstall


cd/lamp/libpng-1.2.31

./configure--prefix=/usr/local/libpng/

make

makeinstall


mkdir/usr/local/jpeg6

mkdir/usr/local/jpeg6/bin

mkdir/usr/local/jpeg6/lib

mkdir/usr/local/jpeg6/include

mkdir-p/usr/local/jpeg6/man/man1

cd/lamp/jpeg-6b

./configure--prefix=/usr/local/jpeg6/--enable-shared--enable-static

make

makeinstall


cd/lamp/freetype-2.3.5

./configure--prefix=/usr/local/freetype/

make

makeinstall


cd/lamp/autoconf-2.61

./configure

make

makeinstall


cd/lamp/gd-2.0.35

./configure--prefix=/usr/local/gd2/--with-jpeg=/usr/local/jpeg6/--with-freetype=/usr/local/freetype/

make

makeinstall


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-support

make

makeinstall


/usr/local/apache2/bin/apachectlstart

echo"/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 apache

root      9696  0.0  0.0  3320   564 ?       S    Oct10   0:28 tail -f /var/log/apache2/error.log
www-data 10923  0.0  0.3 18964  2228 ?       S    02:05   0:00 /usr/sbin/apache2 -k start
www-data 10924  0.0  0.3 18964  2228 ?       S    02:05   0:00 /usr/sbin/apache2 -k start
www-data 10925  0.0  0.3 18964  2228 ?       S    02:05   0:00 /usr/sbin/apache2 -k start
ehuuhui  11333  0.0  0.5 10328  3532 pts/1    T    03:04  0:00 vi 001-eaa-apache

#kill -9 10923
#kill -9 10924

#kill -9 10925


/usr/local/apache2/bin/apachectl restart  ok


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-overwrite

make

makeinstall


groupaddmysql

useradd-gmysqlmysql

cd/lamp/mysql-5.0.41

./configure--prefix=/usr/local/mysql/--with-extra-charsets=all

make

makeinstall


cpsupport-files/my-medium.cnf/etc/my.cnf

/usr/local/mysql/bin/mysql_install_db--user=mysql

chown-Rroot/usr/local/mysql

chown-Rmysql/usr/local/mysql/var

chgrp-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/mysqld

chownroot.root/etc/rc.d/init.d/mysqld

chmod755/etc/rc.d/init.d/mysqld

chkconfig--addmysqld

chkconfig--listmysqld

chkconfig--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-sockets

make

makeinstall


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.ini

echo"Addtypeapplication/x-httpd-php.php.phtml">>/etc/httpd/httpd.conf

/usr/local/apache2/bin/apachectlrestart


2、配置mysql

cd /usr/local/mysql

bin/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 /lamp

cp -a phpMyAdmin-3.0.0-rc1-all-languages/usr/local/apache2/htdocs/phpMyAdmin

//到指定位置(站主目/usr/local/apache2/htdocs/phpMyAdmin下) cd /usr/local/apache2/htdocs/phpMyAdmin

cp 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.html

<html><body><h1>It works!</h1></body></html>

<?php

phpinfo();

?>

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章