Category: Raspberry Pi

About Raspberry Pi

  • Configure php.ini

    Write a page to output the phpinfo

    Make a file named phpinfo.php and place it in the document root. The contents of the file is below.

    <?php phpinfo(); >

    Display phpinfo

    Visit

    http://192.168.10.108/phpinfo.php

    IP address should be modified to yours.

    Find out the item “Loaded Configuration File”. In this section, you can find the path of php.ini that is loaded on the system.

    Edit php.ini

    $ sudo vi /etc/php/7.4/fpm/php.ini
    memory_limit = 1024M
    upload_max_filesize = 128M
    post_max_size = 1024M
    max_execution_time = 3600

    Restart php-fpm

    $ sudo systemctl restart php7.4-fpm
  • Let’s Encrypt

    Install Certbot

    $ sudo apt install certbot python3-certbot-apache

    Add a Certification

    $ sudo certbot --apache -d www.lama-lab.mydns.jp/

    Renew Certbot

    Make a script to renew the certification.

    $ sudo vi /etc/cron.daily/certbot-renew

    In the certbot-renew script, you should write like that.

    #!/bin/sh
    certbot renew --post-hook "systemctl reload apache2"

    Then you must change the permission.

    $ sudo chmod 755 /etc/cron.daily/certbot-renew
  • Install Redis

    Install Redis module

    $ sudo apt install php-redis

    Enable socket communications

    $ sudo vi /etc/redis/redis.conf

    In redis.conf file

    port 0
    unixsocket /var/run/redis/redis-server.sock
    unixsocketperm 770

    Redis Bug fix

    Redis have a bug on loading the service. So fix the bug by editing the service file.

    $ sudo vi /etc/systemd/system/redis.service

    Edit the redis.service file like following.

    [service]
    ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"

    Reload deamon

    $ sudo systemctl daemon-reload

    Permission modify

    $ sudo usermod -aG redis www-data
    $ sudo chown -R redis:www-data /var/run/redis

    Reload redis-server

    $ sudo systemctl restart redis-server

    Check the configuration

    $ sudo redis-cli -s /var/run/redis/redis-server.sock
    >monitor

    If you got “OK”, settings are correct.

  • Install PHP

    Install PHP

    $ sudo apt install php

    Check the version of PHP

    $ php -v

    Install PHP libraries

    $ sudo apt install php7.4-curl php7.4-xml php7.4-common php7.4-json php7.4-mbstring php7.4-zip php7.4-mysql php7.4-GD php7.4-fileinfo php7.4-bz2 php7.4-intl php7.4-imagick

    Install PHP modules

    $ sudo apt install php-apcu redis redis-server
  • Install MariaDB

    Install MariaDB

    $ sudo apt install mariadb-server

    Initialize MariaDB

    $ sudo mysql_sequre_installation

    Notice: First root password is not set.(none). So you should only type Enter when you are prompted to enter that.

    On all other questions, it is recommended to answer “yes”.

  • Add a new HDD

    Search the HDD

    $ sudo fdisk -l

    Make partition

    $ sudo gdisk /dev/sda

    Make a file system

    $ sudo mkfs -t ext4 /dev/sda1

    Mount the file system

    Use autofs.

    Check

    $ df -T
  • Setup AutoFS

    Install autofs

    $ sudo apt install autofs
    $ sudo systemctl enable autofs
    $ sudo systemctl start autofs

    Edit /etc/auto.master

    $ sudo vi /etc/auto.master
    /misc /etc/auto.misc  <-comment in this line.
    #+auto.master  <-comment out this line.

    Search External HDD

    $ sudo blkid /dev/sda1

    Copy the UUID

    Edit auto.misc

    $ sudo vi /etc/auto.misc

    In this file,

    hdd  -fstype=ext4, rw :/dev/disk/by-uuid/xxx-xxx-xxxx

    Enable Autofs

    $ sudo systemctl enable autofs --now

    Debug Configuration

    $ sudo systemctl stop autofs
    $ sudo automount -fv

  • MyDNS

    Resister your information

    Visit MyDNS site https://www.mydns.jp/ and resister your information.

    Information

    • ID: mydnsxxxxxx
    • Pass: XXXXXXXXX
    • Domain: lama-lab.mydns.jp

    Records

    • * = A
    • * = AAAA
    • www = A
    • www = AAAA

    IP Notification

    $ sudo vi /etc/cron.hourly/mydns

    The contents of the file is

    wget -q -O - http://[ID]:[Pass]@ipv4.mydns.jp/login.html
    wget -q -O - http://[ID]:[Pass]@ipv6.mydns.jp/login.html

    Change the permission of the file

    $ sudo chmod u+x /etc/cron.hourly/mydns
  • PPPoE Pass Through

    Install PPPoE

    $ sudo apt install pppoe pppoeconf

    Configure

    $ sudo pppoeconf

    Check the configuration

    $ ip a show ppp0

    Add default gateway

    $ sudo ip route add default dev ppp0

    Turn On and Off

    $ sudo pon dsl-provider
    $ sudo poff

    Create startup script

    $ sudo vi /etc/ppp/ip-up.d/10dslprovider

    The contents of the file is

    #!/bin/sh
    /sbin/ip route add default dev ppp0

    Configure the permission of the script

    $ sudo chmod 755 /etc/ppp/ip-up.d/10dslprovider

    Auto connect after reboot

    $ sudo crontab -e
    @reboot sleep 30; /etc/cron.hourly/mydns

    Notice: Insert a sleep timer between reboot and connection script. It is required to guarantee the time for network system starting before connection script is roaded.

  • Setup FTP Server

    Install pure-ftpd

    $ sudo apt install pure-ftpd
    $ sudo systemctl start pure-ftpd
    $ sudo systemctl enable pure-ftpd

    Configure Firewall

    $ sudo ufw allow ftp

    Check the configuration

    $ ftp 192.168.10.108