Ubuntu 16.04 LTS下用apt搭建LAMP環境

來源:互聯網
上載者:User
Ubuntu 16.04 LTS下用apt搭建LAMP環境



引言

首先說明一下這個方案沒在Ubuntu 16.04 以外的其他版本試過,不過問題應該不大,適合新手搭建環境。通過apt下載軟體請確保你的源是配置是正確的否則容易出問題。



更新源

獲得最近的軟體包的列表,列表中包含一些包的資訊,比如這個包是否更新過。請確保下面的命令執行完畢且沒有錯誤(這個很重要,這個出錯下面也跟著出錯)。
sudo apt update
sudo apt upgrade



安裝Apache2

sudo apt install apache2



啟動Apache2

sudo /etc/init.d/apache2 start(啟動)
sudo /etc/init.d/apache2 restart(重啟)
sudo /etc/init.d/apache2 stop(關閉)

在瀏覽器裡輸入http://localhost或者是http://127.0.0.1,如果看到了It works! 那就說明Apache2就成功的安裝了,Apache的預設安裝的網站根目錄在/var/www/html,當然可以通過Apache的設定檔修改。



安裝PHP和Apache2支援

sudo apt install libapache2-mod-php5 php5
sudo apt install php5-gd php5-mysql(其他擴充)

安裝完畢後重啟Apache服務:
sudo /etc/init.d/apache2 restart(重啟)
在/var/www/html下編寫一個test.php進行測試,大夥應該都是從window過來的,這個就不多說了。



安裝mysql資料庫

sudo apt install mysql-server

安裝過程中需要設定資料庫root使用者的密碼(要輸入兩次)。



安裝phpmyadmin-Mysql資料庫管理

sudo apt install phpmyadmin

安裝過程中需要輸入剛剛設定的root使用者的訪問密碼。然後將phpmyadmin與Apache2建立串連,預設的網址根目錄在/var/www/html,phpmyadmin在/usr/share /phpmyadmin目錄,所以就用命令:

sudo ln -s /usr/share/phpmyadmin /var/www/html

在瀏覽器裡輸入http://localhost/phpmyadmin或者是http://127.0.0.1/phpmyadmin。額,又是熟悉的味道。



設定Ubuntu檔案執行讀寫權限

sudo chmod 777 /var/www/html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.