CentOS 5.3上yum安裝Apache+php+Mysql+phpMyAdmin
一、系統下載
CentOS 開發社區發行了新的 5.3 版本。CentOS 5.3 基於 Red Hat Enterpris Linux 5.3.0,其中包括 Kernel 2.6.18、Apache 2.2、PHP 5.1.6、MySQL 5.0、PostgreSQL 8、GNOME 2.16、KDE 3.5、OpenOffice.org 2.3、Firefox 3.0、Evolution 2.12 等等。此外,CentOS 5.3 更新了美工設計,並根據使用者的請求恢複了 Contrib 倉庫。
CentOS 5.3 支援 i386 及 x86_64 架構,其 ISO 映像可從以下地址擷取。
isoredirect.centos.org/centos/5
/isos/
二、系統安裝
安裝CentOS 5.3是做伺服器,所以沒有用的,一概不裝;具體哪些不裝,自己看著辦吧:)
三、安裝、配置Apache+php+Mysql
Centos 裡的 yum 線上安裝很慢.以下是替換為中國CentOS鏡像伺服器!
中國官方鏡像網站: http://centos.ustc.edu.cn/
引用:
/* 使用說明 */
cd /etc/yum.repos.d[進入yum.repos.d目錄]
mv CentOS-Base.repo CentOS-Base.repo.save[修改源檔案名稱備份]
wget http://centos.ustc.edu.cn/CentOS-Base.repo.5[下載]
mv CentOS-Base.repo.5 CentOS-Base.repo[下載後的檔案更名]
1. 更新系統核心到最新.
引用:
yum -y update
系統更新後,如果yum安裝時提示錯誤資訊,請執行以下命令修複.
引用:
rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*
2. 安裝Apahce, PHP, Mysql, 以及php串連mysql庫組件
引用:
yum -y install httpd php mysql mysql-server php-mysql
//安裝mysql擴充
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
//安裝php的擴充
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
//安裝apache擴充
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
一次性粘貼安裝:
引用:
yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
3. 啟動服務配置
引用:
/sbin/chkconfig httpd on [設定apache為自啟動]
/sbin/chkconfig –-add mysqld [mysql服務]
/sbin/chkconfig mysqld on [mysqld服務]
/sbin/service httpd start [自啟動 httpd 服務]
/sbin/service mysqld start [自啟動mysqld服務]
4.設定mysql資料庫root帳號密碼。
引用:
mysqladmin -u root password ‘新密碼’ [引號內填密碼]
5.讓mysql資料庫更安全
引用:
mysql -u root -p [此時會要求你輸入剛剛設定的密碼,輸入後斷行符號即可
mysql> DROP DATABASE test; [刪除test資料庫]
mysql> DELETE FROM mysql.user WHERE user = ”; [刪除匿名帳戶]
mysql> FLUSH PRIVILEGES; [重載許可權]
按照以上的安裝方式, 配置出來的預設網站目錄為/var/www/html/建立一個php指令碼:
引用:
<?php
phpinfo();
?>
6. 防火牆配置
引用:
a.添加.允許訪問連接埠{21: ftp, 80: http}.
iptables -I RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
b.儲存
service iptables save
c.重設載入防火牆
service iptables restart
7. 安裝phpMyAdmin進入phpMyAdmin官方下載最新版本後,上傳到你的網站目錄下,然後進行配置。只需幾步即可搞定。
引用:
a. config.sample.inc.php更名為config.inc.php;
b. 開啟config.inc.php檔案,進行以下修改;
// $cfg['Servers'][$i]['controluser'] = ‘pma’;
// $cfg['Servers'][$i]['controlpass'] = ‘pmapass’;
// $cfg['Servers'][$i]['pmadb'] = ‘phpmyadmin’;
// $cfg['Servers'][$i]['bookmarktable'] = ‘pma_bookmark’;
// $cfg['Servers'][$i]['relation'] = ‘pma_relation’;
// $cfg['Servers'][$i]['table_info'] = ‘pma_table_info’;
// $cfg['Servers'][$i]['table_coords'] = ‘pma_table_coords’;
// $cfg['Servers'][$i]['pdf_pages'] = ‘pma_pdf_pages’;
// $cfg['Servers'][$i]['column_info'] = ‘pma_column_info’;
// $cfg['Servers'][$i]['history'] = ‘pma_history’;
// $cfg['Servers'][$i]['designer_coords'] = ‘pma_designer_coords’;
去掉每行前面的//;
c.$cfg['blowfish_secret'] = ”; |修改為| $cfg['blowfish_secret'] = ‘http’;
d.$cfg['Servers'][$i]['controluser'] = ‘pma’; |把’pma’修改為你的帳號|
e.$cfg['Servers'][$i]['controlpass'] = ‘pmapass’; |把’pmapass設定為你的mysql登入密碼|
f. $cfg['blowfish_secret'] = ”; | 添加短語密碼例如:$cfg['blowfish_secret'] = ‘onohot’|