Skip to content
Lyrics website using Laravel
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bootstrap
config
database
public
resources
routes
storage
tests
.env.example
.gitattributes
.gitignore
README.md
artisan
composer.json
package-lock.json
package.json
phpunit.xml
readme.md
server.php
webpack.mix.js

README.md

LyricDB

This is an example of a Laravel project.

Run on a Raspberry Pi

Used hardware/software

  • Raspberry Pi 3
  • Micro-SD card (32 GB)
  • Mobile phone charger
  • Ethernet cable

Steps to execute

Preparing SD-card

  1. Start by downloading the latest version of Raspbian
  2. When the download is complete, extract the ZIP-file
  3. Next, run Win32DiskImager as administrator
  4. Click on the browse-button next to the textbox and select the extracted *.img-file
  5. Select, if necessary, the proper disk in the Device-dropdown
  6. Start writing the Raspbian image to the SD-card by clicking the Write-button
  7. When the operation is complete, open the SD-card in the Windows Explorer
  8. Create a file with the name ssh directly on the SD-card. The content doesn't matter

Wire-up

  1. Put your SD-card in the Raspberry Pi
  2. Connect your Raspberry Pi to your internet router at home, using the ethernet-cable
  3. Finally power-up your Raspberry Pi

Find IP-address

  1. There isn't a noob-proof way to find your pi's IP-address. If you don't know about networking, I'd suggest downloading an IP-scanner
  2. Start a scan and search for a device with a MAC-address which starts with B8:27:EB

Installation MobaXterm

MobaXterm is a free application that allows you to connect to a server through FTP, SSH, SFTP, ...
Download MobaXterm

Basic setup of the Raspberry Pi

  1. Start MobaXterm and click on the Session-button
  2. In the dialog choose for SSH, and enter the IP-address of your Raspberry Pi in the Remote host box and pi in the username box
  3. The SSH-prompt requests a password. The default password for the pi-user is raspberry
  4. Moba proposes to remember the password. Postpone this until you've set a new password
  5. Start by changing the password:
    sudo passwd pi
    
  6. Enter a new password and confirm it
  7. Set the timezone-data for the device:
    sudo dpkg-reconfigure tzdata
    
  8. Update the package-repository. Next, update the installed packages:
    sudo apt-get update && sudo apt-get -y upgrade
    
  9. Update Raspbian. Next, choose to restart the Raspberry Pi:
    sudo rpi-update
    
  10. Install the Apache-webserver. This software allows us to host websites:
    sudo apt-get -y install apache2
    
  11. Install PHP7 and the module to Apache2. This software allows us to use server-side scripting when handling webrequests:
    sudo apt-get -y install php7.0 libapache2-mod-php7.0
    
  12. Install MySQL-server and the module to PHP7. This software allows us to host databases and access the databases from PHP.
    sudo apt-get -y install mysql-server mysql-client php7.0-mysql
    
  13. Install PHPMyAdmin. This software allows us to manage the databases on the SQL-server through a webinterface.
    sudo apt-get -y install phpmyadmin
    
  14. At last, we'll need Composer. This is a dependency-manager that allows us to pull Laravel and automatically install the required packages. Note: Composer is only available in the apt-get repository starting from Raspbian Stretch. If you use older versions of Raspbian, you'll have to use getcomposer.org.
    sudo apt-get -y install composer
    
  15. Now we're going to configure everything

