最近一段時間會學習一下PHP全棧開發,將會寫一系列的文章來總結學習的過程,以自勉。php
第一篇記錄一下LAMP環境的安裝html
0、 安裝Apache Web服務器mysql
安裝以前先更新一下系統git
sudo apt-get update && sudo apt-get dist-upgrade
而後安裝Apachegithub
sudo apt-get install apache2
這時在瀏覽器裏輸入localhost就能夠看到 "It works!", 說明安裝成功。web
一、 安裝MySQL數據庫
sql
sudo apt-get install mysql-server php5-mysql
而後是一些安全設置,包括root密碼、遠程登陸等。數據庫
sudo mysql_secure_installation
根據須要自行選擇有Y / n,就OK了。apache
二、 安裝PHPubuntu
安裝php5和一些有用的擴展(php5-curl,php5-imagick等):
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-imagick php5-cli
修改Apache的dir.cof文件,以讓Apache優先尋找index.php:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
而後重啓Apache web server:
sudo service apache2 restart
三、修改網站的根目錄
須要修改兩處配置文件
1)修改/etc/apache2/apache2.conf,找到
<Directory /var/www/>
,將
替換爲本身的目錄/var/www/
2)修改/etc/apache2/sites-available/000-default.conf
,找到DocumentRoot /var/www/html
,將/var/www/html
替換爲本身的目錄
而後重啓Apache
sudo service apache2 restart
3)複製"index.html"文件到本身的根目錄下
cp /var/www/html/index.html /本身的根目錄
四、總結
至此,LAMP環境就安裝好了,之後就能夠開發屬於本身的網站了。
參考連接: