Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Latest commit

 

History

History
248 lines (191 loc) · 6.14 KB

INSTALL.md

File metadata and controls

248 lines (191 loc) · 6.14 KB

Installation of the blog app on a virtual machine

Description of computers:

  • VM: This is the virtual machine that runs the blog application.

    • Directories:
      • /var/www
        • Directory for new web sites. Create a new directory for a new web site.
    • Users:
      • www-data: The user/group that Apache uses.
      • vmuser1: System user with sudo privileges.
    • <IP address of VM>
      • Example: 192.168.1.55 . When you see <IP address of VM>, enter your VM's IP address without angle brackets.
    • <domain_name>
      • example.com may be used. When use see <domain_name>, enter a domain name you selected.
      • Database name: blogdb
      • Database user: bloguser
  • Dev PC: The computer we develop on (Host of the VM).

    • Directories:
      • ~/projects: Local copies of projects
    • Users:
      • <dev_user> : System user with sudo privileges. When you see <dev_user> , enter your system user name without angle brackets.
  • Most of the processes will be on the VM. If the process is on the Dev PC, I will mention it in the title.

Create a new Virtual Machine on Development PC

  • TODO: Create a VM

Install requirements to the Virtual Machine

  • TODO: Install Ubuntu 18.04
    • TODO: Set up ssh daemon.
    • TODO: sshfs
  • TODO: Laravel 5.7 requirements
    • TODO: Apache, MySQL, PHP 7.1.3, Email, Git, unzip, p7zip-full, p7zip-rar, etc
    • Composer
      • PHP must be installed before this one.
    • Node, npm
  • TODO: Setup for sending e-mails.
  • TODO: Git
    • There is two options for git.
      • Install git and set credentials on VM.
      • Install git and set credentials on Dev PC, use sshfs to manipulate files on VM.
      • I use the second one, so I do not have to setup my git credentials on VM.

Installation steps of requirements will be documented later.

Create a new directory in /var/www

cd /var/www
mkdir <domain_name>
cd /var/www/<domain_name>
  • Click title to read the details.

Clone the git repository on Dev PC

cd ~/projects/blog2019-04-26
./connect.sh
cd ~/projects/blog2019-04-26/remote
git clone git@github.com:oldblogs/blog2019-04-26.git ./
  • Click title to read the details.

Generate application key

cd /var/www/<domain_name>
cp .env.example .env
php artisan key:generate

Check .env file APP_KEY value, it must not be empty.

Note: Keep your attention on whitespaces in .env file. White space between characters causes problems.

Laravel link storage

From Laravel 5.7 documentation:

https://laravel.com/docs/5.7/filesystem#the-public-disk

To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public.

cd /var/www/<domain_name>
php artisan storage:link
# set file permissions
cd ~
sudo ./<domain_name>.sh
  • Click title to read the details.

Define site in /etc/hosts file on Dev PC

sudo nano /etc/hosts
<IP address of VM> <domain_name>

Save & exit.

Test

ping <domain_name>

Install npm packages, and compile JS,and CSS

cd /var/www/<domain_name>
npm install
npm run dev

Create a database

$ mysql -u root -p
mysql> CREATE DATABASE blogdb CHARACTER SET utf8;
exit

Create a database user

$ mysql -u root -p
CREATE USER bloguser@localhost IDENTIFIED BY 'password';
exit

Grant privileges to the user

$ mysql -u root -p
GRANT ALL PRIVILEGES ON blogdb.* TO 'bloguser'@'localhost';
exit

Migrate database

Edit /var/www/'<domain_name>'/.env file, change the following values.

APP_NAME=Blog
APP_ENV=development
APP_DEBUG=true
APP_URL=http://'<domain_name>'

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blogdb
DB_USERNAME=bloguser
DB_PASSWORD=password
cd /var/www/<domain_name>
php artisan migrate:install --database=mysql

This creates the migrations table.

Execute the migrations:

php artisan migrate

This will execute scripts listed in migrations table, stored in database/migrations directory.

Seed the database with initial records

cd /var/www/<domain_name>
php artisan db:seed 

Seeding: RolesAndPermissionsSeeder
Seeding: SocialprovidersSeeder
Seeding: CsocialSeeder
Seeding: MediumTypeSeeder
Seeding: LicenseSeeder
Seeding: MediumSeeder
Database seeding completed successfully.

Email Settings

Create mailtrap account and enter your mailtrap information into .env file.

  • Mailtrap -> Email Testing -> Inboxes -> MyInbox -> SMTP Settings -> Show Credentials
    • Integrations: Select Laravel 7+

.env file

MAIL_DRIVER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=mailtrap_user_name
MAIL_PASSWORD=mailtrap_password

MAIL_FROM_ADDRESS="info@<domain_name>"
MAIL_FROM_NAME="Blog"

There must be no whitespaces between characters.

Fill Laravel Application caches (config, routes, views)

cd /var/www/<domain_name>
php artisan config:cache
php artisan route:cache
php artisan view:cache

Restart Apache

sudo service apache2 restart

References:

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04

Installing Node.js with Apt Using a NodeSource PPA

Laravel documentation

Read about domain names

Git

Computer code sign & symbol names exercise part 1 😉

Complete list of github markdown emoji markup