Step 1 : Apache
安裝前請先sudo apt-get update
其他就不多說了,直接裝吧
sudo apt-get update sudo apt-get install apache2
Step 2 : MySQL
安裝指令
sudo apt-get install mysql-server php5-mysql
設定安全性
sudo mysql_install_db sudo mysql_secure_installation
Step 3 : PHP
安裝指令
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
修改一下路徑設定檔
sudo nano /etc/apache2/mods-enabled/dir.conf
裡面原本長這樣
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
現在要把index.php往前移
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
重啟Apache
sudo service apache2 restart
權限要先設定
設定apache2成爲自己設定之資料夾的group owner,同時也是owner
sudo chown -R www-data:www-data /home/my_user_name/my_path
把自己加進www-data的group裡面
sudo usermod -a -G www-data my_user_name
把www-data列爲最高group priority
sudo usermod -g www-data my_user_name
(以下是附贈的,斟酌使用)
把user踢出group,注意要先把group priority設成別的
sudo deluser
顯示目前group
groups my_user_name
更改資料夾權限
sudo chmod -R 775 /home/my_user_name/my_path
Step 4 : phpMyAdmin
自行下載並安裝phpMyAdmin比較好控制,現在載好的版本感覺是不用調整參數,預設cookie
參照以下網址(跟本沒動過阿XD)
paste.plurk.com/show/2081776
要自己重新設定的話,網址如下
/phpmyadmin/setup/index.php
Step 5 : 目錄更改
接下來要做的事情是,把根目錄改成自己的指定路徑:
sudo nano /etc/apache2/sites-available/000-default.conf
把
DocumentRoot /var/www/html
改成
DocumentRoot /home/my_user_name/my_path
注意不可以使用 ~/ 作爲home directory的簡寫
sudo service apache2 restart
修改 apache2.conf
sudo nano /etc/apache2/apache2.conf
新增
<Directory /path/to/another/directory> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted Allow from all </Directory>
重啓apache
sudo service apache2 restart
—參考文獻
[1] How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 14.04 – https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04
[2] Where to place my local website starting with the 2.4.7 version of apache2? – http://askubuntu.com/questions/448944/where-to-place-my-local-website-starting-with-the-2-4-7-version-of-apache2
[3] Apache can’t access folders in my home directory – http://askubuntu.com/questions/325498/apache-cant-access-folders-in-my-home-directory
[4] How to give apache2 permission to write and read files? – http://askubuntu.com/questions/246437/how-to-give-apache2-permission-to-write-and-read-files
[5] How To Install and Secure phpMyAdmin on Ubuntu 12.04 – https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-12-04
[6] Howto: Linux Add User To Group – http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
[7] Permissions issue: how can Apache access files in my Home directory? – http://askubuntu.com/questions/26848/permissions-issue-how-can-apache-access-files-in-my-home-directory
[8] Enable Userdir – http://www.server-world.info/en/note?os=Ubuntu_14.04&p=httpd&f=5
[9] phpMyAdmin sample configuration – http://paste.plurk.com/show/2081776/
搶先發佈留言