CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

這篇“CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來(lái)看看這篇“CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法”文章吧。

我們提供的服務(wù)有:網(wǎng)站建設(shè)、做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、平魯ssl等。為上千余家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的平魯網(wǎng)站制作公司

一、簡(jiǎn)介

什么是lamp
lamp是一種web網(wǎng)絡(luò)應(yīng)用和開(kāi)發(fā)環(huán)境,是linux, apache, MySQL, php/perl的縮寫(xiě),每一個(gè)字母代表了一個(gè)組件,每個(gè)組件就其本身而言都是在它所代表的方面功能非常強(qiáng)大的組件。
lamp這個(gè)詞的由來(lái)最早始于德國(guó)雜志“c't magazine”,michael kunze在1990年最先把這些項(xiàng)目組合在一起創(chuàng)造了lamp的縮寫(xiě)字。這些組件并不是開(kāi)始就設(shè)計(jì)為一起使用的,但是,這些軟件都是開(kāi)源的,可以很方便的隨時(shí)獲得并免費(fèi)使用,這就導(dǎo)致了這些組件經(jīng)常在一起使用。這些組件的兼容性也在不斷完善,為了改善不同組件之間的協(xié)作,已經(jīng)創(chuàng)建了某些擴(kuò)展功能,在一起的應(yīng)用情形變得非常普便,因而成為目前最流行的web應(yīng)用基礎(chǔ)架構(gòu)。

lamp的組件
平臺(tái)由四個(gè)組件組成,呈分層結(jié)構(gòu),每一層都提供了整個(gè)架構(gòu)的一個(gè)關(guān)鍵部分:
linux:linux 處在最底層,提供操作系統(tǒng)。它的靈活性和可定制化的特點(diǎn)意味著它能夠產(chǎn)生一種高度定制的平臺(tái),讓其它組件在上面運(yùn)行。其它組件運(yùn)行于linux 之上,但是并不一定局限于 linux,也可以在 microsoft windows, mac os x 或 unix上運(yùn)行。
apache:apache位于第二層,它是一個(gè)web 服務(wù)平臺(tái),提供可讓用戶獲得 web 頁(yè)面的機(jī)制。apache 是一款功能強(qiáng)大、穩(wěn)定、可支撐關(guān)鍵任務(wù)的web服務(wù)器,internet 上超過(guò) 50% 的網(wǎng)站都使用它作為 web 服務(wù)器。
mysql:mysql 是最流行的開(kāi)源關(guān)系數(shù)據(jù)庫(kù)管理系統(tǒng),是lamp的數(shù)據(jù)存儲(chǔ)端。在 web 應(yīng)用程序中,所有帳戶信息、產(chǎn)品信息、客戶信息、業(yè)務(wù)數(shù)據(jù)和其他類型的信息都存儲(chǔ)于數(shù)據(jù)庫(kù)中,通過(guò) sql 語(yǔ)言可以很容易地查詢這些信息。
php/perl:perl是一種靈活的語(yǔ)言,特別是在處理文本要素的時(shí)候,這種靈活性使perl很容易處理通過(guò)cgi接口提供的數(shù)據(jù),靈活地運(yùn)用文本文件和簡(jiǎn)單數(shù)據(jù)庫(kù)支持動(dòng)態(tài)要素。php 是一種被廣泛應(yīng)用的開(kāi)放源代碼的多用途腳本語(yǔ)言,它可嵌入到 html中,尤其適合 web 開(kāi)發(fā)。可以使用 php 編寫(xiě)能訪問(wèn) mysql 數(shù)據(jù)庫(kù)中的數(shù)據(jù)和 linux 提供的一些特性的動(dòng)態(tài)內(nèi)容。

二、系統(tǒng)環(huán)境

系統(tǒng)平臺(tái):centos release 5.8 (final)

apache版本:httpd-2.2.9.tar.gz

mysql 版本:mysql-5.0.41.tar.gz

php版本:php-5.2.6.tar.gz

三、安裝前準(zhǔn)備

1、庫(kù)文件準(zhǔn)備

在安裝php之前,應(yīng)先安裝php5需要的最新版本庫(kù)文件,例如libxml2、libmcrypt以及gd2庫(kù)等文件。安裝gd2庫(kù)是為了讓php5支 持gif、png和jpeg圖片格式,所以在安裝gd2庫(kù)之前還要先安裝最新的zlib、libpng、freetype和jpegsrc等庫(kù)文件。而且中間還會(huì)穿插安裝一些軟件,讀者可以按照本節(jié)提供的順序安裝。

autoconf-2.61.tar.gz

freetype-2.3.5.tar.gz

gd-2.0.35.tar.gz

jpegsrc.v6b.tar.gz

libmcrypt-2.5.8.tar.gz

libpng-1.2.31.tar.gz

libxml2-2.6.30.tar.gz

zlib-1.2.3.tar.gz

zendoptimizer-3.2.6-linux-glibc21-i386.tar.gz

