天天看點

Linux下Lamp(rpm包)搭建+網頁管理mysql

Linux下Lamp(rpm包)搭建+網頁管理mysql

Lamp(rpm)安裝:

一:編輯本地yum用于安裝軟體包:

[root@localhost ~]# cd /mnt/cdrom/

[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/

[root@localhost ~]# cd /mnt/cdrom/Server/

[root@localhost Server]# vim /etc/yum.repos.d/rhel-debuginfo.repo #編輯本地yum

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715937Lhmh.gif"></a>

二:安裝http伺服器:

[root@localhost Server]# yum install httpd -y #使用yum安裝http服務,-y表示取消互動

[root@localhost Server]# service httpd start #啟動http

[root@localhost Server]# chkconfig httpd on #開機自動啟動http

三:安裝mysql資料庫:

[root@localhost Server]# yum list all |grep mysql #檢視與mysql相關的安裝包

[root@localhost Server]# yum install mysql -y #安裝mysql工具包

[root@localhost Server]# yum install mysql-server -y #安裝mysql-server伺服器

[root@localhost Server]# service mysqld start #啟動mysql服務

[root@localhost Server]# chkconfig mysqld on #開機自動啟動mysql

[root@localhost Server]# netstat -tupln |less #分頁檢視端口

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715938c5IR.gif"></a>

[root@localhost Server]# mysqladmin -u root -p password '123' #為資料庫建立密碼

[root@localhost Server]# mysql -u root -p #使用密碼登入資料庫

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715942CsjL.gif"></a>

四:安裝php:

[root@localhost Server]# yum list all |grep php #檢視與php相關的安裝包

[root@localhost Server]# yum install php -y #安裝php主程式

[root@localhost Server]# yum install php-mysql -y #安裝php與mysql的連接配接包

五:檢視http調用php子產品:

[root@localhost Server]# cd /etc/httpd/conf.d/ #切換到該目錄中檢視http調用http子產品

[root@localhost conf.d]# cat php.conf

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715943Umbf.gif"></a>

六:測試http能否調用php:

[root@localhost conf.d]# cd /var/www/html/

[root@localhost html]# vim index.php #建立該檔案,測試http能否調用php

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715944LSF4.gif"></a>

[root@localhost html]# service httpd restart

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715944wHvd.gif"></a>

七:測試php能否調用mysql:

[root@localhost html]# vim index.php #再次編輯該檔案,檢視php能否成功調用mysql

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715944jXTV.gif"></a>

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715945QZxs.gif"></a>

八:安裝phpmyadmin,通過php網頁形式來管理mysql

[root@localhost ~]# unzip phpMyAdmin-2.11.10.1-all-languages.zip #解壓

[root@localhost ~]# mv phpMyAdmin-2.11.10.1-all-languages /var/www/html/phpmymdmin

#将該檔案移動到/var/www/html中,并改名為phpMyAdmin

[root@localhost ~]# cd /var/www/html/

[root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php

[root@localhost phpmyadmin]# vim config.inc.php #修改該檔案如圖:

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715946ltZw.gif"></a>

[root@localhost phpmyadmin]# service httpd restart

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715948uK9g.gif"></a>

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_1347715950oN6b.gif"></a>

九:根據網頁提示安裝php-mbstring

[root@localhost ~]# yum list all |grep php

[root@localhost ~]# yum install php-mbstring -y #安裝mbstring

[root@localhost ~]# yum localinstall libmcrypt-2.5.7-5.el5.i386.rpm

php-mcrypt-5.1.6-5.el5.i386.rpm --nogpgcheck #使用localinstall安裝CD光牒中手動導入的rpm包,這些軟體包無法擷取公鑰,使用--nogpgcheck,取消簽名檢測

<a href="http://5493845.blog.51cto.com/attachment/201209/15/5493845_13477159513HgI.gif"></a>

安裝php-mbstring及mcrypt後,沒有了錯誤提示。這樣就可以通過網頁的形式管理mysql

本文轉自 liuyatao666 51CTO部落格,原文連結:http://blog.51cto.com/5503845/992166,如需轉載請自行聯系原作者