[Raspberry Pi] 在 Raspberry Pi 安裝 AP(Linux+Apache+PHP) 環境

研究一個下午,終於用出來了。




1.執行apt-get更新
sudo apt-get update
2.輸入apache和php的安裝指令
sudo apt-get install apache2 php5 libapache2-mod-php5
3.(選用)為了使用mysqli,安裝php5-mysqlnd
sudo apt-get install php5-mysqlnd
4.(選用)開啟.htaccess功能,輸入
sudo nano /etc/apache2/sites-enabled/000-default
然後找到
<directory var="" www="">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</directory>
把AllowOverride None改成AllowOverride All
重新啟動apache

5.輸入hostname -I得到IP位置,輸入IP有顯示It's work就是成功了。

6.不確定需不需要,我看他人會使用
sudo chown -R $USER:$USER /var/www/folder-name
sudo chmod -R 755 /var/www
確保使用者有足夠的權限開啟執行php

  • ps:  預設的本機位置是http://localhost/192.168.1.10
  • ps2:預設的php路徑是/var/www/


補充:.htaccess設置

Even though mod-rewrite is enabled, by default it is not enabled for .htaccess files.
Hold Your Breath
  • Open xampp control panel
  • Stop Apache
  • Click the Config button on the Apache row, and select httpd.conf
  • In that file, search for something like xampp/htdocs">
  • A bit lower, you may see a line like this: # AllowOverride All. Remove the #, which is a comment
  • Alternately, search for AllowOverride All, make sure it is in the right section, and remove the comment #
  • Save the file
  • Restart Apache, say a prayer, cross your fingers and hold your breath
TAG: apache, linux, php, raspberry pi

留言

這個網誌中的熱門文章

[IDE] Eclipse熱鍵大全

[滑鼠] 羅技G402 換微動