Cen OS6 系統(tǒng)下安裝LAMP

一、個別電腦可能有防火墻限制導(dǎo)致不能安裝

查看防火墻關(guān)閉狀態(tài)service iptables status

1關(guān)閉防火墻-----service iptables stop

2啟動防火墻-----service iptables start

3重啟防火墻-----service iptables restart

4查看防火墻狀態(tài)--service iptables status

5永久關(guān)閉防火墻--chkconfig iptables off

6永久關(guān)閉后啟用--chkconfig iptables on

二、開始安裝MySQL

1、安裝

#? yum install ?mysql mysql-server

2 、設(shè)置mysql 開機(jī)自啟動

#? chkconfig--levels 235 mysqld ?on ?/etc/init.d/mysqld start

3、設(shè)置mysql密碼

?? 1>知道初始密碼? 通過登錄mysql系統(tǒng),

# mysql -u root -p? password:

【輸入原來的密碼】

# use mysql;

# update user set password=password("test") where user='root';

#? flush privileges;

#? exit;

?? 2>忘記原來的myql的root的密碼;

查看下mysql狀態(tài)

# /etc/init.d/mysqld status

如果正在運(yùn)行狀態(tài)下 那么請首先關(guān)閉掉

# /etc/init.d/mysqld stop然后

跳過驗證

# mysqld_safe --skip -grant -tables

這時已經(jīng)跳過驗證直接 進(jìn)入mysql

# mysql

進(jìn)入mysql系統(tǒng)數(shù)據(jù)庫:

# use mysql

修改root賬戶密碼:

# update user set password=password("12345") where user="root";

刷新權(quán)限:

# flush privileges;

退出

# exit啟動mysql:

# /etc/init.d/mysqld start

進(jìn)入mysql

# mysql -u root -p 12345

三、安裝Apache2

1、安裝

# yum install? httpd

2配置系統(tǒng)在引導(dǎo)時啟動

# chkconfig--levels 235 httpd on

3、啟動Apache

# ?/etc/init.d/httpdstart

然后瀏覽器輸入 http://127.0.0.1或者 服務(wù)器的域名 ?? 你應(yīng)該看到Apache2的測試頁:

注意

Apache的默認(rèn)文檔根目錄是在CentOS上的/var/www/html 目錄 ,

配置文件是/etc/httpd/conf/httpd.conf

四、安裝PHP

1我們可以用下面的命令來安裝PHP? php55w 表示安裝php5.5版本 根據(jù)自己需求更改

# yum install php55w

安裝完需要重啟

# /etc/init.d/httpd restart

測試在根目錄中創(chuàng)建

# vi /var/www/html/info.php

然后瀏覽器訪問例如http://127.0.0.1/info.php? 或者h(yuǎn)ttp://域名/index.php顯示index.php 內(nèi)容就表示完成了

設(shè)置php mysql支持? 安裝的php-mysql軟件

# yum install ?php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xmlphp-xmlrpc

重新啟動Apache2的:

# /etc/init.d/httpd restart

五、安裝phpMyAdmin(注意下載的phpMyAdmin 支持的php 版本 和mysql版本)

下載phpMyAdmin 文件 然后將文件包放在 /var/www/html文件夾下如果php環(huán)境沒問題的話應(yīng)該能通過http://127.0.0.1/phpMyAdmin/訪問了 內(nèi)部具體的權(quán)限設(shè)置可以自行查閱資料

六、錯誤解決方法

1、出現(xiàn)缺少包的錯誤解決方法

查看以下的包是不是全部安裝完成

httpd??? httpd-devel ?? php55w ?? php55w-devel???? php55w-mysql??? mysqld-server?? mysql??? mysql-server

如果缺少那個重新安裝那個

一鍵安裝所需的所有包(php55w 是php5.5 版本具體根據(jù)自己使用版本而定)

使用前先移除服務(wù)器上的各種包

#? yum -y remove httpd httpd-devel php55w php55w-devel php55w-mysql mysqld55w-server mysql55w mysql55w-server

安裝

#? yum -yinstall httpd httpd-devel php55w php55w-devel php55w-mysql mysqld55w-servermysql55w mysql55w-server

2、出現(xiàn) yum安裝出現(xiàn) Error: xz compression not available

解決方法:

參考這個帖子https://my.oschina.net/iceTear/blog/1162681

3、phpMyAdmin里邊出現(xiàn) 沒有找到 PHP 擴(kuò)展 mbstring,而您現(xiàn)在正在使用多字節(jié)字符集。

解決方法:

#? yuminstall php55w-mbstringphp -m 可以查看當(dāng)前php 支持的擴(kuò)展

4、phpMyAdmin 配置文件現(xiàn)在需要一個短語密碼。

解決方法:

1、將 phpMyAdmin/libraries/config.default.php中的$cfg['blowfish_secret'] =''; 改成 $cfg['blowfish_secret'] ='aaaaa'; (注:其中的'aaa′為隨意的32位字符 否則會警告太短)

2、在phpMyAdmin目錄中,打開config.inc.php,

$cfg['blowfish_secret'] = ''; 改成 $cfg['blowfish_secret'] = 'aaaaa'; (注:其中的'aaaaa′為隨意的字符)這個密碼用于Cookies的加密,以免多個PhpMyAdmin或者和其他程序共用Cookies時搞混。

5、重啟apach服務(wù)器出現(xiàn)下面警告

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName

解決方法:

#? echo"ServerName admin">>/etc/httpd/conf/httpd.conf

給服務(wù)器設(shè)置個名字即可

6、由于端口受限 不能訪問的 參考以下帖子 開啟端口的方法

http://www.itdecent.cn/writer#/notebooks/11663044/notes/14293774

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容