2016年2月6日 星期六

在 Raspberry 上面建立 php 的網頁server



sudo apt-get install apache2 -y

用web browse 去  http://192.168.1.9  (RPI 的ip.... 這不一定是你的...請用ifconfig 去查看)

如果有看到下面的畫面....代表apache php server 已經啟動了


  The default web is in 
/var/www/html/index.html.

cd /var/www/html
ls -al

ADDITIONAL - INSTALL PHP

To allow your Apache server to process PHP files, you'll need to install PHP5 and the PHP5 module for Apache. Type the following command to install these:
sudo apt-get install php5 libapache2-mod-php5 -y

Now remove the index.html file:
sudo rm index.html
and create the file index.php:
sudo nano index.php

<?php echo "hello world"; ?>


or show your PHP info:
<?php phpinfo(); ?>

apache2 server operation

  • stop it: sudo /etc/init.d/apache2 stop
  • start it with: sudo /etc/init.d/apache2 start
  • reload the config with: sudo /etc/init.d/apache2 reload
  • restart (stop followed by start): sudo /etc/init.d/apache2 restart


Reference : https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

沒有留言:

張貼留言