Raspberry Pi/Web Server

From Omnia
Jump to navigation Jump to search

Web Server

Setting up a web server on a Raspberry Pi - Raspberry Pi Documentation - https://www.raspberrypi.org/documentation/remote-access/web-server/

Apache

Setting up an Apache Web Server on a Raspberry Pi - Raspberry Pi Documentation - https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

sudo apt-get update
sudo apt-get install apache2 -y

php:

sudo apt-get install php libapache2-mod-php -y

NGINX

Setting up an NGINX web server on a Raspberry Pi - Raspberry Pi Documentation - https://www.raspberrypi.org/documentation/remote-access/web-server/nginx.md

sudo apt-get update
sudo apt-get install nginx
sudo /etc/init.d/nginx start

php:

sudo apt-get install php-fpm
cd /etc/nginx
sudo nano sites-enabled/default
  # Add index.php
  index index.html index.htm;
  # uncomment .php section
  location ~ \.php$ {
               include snippets/fastcgi-php.conf;
               # With php-fpm (or other unix sockets):
               fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
               # With php-cgi (or other tcp sockets):
               #fastcgi_pass 127.0.0.1:9000;
  }
sudo /etc/init.d/nginx reload

test:

cd /var/www/html/
sudo mv index.nginx-debian.html index.php
# index.php
<?php echo phpinfo(); ?>