Create an SQL-user

  1. Log in as root sql-user:
    sudo mysql -u root
    
  2. Create a new user (I called him pi as well). Replace password with a password of your choice:
    CREATE USER 'pi'@'localhost' IDENTIFIED BY 'password';
    
  3. Allow your new SQL-user to do anything:
    GRANT ALL PRIVILEGES ON *.* TO 'pi'@'localhost';
    
  4. Reload the priviliges:
    FLUSH PRIVILEGES;
    
  5. Exit the SQL command prompt:
    exit
    
  6. Restart the SQL-server:
    sudo service mysql restart
    
  7. To hide the unimportant databases in PHPMyAdmin, modify this file:
    sudo nano /etc/phpmyadmin/config.inc.php
    
  8. Add following line in the appropriate position (you'll see where). Save and exit (ctrl+O → Enter → ctrl+X):
    $cfg['Servers'][$i]['hide_db'] = 'information_schema|performance_schema|mysql|phpmyadmin';
    

Configure FTP:

  1. Become the owner of the webfolder:
    sudo chown -R pi /var/www
    
  2. Install vSFTPd:
    sudo apt-get -y install vsftpd
    
  3. Modify the configuration file:
    sudo nano /etc/vsftpd.conf
    
  4. Change write_enable=NO to:
    write_enable=YES
    
  5. Add this line at the end of the file:
    force_dot_files=YES
    
  6. Save and exit (ctrl+O → Enter → ctrl+X)
  7. Restart vSFTPd:
    sudo service vsftpd restart
    
  8. Create a softlink to the webfolder in your home-directory:
    ln -s /var/www ~/www
    

NPM

  1. Install the node-package-manager:
    sudo apt-get -y install npm
    
  2. Sadly this probably installed node-legacy. Uninstall nodejs and add the correct debian package to the apt-get repository. Finally install this version:
    sudo apt-get -y remove nodejs
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get -y install nodejs
    
  3. Finally, install dh-autoreconf
    sudo apt-get -y install dh-autoreconf
    

Clone the LyricDB repository

  1. Go to the webfolder:
    cd /var/www
    
  2. Remove the testsite:
    sudo rm -R html
    
  3. Clone the source code for LyricDB:
    git clone https://github.com/PieterjanDeClippel/LyricDB
    
  4. Go to the folder:
    cd LyricDB
    
  5. Install the required packages:
    composer install
    
  6. Copy the example .env-file. This file contains any configuration about the environment (passwords, ...):
    cp .env.example .env
    
  7. Edit the file:
    sudo nano .env
    
  8. Set APP_NAME, APP_URL (http://lyricdb), DB_DATABASE (LyricDB), DB_USERNAME (pi), DB_PASSWORD (your sql-password) to the proper values
  9. Save and exit nano (ctrl+O → Enter → ctrl+X)
  10. Generate an application key:
    php artisan key:generate
    
  11. Create the database. Log in into the SQL command prompt:
    sudo mysql -u root
    CREATE DATABASE LyricDB;
    exit;
    
  12. Install the database. This may take some time:
    php artisan migrate
    
  13. In the latest version of Raspbian, the rewrite module is probably disabled. To enable mod-rewrite, run:
    sudo a2enmod rewrite
    
  14. Also in the latest version of Apache, there's a big chance Apache doesn't allow rewriting for the webfolder. Check the following file:
    sudo nano /etc/apache2/apache2.conf
    
  15. Ensure AllowOverride is set to All:
    <Directory /var/www/>
    	Options Indexes FollowSymLinks
    	AllowOverride All
    	Require all granted
    </Directory>
    
  16. Restart Apache:
    sudo systemctl restart apache2
    
  17. Create a new site by first copying the default VirtualHost-file:
    cd /etc/apache2/sites-available/
    sudo cp 000-default.conf lyricdb.conf
    
  18. Modify the file. Change following settings:
    ServerName lyricdb
    DocumentRoot /var/www/LyricDB/public
    
  19. Enable the site:
    sudo a2ensite lyricdb.conf
    
  20. Restart Apache:
    sudo systemctl reload apache2
    
  21. Change the owner of the storage folder:
    cd /var/www/LyricDB
    sudo chown -R www-data:www-data storage
    
  22. Restart Apache:
    sudo systemctl restart apache2
    

Set hostname

At last, we can set a hostname for our Rapsberry Pi.
  1. Change the hostname-file:
    sudo nano /etc/hostname
    
  2. Put lyricdb in the file. Save and exit nano (ctrl+O → Enter → ctrl+X)
  3. Change the hosts-file:
    sudo nano /etc/hosts
    
  4. Modify the entry for 127.0.1.1. Replace localhost with lyricdb. Save and exit nano (ctrl+O → Enter → ctrl+X)
  5. Install Samba and Winbind. This will ensure that the hostname is being broadcasted in the network:
    sudo apt-get -y install samba winbind
    
  6. Restart the Raspberry Pi:
    sudo reboot
    
  7. Now you can visit http://lyricdb and you should see the Laravel website

Managing Node-modules

  1. This repository already contains a file /public/js/app.js. This is a compilation of jquery, bootstrap, angular, angular-route, and some more libraries
  2. If you'd wish to recompile this file, you should first acquire all the needed node-packages. Therefore you need to run:
    npm install
    
  3. If you'd wish to add more packages, you can just run
    npm install [package]
    

    to install them. You should then require the package in either the /resources/assets/js/bootstrap.js or /resources/assets/sass/app.scss file

  4. When you added new node-modules, registered them in the above mentioned file, and want to recompile these assets, run following command:
    npm run dev
    

    This will put the result of the compiled app.js and app.scss in the public folder. No further actions have to be taken.

You can’t perform that action at this time.