-
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.
- /var/www
- 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.
- Example: 192.168.1.55 . When you see
<domain_name>
- example.com may be used. When use see
<domain_name>
, enter a domain name you selected. - Database name: blogdb
- Database user: bloguser
- example.com may be used. When use see
- Directories:
-
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.
- Directories:
-
Most of the processes will be on the VM. If the process is on the Dev PC, I will mention it in the title.
- TODO: Create a VM
- TODO: Install Ubuntu 18.04
- TODO: Set up ssh daemon.
- TODO: sshfs
- TODO: Laravel 5.7 requirements
- 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.
- There is two options for git.
Installation steps of requirements will be documented later.
cd /var/www
mkdir <domain_name>
cd /var/www/<domain_name>
- Click title to read the details.
cd ~/projects/blog2019-04-26
./connect.sh
cd ~/projects/blog2019-04-26/remote
git clone [email protected]:oldblogs/blog2019-04-26.git ./
- Click title to read the details.
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.
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.
sudo nano /etc/hosts
<IP address of VM> <domain_name>
Save & exit.
Test
ping <domain_name>
cd /var/www/<domain_name>
npm install
npm run dev
$ mysql -u root -p
mysql> CREATE DATABASE blogdb CHARACTER SET utf8;
exit
$ mysql -u root -p
CREATE USER bloguser@localhost IDENTIFIED BY 'password';
exit
$ mysql -u root -p
GRANT ALL PRIVILEGES ON blogdb.* TO 'bloguser'@'localhost';
exit
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.
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.
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.
cd /var/www/<domain_name>
php artisan config:cache
php artisan route:cache
php artisan view:cache
sudo service apache2 restart