lamp的搭建以及應用(rpm)


注:本次實驗爲rpm包形成的搭建,而不是源碼


Lamp=linux+apache+mysql+php


實驗:

1,建立光盤掛載點

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

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


2,配置本地yum(因爲要安裝的包比較多而且有依賴關係,所以使用yum安裝)

[rhel-server]

name=Red Hat Enterprise Linux server

baseurl=file:///mnt/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release


3,安裝lamp所有安裝包:

[root@localhost ~]# yum install httpdmysql-server mysql php php-gd php-mysql


3,啓動服務

[root@localhost ~]# service httpd start(啓動http服務)

Starting httpd:                                           [  OK  ]

[root@localhost ~]# chkconfig httpd on(寫入開機自啓動中)


[root@localhost ~]# service mysqld start(啓動數據庫)


查看sql是否安裝成功

[root@localhost ~]# mysql -u root(進入數據庫)

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.0.77 Source distribution


Type 'help;' or '\h' for help. Type '\c' toclear the buffer.


mysql> show databases;(查看database數據)

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)


因爲此時的數據庫沒有密碼,處於安全考慮,設置上密碼

[root@localhost ~]# mysqladmin -u root -ppassword  '123'(爲mysql中的root設置密碼)


4,編輯一個小網頁驗證phphttp的結合:

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

[root@localhost html]# vim index.html


<?php

phpinfo{};(把信息輸出到網頁中)

?>


使用客戶機驗證,如圖:




5,繼續編輯網頁驗證mysqlhttp的結合

<?php

$link=mysql_connect('127.0.0.1','root','123');

if ($link)

echo "ok";

else

echo "not";

?>


使用客戶機驗證,如圖:



到此:

環境搭建成功

下面以用此環境爲案例搭建一個小的商城的網站:

案例:

首先準備軟件ECShop_V2.7.2_UTF8_Release0505.zip

如圖:


1,解壓文件

[root@localhost ~]# unzip ECShop_V2.7.2_UTF8_Release0505.zip  


2,移動upload文件夾到/var/www/html/中並改名爲ecshop

[root@localhost ~]# mv upload/  /var/www/html/ecshop


3,輸入http://192.168.10.1/ecshop出現如下界面

同意上述條款並點擊下一步配置


linux中修改文件權限使其可寫


修改後如圖

全部可寫,然後點擊下一步配置


點擊安裝

完成安裝後如圖:


實驗完成


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