RedHatLinux9平台下搭建LAMP(Linux+Apache+Mysql+PHP)
RedHatLinux9平台下搭建LAMP
(Linux+Apache+Mysql+PHP)
一、安裝環境:
系統平台:Red Hat Linux9,內核2.4.20-8,文字界面(未安裝圖形界面)
硬體配置:
CPU:CM 1.8
RAM:128MB
DISK:40GB
二、軟體需求及下地地址:
1.Apache2.2.6
下載地址:http://apache.mirror.phpchina.com/httpd/httpd-2.2.6.tar.gz
2.Mysql5.0.45
下載以下rpm包:
MySQL-server-5.0.45-0.i386.rpm
MySQL-devel-5.0.45-0.i386.rpm
MySQL-client-5.0.45-0.i386.rpm
MySQL-shared-5.0.45-0.i386.rpm
下載地址:
server:
http://dev.mysql.com/get/Downloads/MySQL-5.0/MySQL-server-5.0.45-0.glibc23.i386.rpm/from/http://mysql.ntu.edu.tw/
devel:
http://dev.mysql.com/get/Downloads/MySQL-5.0/MySQL-devel-5.0.45-0.glibc23.i386.rpm/from/http://mysql.cs.pu.edu.tw/
client:
http://dev.mysql.com/get/Downloads/MySQL-5.0/MySQL-client-5.0.45-0.glibc23.i386.rpm/from/http://mysql.cdpa.nsysu.edu.tw/
shared:
http://dev.mysql.com/get/Downloads/MySQL-5.0/MySQL-shared-5.0.45-0.glibc23.i386.rpm/from/http://mysql.cdpa.nsysu.edu.tw/
此外,這個版本用文字界面安裝的話,有可能會缺一個perl組件:perl-DBI-1.32-5.i386.rpm,當你安裝Mysql的時候可能缺少這個依賴組件。或許有的人不會缺,不過在些還是提醒一下。。。
下載地址:
這個軟體一般在Red Hat Linux9 安裝盤的第二張盤裡面可以找到,如果手裡沒有安裝盤,那麼只能去百度上搜啦。
3. PHP5.2.4
下載地址:
http://cn.php.net/get/php-5.2.5.tar.bz2/from/hk.php.net/mirror
此外,如果安裝的版本是PHP5的話,那麼還需要對XML庫進行升級,因為系統自帶的版本可能較低,configure的時候有可能過不去的哦。
這就是說,安裝PHP5的話,要安裝一些必須的庫支持:
libxml2-2.6.19.tar.gz
下載地址:http://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.19.tar.gz
libxslt-1.1.15.tar.gz
下載地址:http://ftp.gnome.org/pub/GNOME/sources/libxslt/1.1/libxslt-1.1.15.tar.gz
curl-7.15.0.tar.gz
下載地址:http://curl.haxx.se/download/curl-7.15.0.tar.gz
4.一些常用的庫文件:
gd-2.0.33.tar.gz
下載地址:http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
freetype-2.2.1.tar.gz
下載地址:http://keihanna.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.10.tar.gz
jpegsrc.v6b.tar.gz
下載地址:http://www.ijg.org/files/jpegsrc.v6b.tar.gz
libpng-1.2.11.tar.gz
下載地址:http://nchc.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz
zlib-1.2.3.tar.gz
下載地址:http://www.zlib.net/zlib-1.2.3.tar.gz
三、安裝過程:
1.安裝前的準備工作:
把你所下載的軟體包全部放在同一個文件夾里,這樣的話裝起來比較文件,也便於管理。
如我就把所有軟體包放在/usr/local/src/下面,當然啦,大家放到別的目錄也成。一樣的。
這裡先說明一下大致的過程,先安裝Mysql(本人用的rpm軟體包一條命令搞定,源碼編繹的話也一樣,不過Mysql網站上的rmp包與源碼版本的更新幾乎是同時的,所以能省事就省事吧),然後安裝Apache 伺服器,弄完這個,就是一個一個的裝庫文件及一些雜七雜八的東西啦。最後安裝PHP及一些收尾工作。
1.Mysql的安裝:
進入你下載軟體包所在的文件夾
#rpm –ivh Mysql-*.rpm
或者你一個軟體包一個軟體包的裝,也行,不過這樣不是更簡單嘛。
如果你安裝的時候提示你缺少perl-DBI-1.32-5.i386.rpm支持的話,那麼,先把它裝上吧,到安裝盤的第二張盤裡面的RPMS文件夾中就可以找到。
先:#rpm –ivh perl-DBI-1.32-5.i386.rpm
然後再:#rpm –ivh Mysql-*.rpm
裝完沒有問題以後,Mysql也會隨之啟動的。
命令行下執行:
#mysql
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.04 sec)
這樣的話,證明你的Mysql已經安裝成功了。
這裡建議你安裝完Mysql后,給Mysql管理員設置一個密碼:
# mysqladmin -u root password 密碼。
2.Apache的安裝
# tar -zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6/
# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so
//這裡的—prefix指定apache的安裝將安裝到:/usr/local/apache目錄下,--sysconfdir指定apache配置文件httpd.conf安裝到:/etc/httpd目錄下。(這兩個路徑可以自己任意指定指定,但是自己一定要在安裝時記清楚,因為這個路徑後面還要用到)
# make
# make install
如果不出意外的話,successful!
啟動運行apache:
# /usr/local/apache/bin/apachectl start
然後在本機瀏覽器裡面輸入:http://127.0.0.1,回車,默認會顯示:it works字樣,證明apache已經在工作狀態中了。
如果沒有圖形界面的話,命令提示符下輸入:
# lynx http://127.0.0.1
效果一樣。
如果你想一開機就讓apache自動運行的話,那麼進行如下操作:
編輯etc/rc.d/rc.local
# vi /etc/rc.d/rc.local
在最後加上一句: /usr/local/apache/bin/apachectl start
看這裡的/usr/local/apache的安裝路徑用到了吧,所以大家裝的時候一定要記清楚哦。。。。
3.庫軟體包的安裝:
1).JPEG包
# tar xvzf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure
# mkdir –p /usr/local/man/man1(如果不建立這個目錄,那麼安裝的時候會發生錯誤的,找不到這個路徑,所以提前建好啦)
# make
# make install
# make install-lib
2).TTF(GD支持包)
# tar xvzf freetype-2.1.10.tar.gz
# cd free-10
# ./configure
# make
# make install
3).zlib包(lib png支持包)
# tar xvzf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make
# make install
4).libpng包(必須先安裝zlib包)
# tar xvzf libpng-1.2.8.tar.gz
# cd libpng-1.2.8
# cp scritp/makefile.gcmmx makefile(本身自帶makefile文件,無需configure,copy一下就OK了)
# make
# make install
5).GD包
# tar xvzf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure
# make
# make install
# cp gd.h /usr/local/lib/
6).xml包
# tar xvzf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# ./configure
# make
# make install
7). Libxslt包
# tar xvzf libxslt-1.1.15.tar.gz
# cd libxslt-1.1.15.tar.gz
# ./configure
# make
# make install
8) curl包
# tat xvzf curl-7.15.0.tar.gz
# cd curl-7.15.0
# ./configure
# make
# make install
4.PHP的安裝:
# tar xvjf php-5.2.5.tar.bz2(注意這個是bz2格式的!!!!)
# cd php-5.2.5
# ./configure --prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql
--with-libxml-dir
--with-png-dir
--with-jpeg-dir
--with-zlib
--with-freetype-dir
--with-gd
–-with-curl
--disable-debug
--enable-sockets
--enable-force-cgi-redirect
--with-config-file-path=/etc
--enable-magic-quotes
--enable-ftp
--enable-gd-native-ttf
-with-ttf --with-gdbm
--with-gettext
--with-iconv
--enable-mbstring=all
# make
# make instal
提示:如果一些圖形庫,例如gd庫在你configure時,失敗的話,那麼在--with-gd後面加上「-dir」也許就能過去。這樣做的目的是讓程序自己檢測其位置在哪裡。當然啦,如果你安裝這些圖形庫的時候指定了位置,在這裡指定的話也可以的。
到這裡PHP已經安裝完畢了。
5.收尾工作:
編輯apache的配置文件httpd.conf
vi /etc/httpd/httpd.conf
找到「#AddType application/x-gzip .gz .tgz
」
並在後面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
這兩行的目的是讓apache識別php。
再找到「DirectoryIndex index.html」
加上 index.php 讓它把index.php做為默認頁
6.測試環境:
在/usr/local/apache/htdocs/下面建立php文件。
# vi /usr/local/apache/htdocs/index.php
輸入:
<?
phpinfo();
?>
重啟apache伺服器
# /usr/local/apache/bin/apachectl restart
瀏覽器中輸入:http://127.0.0.1/index.php測試一下,激動的話面就出來嘍!!!!
如果小弟有什麼錯誤的地方,還希望大家能指出來。如果對此有疑問,請跟貼!!!
《解決方案》
有其他版本的么,redhat 9 太老了吧,3年前就沒用了,搞個as 4的配置看看,我的mysql只要裝5.0就沒成功過,現在還用4.1
《解決方案》
同志,libpng包出錯了啊
同志,libpng包出錯了啊
《解決方案》
cp php.ini-dist /usr/local/php/lib/php/php.ini
《解決方案》
# /usr/local/apache/bin/apachectl restart
httpd: apr_sockaddr_info_get() failed for mypalsky.com
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
怎麼解決摟主
《解決方案》
求救
我配置linux+apache+php+mysql+zend (源碼安裝)時,在安裝gd時候老是安裝不下去,具體代碼是:
make
cd . && /bin/sh /usr/local/src/gd2/config/missing --run aclocal-1.9 -I config
/usr/local/src/gd2/config/missing: line 46: aclocal-1.9: command not found
WARNING: `aclocal-1.9' is missing on your system. You should only need it if
you modified `acinclude.m4' or `configure.ac'. You might want
to install the `Automake' and `Perl' packages. Grab them from
any GNU archive site.
cd . && /bin/sh /usr/local/src/gd2/config/missing --run automake-1.9 --foreign
/usr/local/src/gd2/config/missing: line 46: automake-1.9: command not found
WARNING: `automake-1.9' is missing on your system. You should only need it if
you modified `Makefile.am', `acinclude.m4' or `configure.ac'.
You might want to install the `Automake' and `Perl' packages.
Grab them from any GNU archive site.
cd . && /bin/sh /usr/local/src/gd2/config/missing --run autoconf
configure.ac:28: error: Autoconf version 2.58 or higher is required
aclocal.m4:7870: AM_INIT_AUTOMAKE is expanded from...
configure.ac:28: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
make: *** Error 1
《解決方案》
原帖由 smilecat 於 2007-11-20 08:47 發表 http://linux.chinaunix.net/bbs/images/common/back.gif
有其他版本的么,redhat 9 太老了吧,3年前就沒用了,搞個as 4的配置看看,我的mysql只要裝5.0就沒成功過,現在還用4.1
看看這裡的mysql安裝過程是否能助能成功安裝mysql-5.0.45
http://bbs.chinaunix.net/thread-987344-1-1.html
《解決方案》
LAMP中的mysql如果不用rpm包而用Tarball源代碼編譯如何做,我在安裝mqsql時總是在生成mysql.sock文件時出問題。
《解決方案》
使勁頂。。。。。。。。。。。。。。。