標籤:
由於這裡採用yum方式安裝,前提是我們必須配置好yum源。為了加快下載速度,建議使用網易的yum源。參考:CentOS配置網易163yum源 http://www.linuxidc.com/Linux/2014-07/104562.htm
這種方式對於初學者來說,非常方便,但是可定製性不強,而且軟體版本較低。一般用於實驗和學習環境。
CentOS 6.5安裝配置LAMP http://www.linuxidc.com/Linux/2014-07/104373.htm
Ubuntu 13.04 安裝 LAMP\Vsftpd\Webmin\phpMyAdmin 服務及設定 http://www.linuxidc.com/Linux/2013-06/86250.htm
CentOS 5.9下編譯安裝LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm
RedHat 5.4下Web伺服器架構之源碼構建LAMP環境及應用PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm
LAMP源碼環境搭建WEB伺服器Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm
基於Ubuntu 的LAMP 最佳化加固 http://www.linuxidc.com/Linux/2014-07/104092.htm
1、安裝Apache
[[email protected] ~]# yum -y install httpd
# 開機自啟動
[[email protected] ~]# chkconfig httpd on
# 啟動httpd 服務
[[email protected] ~]# service httpd start
### 安裝apache 一些擴充
[email protected] ~]# yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
現在直接在瀏覽器鍵入http://localhost 或 http://本機IP ,應該會看到Apache的測試頁面
這裡需要注意iptables的設定哦。
2、安裝配置MySQL
# mysql 用戶端程式
# mysql-server 服務端程式
# mysql-devel 開發設計的庫
[[email protected] ~]# yum -y install mysql mysql-server mysql-devel
# 開機啟動
[[email protected] ~]# chkconfig mysqld on
# 啟動mysqld服務
[[email protected] ~]# service mysqld start
# 進行一些安全性配置
[[email protected] ~]# /usr/bin/mysql_secure_installation
[[email protected] ~]# netstat -tulpn | grep -i mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1723/mysqld
OK, 我們看到mysqld已經啟動,監聽在3306連接埠上。
3、安裝php
安裝相關模組:為了讓PHP支援MySQL,我們可以安裝php-mysql軟體包;也可使用以下命令搜尋可用的php模組
[[email protected] ~]# yum -y install php php-mysql
# 安裝php常用擴充
[[email protected] ~]# yum search php
[[email protected] ~]# yum -y install gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap
### 重啟httpd服務,這一步很重要
[[email protected] ~]# service httpd restart
然後,我們提供php頁面,測試
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# vi index.php
<?php
phpinfo();
?>
然後,我們再次在瀏覽器鍵入http://localhost 或 http://本機IP ,應該會看到如下頁面
4、安裝配置phpMyAdmin
安裝好MySQL,Apache及PHP後,為了可視化的管理MySQL資料庫,我們可以安裝phpMyAdmin。到其官網下載最新版本:http://www.phpmyadmin.net/home_page/
在Windows下,其實Navicat也是一個非常好用的MySQL視覺化檢視,推薦使用。
[[email protected] ~]# unzip phpMyAdmin-4.2.6-all-languages.zip
[[email protected] ~]# mv phpMyAdmin-4.2.6-all-languages /var/www/html/phpmyadmin
[[email protected] ~]# cd /var/www/html/phpmyadmin
[[email protected] ~]# cp libraries/config.default.php config.inc.php
[[email protected] ~]# vi cnfig.inc.php
$cfg[‘PmaAbsoluteUri‘] = ‘‘;這裡填寫 phpMyAdmin 的訪問網址。
$cfg[‘Servers‘][$i][‘host‘] = ‘localhost‘; // MySQL hostname or IP address
$cfg[‘Servers‘][$i][‘port‘] = ‘‘; // MySQL port - leave blank for default port
$cfg[‘Servers‘][$i][‘user‘] = ‘root‘; // 填寫 MySQL 訪問 phpMyAdmin 使用的 MySQL 使用者名稱,預設為 root。
fg[‘Servers‘][$i][‘password‘] = ‘‘; // 填寫對應上述 MySQL 使用者名稱的密碼。
# 然後重啟,httpd服務
[[email protected] ~]# service httpd restart
在瀏覽器鍵入http://localhost/phpmyadmin 即可訪問。
如果遇到存取權限的問題, 請檢查SElinux。
1130mysql串連錯誤解決方案:
mysql -u root -p;
mysql>use mysql;
mysql>update user set host = ‘%‘ where user = ‘root‘;
mysql>select host, user from user;
完全卸載mysql方法:
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否還有mysql軟體:
rpm -qa|grep mysql
如果存在的話,繼續刪除即可。
CentOS 6.5使用yum快速搭建LAMP環境