phpmyadmin-3.0.0-rc1-all-languages.tar.gz

2、安裝gcc、gcc-c++編譯器

用gcc -v 命令檢查安裝時(shí)使用的編譯工作是否存在

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

如系統(tǒng)未安裝,在系統(tǒng)聯(lián)網(wǎng)的情況下使用yum install gcc和yum install gcc-c++安裝

3、卸載默認(rèn)的低版本環(huán)境

目前發(fā)行的linux操作系統(tǒng)版本中,如果選擇默認(rèn)全部安裝,就已經(jīng)安裝了lamp環(huán)境,但是版本相對(duì)都比較低。我們可以再安裝一個(gè)lamp環(huán)境和原來(lái)的并存,但是這樣做沒(méi)有必要,因?yàn)橥瑫r(shí)只能開(kāi)啟一個(gè)lamp環(huán)境。所要我們要在安裝之前,先應(yīng)檢查一下系統(tǒng)中是否已經(jīng)安裝了低版本的環(huán)境,如果已經(jīng)安裝過(guò)了,停止原來(lái)的服務(wù)運(yùn)行,或者把原來(lái)的環(huán)境卸載掉。

a. 卸載apache

# rpm -qa | grep httpd

說(shuō)明:檢查是否安裝了httpd軟件包

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

# rpm -e httpd-2.2.3-63.el5.centos --nodeps

說(shuō)明:卸載軟件包, --nodeps 如果有連帶關(guān)系,也強(qiáng)制卸載

# cd /etc/httpd/

# rm -rf *

說(shuō)明:到原來(lái)的apache安裝目錄下,將其所有的安裝目錄和文件都刪掉

b. 卸載mysql

# rpm -qa | grep mysql

# rpm -e mysql-5.0.77-4.el5_4.2 --nodeps

說(shuō)明:卸載mysql

c. 卸載php

# rpm -qa | grep php

# rpm -e php-common-5.1.6-27.el5 --nodeps

# rpm -e php-ldap-5.1.6-27.el5 --nodeps

# rpm -e php-cli-5.1.6-27.el5 --nodeps

# rpm -e php-5.1.6-27.el5 --nodeps

說(shuō)明:卸載php

4、關(guān)閉selinux,清空防火墻規(guī)則

5、使用ssh shell將windows下的13個(gè)源碼包上傳到/usr/local/src

6、解包

編寫(xiě)一個(gè)shell腳本tar.sh進(jìn)行解包。

#!/bin/sh cd /usr/local/srcls *.tar.gz > ls.list for tar in `cat ls.list` dotar -zxvf $tardone

執(zhí)行腳本tar.sh進(jìn)行解包

7、將源碼包*.tar.gz全都刪除

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

四、安裝lamp

1、安裝libxml2

# cd /usr/local/src/libxml2-2.6.30
# ./configure --prefix=/usr/local/libxml2
# make && make install

2、安裝libmcrypt

# cd /usr/local/src/libmcrypt-2.5.8
# ./configure --prefix=/usr/local/libmcrypt
# make && make install

3、安裝zlib

# cd /usr/local/src/zlib-1.2.3
# ./configure
# make && make install

4、安裝libpng

# cd /usr/local/src/libpng-1.2.31
# ./configure --prefix=/usr/local/libpng
# make && make install

5、安裝jpeg6

這個(gè)軟件包安裝有些特殊,其它軟件包安裝時(shí)如果目錄不存在,會(huì)自動(dòng)創(chuàng)建,但這個(gè)軟件包安裝時(shí)需要手動(dòng)創(chuàng)建。

# 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 /usr/local/src/jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make && make install

6、安裝freetype

# cd /usr/local/src/freetype-2.3.5
# ./configure --prefix=/usr/local/freetype
# make
# make install

7、安裝autoconf

# cd /usr/local/src/autoconf-2.61
# ./configure
# make && make install

8、安裝gd庫(kù)

# cd /usr/local/src/gd-2.0.35
# ./configure \
--prefix=/usr/local/gd2/ \
--enable-m4_pattern_allow \
--with-zlib=/usr/local/zlib/ \
--with-jpeg=/usr/local/jpeg6/ \
--with-png=/usr/local/libpng/ \
--with-freetype=/usr/local/freetype/

# make

出現(xiàn)錯(cuò)誤:

make[2]: *** [gd_png.lo] error 1
make[2]: leaving directory `/usr/local/src/gd-2.0.35'
make[1]: *** [all-recursive] error 1
make[1]: leaving directory `/usr/local/src/gd-2.0.35'
make: *** [all] error 2

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

分析:這個(gè)問(wèn)題是因?yàn)間d庫(kù)中的gd_png.c這個(gè)源文件中包含png.h時(shí),png.h沒(méi)有找到導(dǎo)致的。

解決:

在編譯文件里

# vi gd_png.c

將include “png.h” 改成 include “/usr/local/libpng/include/png.h”

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

其中/usr/local/libpng/為libpng安裝路徑。

