CentOS上yum安裝Apache套件

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*

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 ‘新密碼’ [引號內填密碼]

讓mysql數據庫更安全

複製內容到剪貼板

代碼:

mysql -u root -p [此時會要求你輸入剛剛設置的密碼,輸入後回車即可

mysql> DROP DATABASE test; [刪除test數據庫]

mysql> DELETE FROM mysql.user WHERE user = ”; [刪除匿名帳戶]

mysql> FLUSH PRIVILEGES; [重載權限]

5. 防火牆配置
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
鬱悶.請把上面複製到記事本里,然後把–state這段–改成小寫的,再操作.否則粘貼時會出現亂碼.
b.關閉防火牆{不推薦}.
service iptables stop
c.重置加載防火牆
service iptables restart

6. 安裝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’|

參考網站:http://www.fengyihot.com/blog/?p=169

 

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