kreativan
12/27/2018 - 10:01 PM

RaspberryPi

RaspberryPi Web Server

Apache

sudo apt-get update
sudo apt-get upgrade -y

Install apache 2

sudo apt-get install apache2 -y
sudo a2enmod rewrite
sudo service apache2 restart

We’re using the -y flag which will automatically install required and suggested Apache2 packages. We need to change one setting on Apache2 to allow .htaccess overrides in the /var/www directory, so open sudo nano /etc/apache2/apache2.conf and change the AllowOverride None to AllowOverride All as shown below:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Restart apache2

sudo service apache2 restart

File Sahring with SAMBA

sudo apt-get update
sudo apt-get upgrade
sudo apt-get clean

Insall and configure Samba

sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf

Add this at the bottom

[www] 
comment = Pi www
public = yes
writeable = yes
browsable = yes 
path = /var/www
valid users = pi
guest ok = yes
create mask = 0777
directory mask = 0777

Creater user and start amba

sudo smbpasswd -a pi
sudo /etc/init.d/samba restart

mailhog-docker-rpi

Raspberry Pi Docker Raspberry Pi

You need Docker runtime installed on your rpi. https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi/

curl -sSL https://get.docker.com | sh

Build

git clone https://github.com/Lewiscowles1986/mailhog-docker-rpi
cd mailhog-docker-rpi
sudo docker build -t mailhog:alpine-pi .

Run

sudo docker run --restart always --name mailhog -p 1025:1025 -p 8025:8025 -d mailhog:alpine-pi

PHP

Install php 7

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

Install php 7.3

sudo apt install ca-certificates apt-transport-https 
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

sudo apt update
sudo apt install php7.3
sudo apt install php7.3-cli php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql php7.3-xml
sudo apt install php7.3-bcmath php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-readline php7.3-xml php7.3-zip

Switch From PHP 5.6 => PHP 7.2

sudo a2dismod php5.6
sudo a2enmod php7.2
sudo service apache2 restart

Remove php

Remove php 7.0

sudo apt-get install ppa-purge
sudo apt-get purge php7.0-common

Or remove all php versions

sudo apt-get purge php7.*

php extensions

Install GD Library

sudo apt-get install php7.3-gd

Install Zip Support

sudo apt-get install php7.3-zip

Install MySQL

sudo apt-get install mysql-server php-mysql -y
sudo service apache2 restart

Install phpMyAdmin

sudo apt-get install phpmyadmin -y

link: http://192.xxx.x.xxx/phpmyadmin/

username: phpmyadmin

phpmyadmin reconfigure

sudo dpkg-reconfigure phpmyadmin

Permmission

The /var/www is the root directory of the website, it is currently owned by the “root” user. We must ensure the "Pi" user account can write files to /var/www directory.

sudo chown www-data:www-data /var/www
sudo chmod 775 /var/www
sudo usermod -a -G www-data pi
# also
sudo chown -R pi:pi /var/www

Git

sudo apt-get install git

Mail

Install

sudo apt-get update
sudo apt-get install ssmtp
sudo apt-get install mailutils

Edit SSMTP cofiguration file

***/etc/ssmtp/ssmtp.conf ***

root=postmaster
mailhub=smtp.gmail.com:587
hostname=raspberrypi
AuthUser=YourGMailUserName@gmail.com
AuthPass=YourGMailPassword
UseSTARTTLS=YES

Optional lines:

rewriteDomain=your.domain
FromLineOverride=YES

Nice sender names:

If you would like your website to be able to send emails which appear to be sent from a person with a nice name like “John Doe” or “Your super web site” instead of from a simple sender name like you@your.domain, then you need to make sure that in the /etc/ssmtp/ssmtp.conf file the FromLineOverride line is commented (#) or set to NO and you need to give a nice name to the www-data user. You can do this by editing the passwords file: nano /etc/passwd

Find the line corresponding to www-data and set the fifth value in it to a nice name like “Your super website”.

Test Email

<?php 
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "test@test.com";
    $to = "kreativan.dev@gmail.com";
    $subject = "PHP Mail Test script";
    $message = "This is a test to check the PHP Mail functionality";
    $headers = "From:" . $from;
    mail($to,$subject,$message, $headers);
    echo "Test email sent";
?>

Check Temp

/opt/vc/bin/vcgencmd measure_temp