# make install

9、安裝apache

# cd /usr/local/src/httpd-2.2.9
# ./configure \
--prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-z=/usr/local/zlib \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support
# make && make install

10、配置apache

啟動(dòng)apache
# /usr/local/apache2/bin/apachectl start

關(guān)閉apache
# /usr/local/apache2/bin/apachectl stop

查看80端口是否開(kāi)啟
# netstat -tnl|grep 80

訪問(wèn)apache服務(wù)器

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

添加自啟動(dòng)
# echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local

11、安裝mysql

添加一個(gè)mysql標(biāo)準(zhǔn)組
# groupadd mysql

添加mysql用戶并加到mysql組中
# useradd -g mysql mysql

# cd /usr/local/src/mysql-5.0.41
# ./configure \
--prefix=/usr/local/mysql/ \
--with-extra-charsets=all

出現(xiàn)錯(cuò)誤:

checking for tgetent in -lncurses... no
checking for tgetent in -lcurses... no
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for termcap functions library... configure: error: no curses/termcap library found

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

分析:缺少ncurses安裝包

解決:

# yum install ncurses-devel

# make && make install

12、配置mysql

創(chuàng)建mysql數(shù)據(jù)庫(kù)服務(wù)器的配置文件
# cp support-files/my-medium.cnf /etc/my.cnf

用mysql用戶創(chuàng)建授權(quán)表,創(chuàng)建成功后,會(huì)在/usr/local/mysql目錄下生成一個(gè)var目錄
# /usr/local/mysql/bin/mysql_install_db --user=mysql

將文件的所有屬性改為root用戶
# chown -r root /usr/local/mysql

將數(shù)據(jù)目錄的所有屬性改為mysql用戶
# chown -r mysql /usr/local/mysql/var

將組屬性改為mysql組
# chgrp -r mysql /usr/local/mysql

啟動(dòng)數(shù)據(jù)庫(kù)
# /usr/local/mysql/bin/mysqld_safe --user=mysql &

查看3306端口是否開(kāi)啟
# netstat -tnl|grep 3306

簡(jiǎn)單的測(cè)試
# /usr/local/mysql/bin/mysqladmin version

查看所有mysql參數(shù)
# /usr/local/mysql/bin/mysqladmin variables

設(shè)置mysql開(kāi)機(jī)自啟動(dòng)
# cp /usr/local/src/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chown root.root /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list mysqld
# chkconfig --levels 245 mysqld off

13、mysql安全性設(shè)置

沒(méi)有密碼可以直接登錄本機(jī)服務(wù)器
# /usr/local/mysql/bin/mysql -u root

查看mysql用戶權(quán)限信息
mysql> select * from mysql.user;
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

刪除非localhost的主機(jī)
mysql> delete from mysql.user where host='localhost' and user='';
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

刷新授權(quán)表
mysql> flush privileges;
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

為root用戶添加密碼
mysql> set password for 'root'@'localhost' = password('abc123');
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

再次進(jìn)入mysql客戶端
# /usr/local/mysql/bin/mysql -u root -h localhost -p
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

關(guān)閉mysql數(shù)據(jù)庫(kù)
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

14、安裝php

# cd /usr/local/src/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-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/ \
--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
# make && make install

15、配置php

創(chuàng)建配置文件
# cp php.ini-dist /usr/local/php/etc/php.ini

使用vi編輯apache配置文件
# vi /etc/httpd/httpd.conf

添加這一條代碼
addtype application/x-httpd-php .php .phtml
CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

重啟apache
# /usr/local/apache2/bin/apachectl restart

以上安裝步驟可以寫(xiě)成一個(gè)shell script,詳細(xì)參考

16、安裝zend加速器

# cd /usr/local/src/zendoptimizer-3.2.6-linux-glibc21-i386/
# ./install.sh

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

17、安裝phpmyadmin

拷貝目錄到指定位置并改名為phpmyadmin

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

# cd /usr/local/apache2/htdocs/phpmyadmin/

# cp config.sample.inc.php config.inc.php

18、配置phpmyadmin

# vi /usr/local/apache2/htdocs/phpmyadmin/config.inc.php

將auth_type 改為http

$cfg['servers'][$i]['auth_type'] = 'http';

五、測(cè)試

1、編寫(xiě)info.php文件,查看php配置詳細(xì)

# vi /usr/local/apache2/htdocs/info.php

<?phpphpinfo();?>

通過(guò)瀏覽器訪問(wèn)http://10.0.0.154/info.php,獲得php的詳細(xì)配置信息

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

2、zend加速器信息

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

3、訪問(wèn)phpmyadmin

CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法

以上就是關(guān)于“CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

分享文章:CentOS6.3下源碼安裝LAMP運(yùn)行環(huán)境的方法
標(biāo)題鏈接:http://muchs.cn/article12/ihjegc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、軟件開(kāi)發(fā)網(wǎng)站內(nèi)鏈、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開(kāi)發(fā)公司