紅旗5.0下apache+php+mysql+phpMyAdmin全攻略(轉)

BSDLite發表於2007-08-15
紅旗5.0下apache+php+mysql+phpMyAdmin全攻略(轉)[@more@]  轉貼

這是我在紅旗5.0上的apache+php+mysql+phpMyAdmin安裝過程。執行良好,目前未發現問題。

需要以下四個壓縮檔案:

mysql-standard-4.1.12-pc-linux-gnu-i686.tar.gz (下載地址http://dev.mysql.com/downloads/mysql/4.1.html

MySQL-client-4.1.14-0.i386.rpm (mysql客戶端) (下載地址http://dev.mysql.com/downloads/mysql/4.1.html

httpd-2.0.54.tar.gz (下載地址)

php-4.4.0.tar.gz (下載地址)

phpMyAdmin-2.5.7-pl1.tar.gz (下載地址)

將壓縮檔案都放在/root,

將mysql-standard-4.1.12-pc-linux-gnu-i686.tar.gz解壓,為方便,將資料夾重新命名為mysql。移動到/usr/local/(也可以在/usr/local建立個連結到/root/mysql)

[root@shunzi ~]#mv mysql /usr/local/mysql

這是二進位制的,不需要編譯,只需做一些相應的配置就可以使用了。

[root@shunzi ~]# groupadd mysql

[root@shunzi ~]# useradd -g mysql mysql

[root@shunzi ~]# cd /usr/local/mysql

[root@shunzi mysql]# scripts/mysql_install_db --user=mysql

[root@shunzi mysql]# chown -R root .

[root@shunzi mysql]# chown -R mysql data

[root@shunzi mysql]# chgrp -R mysql .

[root@shunzi mysql]# bin/mysqld_safe --user=mysql &



看到:

[1] 5134

[root@shunzi mysql]# Starting mysqld daemon with databases from /usr/local/mysql/data

STOPPING server from pid file /usr/local/mysql/data/shunzi.pid

030102 21:00:46 mysqld ended

提示啟動失敗了,這是由於許可權的問題,執行下列命令:

chown -R root /usr/local/mysql

chgrp -R mysql /usr/local/mysql

執行:

[root@shunzi mysql]# bin/mysqld_safe --user=root &

可以看到類似的內容:

[1] 5846

5846 pts/1 S 0:00 /bin/sh bin/mysqld_safe --user=root

5864 pts/1 S 0:00
/usr/local/mysql/bin/mysqld
--defaults-extra-file=/usr/local/mysql/data/my.cnf --ba

這說明mysql服務已經啟動了。mysql伺服器安裝成功了。如還不行,就再檢查mysql檔案的許可權。



接著安裝客戶端MySQL-client-4.1.14-0.i386.rpm,這個也直接雙擊安裝。執行:

[root@shunzi mysql]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

提示找不到介面檔案,藉口檔案在/tmp/mysql.sock,可建立一個軟連結:

[root@shunzi mysql]# mkdir /var/lib/mysql

[root@shunzi mysql]# cd /var/lib/mysql

[root@shunzi mysql]# ln -s /tmp/mysql.sock mysql.sock

執行:

[root@shunzi mysql]# mysql

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 11 to server version: 4.1.12-standard

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql>

說明客戶端可以與mysql伺服器連線上了;為了安全,接著給root 使用者設定密碼:

mysql> quit

Bye

[root@shunzi mysql]# cd /usr/local/mysql/bin

[root@shunzi bin]# mysqladmin -u root -h localhost password ******(換成你的密碼)



***********************************************************************************

安裝apache:

[root@shunzi ~]# tar xzvf httpd-2.0.54.tar.gz

[root@shunzi ~]# cd httpd-2.0.54

詳細的配置可以用 ./configure --help 來檢視,下面只是我的配置。

[root@shunzi httpd-2.0.54]#./configure --prefix=/usr/local/apache
--enable-shared=max --enable-module=rewrite --enable-module=most

[root@shunzi httpd-2.0.54]# make

[root@shunzi httpd-2.0.54]# make install

啟動apache服務:

[root@shunzi httpd-2.0.54]# /usr/local/apache/bin/apachectl start

在瀏覽器裡輸入,如果能看到歡迎頁面,那麼apache就安裝成功了。

***********************************************************************************

安裝php:

要先將apache停止:

[root@shunzi ~]# /usr/local/apache/bin/apachectl stop

[root@shunzi httpd-2.0.54]# /usr/local/apache/bin/apachectl stop

[root@shunzi php]# ./configure
--prefix=/usr/local/php --with-mysql=/usr/local/mysql
--with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars
--enable-ftp --enable-inline-optimization
--enable-trans-sid --with-xml --with-gd=/usr/local/gd
--with-png-dir=/usr/local/png --with-zlib-dir=/usr/local/zlibc
--with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype

(事先把png,zlibc,jpeg,freetype安裝到/usr/local/下,)



可以看到:

+--------------------------------------------------------------------+

|
License:
|

| This software is subject to the PHP License, available in this |

| distribution in the file LICENSE. By continuing this installation |

| process, you are bound by the terms of this license agreement. |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this
point.
|

+--------------------------------------------------------------------+

|
*** NOTE
***
|

| The
default for register_globals is now
OFF! |

|
|

| If your application relies on register_globals being ON, you |

| should explicitly set it to on in your php.ini
file.
|

| Note that you are strongly encouraged to
read
|

|
http://www.php.net/manual/en/security.globals.php
|

| about the implications of having register_globals set to on, and |

| avoid using it if
possible.
|

+--------------------------------------------------------------------+



Thank you for using PHP.



[root@shunzi php]#make

[root@shunzi php]#make install

複製php.ini-dist 到/usr/local/lib,並重新命名為php.ini。

[root@shunzi php]# cp php.ini-dist ../lib/php.ini



接下來對httpd.conf檔案進行簡單的配置,至於詳細的配置可參考其他資料。

開啟 /usr/local/apache/conf/httpd.conf

找到LoadModule php4_module modules/libphp4.so 一行,在下面新增

AddType application/x-httpd-php .php .phtml

找到DirectoryIndex index.html index.html.var ,在後面新增

index.php index.php3 index.phtml index.htm

使之支援php指令碼。

查詢DocumentRoot "/usr/local/apache/htdocs",將目錄更改為存放網頁內容的目錄。據我的經歷,單單改這個往往還不行,訪問時會出錯。

找到 ,改為 。這時再瀏覽就好了。

如果網站根目錄下有 index.* 的檔案,就自動瀏覽此檔案,如果沒有,就顯示網站的目錄。在網站沒有做好之前,我習慣讓其顯示目錄,這樣方便除錯。



為測試php是否正常工作,編輯一個phpinfo.php的檔案,內容如下:


phpinfo();

?>

用瀏覽器開啟此檔案。若看到php的配置資訊,則php正常。



安裝phpMyAdmin-2.5.7,

現在的最新版是2.6.4,但是本人安裝後發現資料庫的中文內容為亂碼,一時不知道如何解決,所以選擇了2.5.7,這個版本顯示中文是很好的。

將檔案解壓到網頁根目錄下,命名為phpMyAdmin,編輯其目錄下的config.inc.php檔案

$cfg['Servers'][$i]['port'] = '80'; (埠)

$cfg['Servers'][$i]['user'] = 'root';(使用者名稱)

$cfg['Servers'][$i]['password'] = ''; (密碼)

$cfg['PmaAbsoluteUri'] = '';(否則會出現警告要求你配置)

在瀏覽器中輸入就可以連線上了,預設是中文介面的。



至此,apache+php+mysql+phpMyAdmin安裝全部完成。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617542/viewspace-960232/,如需轉載,請註明出處,否則將追究法律責任。

相關文章