新手第一次搭建lamp環(huán)境可以在window下創(chuàng)建一個虛擬機,裝上ubuntu
命令行+可視化,可以直觀的看到指令運行完成情況,比較方便,ubuntu的鏡像文件,可以到官網(wǎng)下載 Unbunt
Tip
sudo命令:用管理員root運行這個命令,也可以 直接 sudo su root,以下都能省去sudo
通過apt-get安裝指定版本
apt-get install <<package name>>=<<version>>
將列出所有來源的版本(只會列出能安裝的)
apt-cache madison apache
madison是一個apt-cache子命令烁设,可以通過man apt-cache查詢更多用法玻熙。
建議安裝順序
①Apache ②Mysql ③PHP
(PHP要放到最后,要依賴Apache和Mysql的服務(wù)的)
0.安裝Apache
sudo apt-get install apache2
啟動/關(guān)閉/重啟/狀態(tài)
/etc/init.d/apache2 (start/stop/restart/status)
查看apache是否運行
ps -A|grep apache
檢查apache是否安裝成功:打開本機的瀏覽器 輸入 127.0.0.1
出現(xiàn) It works 即為成功
1.安裝Mysql
sudo apt-get install mysql-server
啟動/關(guān)閉/重啟/狀態(tài)
/etc/init.d/mysqld (start/stop/restart/status)
安裝完成后查看服務(wù):
sudo netstat -tap | grep mysql
2.安裝PHP
sudo apt-get install php libapache2-mod-php
首先需要將www目錄更改下所有權(quán)以便可以新建文檔
sudo chmod 777 /var/www(默認路徑,可以修改)
創(chuàng)建一個phpinfo.php文件
在瀏覽器訪問,出現(xiàn)phpinfo頁面
3.安裝PHP的一些擴展
apt-get install php-mysql php-curl php-gd 等等