vagrant up
Then go to URL: homestead.test
Make use of an external tool like:
-SequelPro (Mac OS)
-Alternatives for Windows include: HeidiSQL, ...
In this tool use the variables from the ".env" file to connect to the database.
First we need to go inside the virtual machine:
vagrant ssh
Then we need to go into the "code" folder:
cd code
This is the right folder to make use of Artisan that interacts with our DB manipulations.
Migrate (make) tables that are defined in "laravel-app > database > migrations":
php artisan migrate
That's it, you should now be able to use the external tool (see previous title) to look into the DB and confirm if all is ok.
Added rows to table 'students' on 08/10/2019
Added email and password rows to table 'users' for login on 14/10/2019
Added rows to table 'companies' on 14/10/2019
Added rows and updated seeders with fillable content to tables 'companies' and 'students' on 15/10/2019
Added Thomas More user and company for API testing to tables 'companies' and 'students' on 17/10/2019
Added new seeder for standerd background/profile picture on 21/10/2019
Added rows to 'table 'internships' on 24/10/2019
Added Dribble columns to 'table 'students' on 04/11/2019
Fixed Intracto bug in database on 22/11/2019
Added table students_internships for many to many on 02/12/2019
Changes on seeders (and removed factories) for user testing on 05/12/2019
Added a students_companies table to save the distance in database on 12/12/2019
Added a tags column to internships and students tables in database on 13/12/2019
Refreshing tables when changes were made
php artisan migrate:refresh
Refreshing tables and simultaniously add seeders
php artisan migrate:refresh --seed
- Add credentials
composer update
- If you want to try with own Algolia API, you can change the credentials but you need to perform following commands to bring all the information of you database into the api.
php artisan scout:import "App\User"
php artisan scout:import "App\Student"
php artisan scout:import "App\Company"
php artisan scout:import "App\Internship"
php artisan scout:import "App\ReviewInternship"
php artisan scout:import "App\ReviewCompany"
- If something went wrong, please say it in the fb group ^^
To add dummy data to the tables:
php artisan db:seed
If a new seeder is added or in case of an error try the following commands:
composer dump-autoload
If the problem is still there:
composer update
and composer dump-autoload
To convert SASS & ES6 to CSS & plain Javascript for a visual view in your browser:
npm run watch
(Updates live in browser)
Legende | Betekenis |
---|---|
π | Nieuwe to do |
Arne | |
Bram | |
Irene | |
Lars |
Geheime feedback van Joris na de eerste demo: https://docs.google.com/document/d/1EONhy5d7Q7JDloX7UC3OkLKlEE4s2yvwaC_pqeFDuRs/edit#heading=h.qjhtyun2njki (doorstreep als iets klaar is)
Normally everybody should have mysql on their server. To check it run: mysql --version
mysql -u username -p
Enter password:
MariaDB [(none)]> CREATE DATABASE databasename;
IMPORTANT ip is that of the person who uses your database
MariaDB [(none)]> create user 'name'@'ip' IDENTIFIED BY 'password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON databasename.* TO 'name'@'ip';
MariaDB [(none)]> SHOW DATABASES;
MariaDB [(none)]> select * from mysql.user;
MariaDB [(none)]> show grants for 'name'@'ip';
mysql -h ip -u username -p
Enter password:
MariaDB [(none)]> show databases;
Use following link to generate a keyname.pkk file to access the database server: https://linuxize.com/post/mysql-ssh-tunnel/
HeidiSQL > Settings
Network Type: MySQL (SSH tunnel)
IP: enter ip of database server
User: user of database
Password: password of user
Port: 3306
HeidiSQL > SSH-tunnel
Plink.exe location: select file
SSH host + port: ip database server 22
username: username of database server
password: (keep empty)
plink.exe time-out: 15
private key file: (select file you generated in putty)
local port: 3307
This section is added by request for SSH access to server ;)
user = your name
cd /home
ls -al
drwx------. user user
cd /home/user
ls -al
drwx------. 4 user user 4096 Oct 20 15:23 .
drwxr-xr-x. 5 root root 4096 Oct 23 18:51 ..
-rw-------. 1 user user 1305 Oct 23 19:57 .bash_history
-rw-r--r--. 1 user user 18 Oct 30 2018 .bash_logout
-rw-r--r--. 1 user user 193 Oct 30 2018 .bash_profile
-rw-r--r--. 1 user user 231 Oct 30 2018 .bashrc
drwx------ 2 user user 4096 Sep 27 12:28 MyNotes
-rw------- 1 user user 16 Oct 20 15:23 .mysql_history
drwx------ 2 user user 4096 Oct 20 09:32 .ssh
cd /home/user/.ssh
drwx------ 2 user user 4096 Oct 20 09:32 .
drwx------. 4 user user 4096 Oct 20 15:23 ..
-rw-r--r-- 1 user user 410 Oct 20 09:32 authorized_keys
Still problems with ssh public key access? Check this link
Make sure you have a user folder in your /home folder where the webapp will run from, something like:
/home/username (it's good to name this after your webapp).
we create that by making a new user:
NOTE: username in these commands is always the name of your webapp!
adduser username
passwd username
get root su -
and cd into /home/username
make 2 log files and 2 folders:
touch access.log
touch error.log
mkdir username
This is actually again the name of your webapp/username, in here will go all project files.
mkdir .ssh
change permissions on the whole webapp folder so apache can read and execute as a group:
cd /home
chmod -R 750 username
chgrp -R apache username
make sure your sites-available file is changed to correspond with the new directory for serving the webapp
nano /etc/httpd/sites-available/appYOURNAME.thecreativitygym.be.conf
Change 4 things here:
-> 1st line: Directory "/home/username/username/github_projectname/public"
->inside the VirtualHost:
=> DocumentRoot /home/username/username/github_projectname/public
=> ErrorLog /home/username/error.log
=> CustomLog /home/username/access.log combined
Save and exit this file
Change the httpd.conf file's DocumentRoot
nano /etc/httpd/conf/httpd.conf
-> search for DocumentRoot and change the path to "/home/username/username/github_projectname"
restart apache
systemctl restart httpd
Create the SSH key for Github
ssh-keygen -t rsa -b 4096 -C "[email protected]"
User your Github email address!
It will ask for a place to save the file
/home/username/.ssh/id_rsa
Enter a passphrase if you want to, it will ask this later if you try to access the SSH key.
Add your SSH key to the SSH agent:
eval "$(ssh-agent -s)"
ssh-add /home/username/.ssh/id_rsa
Finally:
cat /home/username/.ssh/id_rsa.pub
copy this output from "ssh-rsa" until your email address from the terminal window.
Only for owner repository
Go online to the Github repo -> settings -> Deploy keys -> add deploy key -> give it a name and paste in the public key.
For all users expect owner of repository
Make sure the owner of the repository has your key :)
First clone the project to your server:
git clone CLONE_HTTPS_URL
Check if all permissions in .ssh are owned by USERNAME, grouped by USERNAME and nothing for world.
This can be done by using following commands:
chown OWNERNAME FILE_NAME
chgrp GROUPNAME FILE_NAME
chmod PERMISSION_NUMBER FILE_NAME
Test your SSH connection to Github:
su - USERNAME
ssh -T [email protected]
Enter passphrase for key 'path':
Hi REPO_NAME! You've succesfully autheniticated, but GitHub does not provide shell access.
Git pull through SSH (deploy)
cd /home/USERNAME/USERNAME/laravel-stagevinder
git pull ssh://[email protected]/ArneAmeye/laravel-stagevinder.git
We don't have the .env file yet (it's excluded from the git repo).
paste your local .env data here and save: nano .env
Make sure you link up the DB credentials right!
You need to change the following variables:
APP_URL=YOUR SITENAME
DB_HOST
DB_DATABASE
DB_USERNAME
DB_PASSWORD
By now we added a whole new git repo in the server and a .env file, all of them need permissions for the apache group. As our site is located in the folder 'USERNAME', we change these permissions.
su -
Enter password:
cd /home/USERNAME/USERNAME
chmod -R 750 USERNAME
chgrp -R apache USERNAME
NOTE: Laravel needs write access for logs but also in the public/images folder to save our profile and banner pictures. Only these folders should have write access too!
CD into the laravel project folder.
chmod -R 770 storage
chmod -R 770 public/images
Installing following stuff for use of a laravel 6 project:
yum install php72w-mbstring
yum install php72w-dom
yum install php72w-pdo_mysql
Installing composer:
cd ~
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
Installing composer in laravel projects (this adds the vendor folder):
cd /home/USERNAME/USERNAME/laravel-stagevinder
composer install --no-dev
Change the permissions on vendor directory: chmod -R 770 vendor
Change owner in vendor directory: chown -R USERNAME vendor
Change the group in vendor directory: chgrp -R apache vendor
If everything went well: php artisan migrate
If access denied, check .env
file in laravel-stagevinder directory
Normally by following the tutorial above, your site should appear in appYOURNAME.thecreativitygym.be
If not, check appYOURNAME.thecreativitygym.be/index.php
If it shows, check following step:
nano /etc/httpd/sites-available/appYOURNAME.thecreativitygym.be.conf
Change line AllowOverride None
to AllowOverride All
systemctl restart httpd
or even better apachectl graceful
If the above didn't work:
Check errors on reload of your site: tail -f /home/USERNAME/error.log
Check if the path cd /home/USERNAME
has permissions for owner USERNAME and group apache by using following command ls -al
and later on chmod -R 770 USERNAME
Check if the index is correctly set: nano /etc/httpd/conf/httpd.conf
, make sure DirectoryIndex index.html
is set to DirectoryIndex index.html index.php
And of course systemctl restart httpd
or even better apachectl graceful
We are now going to add a https certificate to our site! This we need to use the Sociallite function :D
ssh name@ip
su -
yum install epel-release
now we are at it, make sure you are running the latest versions ;) : yum update
yum install wget
now you can follow this tutorial starting with step 3
Check the result!
nano /etc/httpd/sites-available/appYOURNAM.thecreativitygym.be.conf
add following lines to the section VirtualHost:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
apachectl graceful
Check if it works :D
Done! Feel free to ask questions, might have missed some stuff π
Envoy needs to be configured LOCALLY!
Install Envoy: composer global require laravel/envoy
Make sure you have 2 environments: production and staging folders in Linode, a separate DB for each of them and working URL's.
Create an Envoy file in the root of the Laravel project called 'Envoy.blade.php'.
It looks like this: (Replace your deploy username, IP adresss and foldernames!)
The people who don't have a beta server, remove all parts with staging.
@servers(['production' => ['[email protected] -p22'], 'staging' => ['[email protected] -p22']])
@task('deploy-production', ['on' => 'production'])
cd /home/FOLDERNAME/FOLDERNAME/laravel-stagevinder
php artisan down
git reset --hard HEAD
git pull ssh://[email protected]/ArneAmeye/laravel-stagevinder.git
php artisan migrate --force
php artisan up
@endtask
@task('deploy-staging', ['on' => 'staging'])
cd /home/FOLDERNAME-beta/FOLDERNAME-beta/laravel-stagevinder
php artisan down
git reset --hard HEAD
git pull ssh://[email protected]/ArneAmeye/laravel-stagevinder.git
php artisan migrate --force
php artisan up
@endtask
Now run the deployment (in vagrant) with: envoy run deploy-staging
or envoy run deploy-production
ISSUES?
- SSH key for the deploy user must be setup!
If you have done this but it tries to load it from "C/users/yourname/.ssh/id_rsa" then we need to tell Windows where this Linode host can find our Private Key:
Go to "C:/User/Yourname/.ssh" and create aconfig
file if it doesn't exist yet.
Paste this and adapt to your configuration:
Host 139.XXX.XXX.XXX
HostName 139.XXX.XXX.XXX
User deployUsername
IdentityFile ~/.ssh/YourPrivateKeyFileName
NOTE: Recommended to place your Private SSH key or a copy of it inside this .ssh folder so the last line of this file can find it easily (or adapt the whole path...).
- No access to remote repository? Then change the line
ssh://[email protected]/ArneAmeye/laravel-stagevinder.git
intohttps://USERNAME:[email protected]/ArneAmeye/laravel-stagevinder.git
What isPASSWORD_WITHOUT_SPECIALCHARS
? If you use special characters in your password, you need to replace it by (following this link)[https://support.brightcove.com/special-characters-usernames-and-passwords]. Adding this to your github link in your .env is recommended.
@setup
require __DIR__.'/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__);
try {
$dotenv->load();
$dotenv->required(['DEPLOY_USER', 'DEPLOY_SERVER', 'DEPLOY_BASE_DIR', 'DEPLOY_REPO'])->notEmpty();
} catch ( Exception $e ) {
echo $e->getMessage();
}
$gitUrl = env('GIT_URL');
@endsetup
@task('deploy-production', ['on' => 'production'])
...
git pull {{ $gitUrl }}
...
@endtask
- Error on bootstrap folder?
chmod -R 775 bootstrap/cache
andsystemctl restart httpd
- Error on storage folder with permissions denied?
chmod -R 775 storage
andchgrp -R apache storage
- Errors about a package not found? Then add
composer install
after the git pull line in your Envoy.blade.php - Still errors? Then ask in chat π
- First, make an new directory with a new laravel project (
composer create-project --prefer-dist laravel/laravel nameOfProject
). - Follow the tutorial on this website.
- Tips when following the turorial:
- I recommend spliting following command in
docker-compose up -d --build database && docker-compose up -d --build app && docker-compose up -d --build web
intodocker-compose up -d --build database
,docker-compose up -d --build app
anddocker-compose up -d --build web
;) - Did you get an error after running the command
docker-compose up -d --build app
? It is about the php artisan optimize command? Then delete that line in the development > app.dockerfile.
- I recommend spliting following command in
Add Dusk with composer: composer require --dev laravel/dusk
Install Dusk:
vagrant ssh
cd code
php artisan dusk:install
Make sure our .env file has the right URL (http://homestead.test) for "APP_URL".
Within the .env also change the DB HOST (ip) to the IP found in Homestead.yaml
Add [email protected]
and DUSK_PASSWORD=yourpassword
to the .env file, this is needed for a login test that i've written!
You can make a ".env.dusk.local" file filled with a copy of the ".env" file in case you want Dusk to use other settings of your .env file, however right now this is not needed.
All Dusk tests can be found in (folders): "tests->Browser"
We can run a test with: php artisan dusk
Note: do this in your local terminal, not inside the vagrant ssh terminal!
Maybe try set the permissions right: chmod -R 0755 vendor/laravel/dusk/bin/
Error: Failed to connect to localhost port 9515: Connection refused
sudo apt-get update
sudo apt-get -y install libnss3 chromium-browser
Error: session not created: Chrome version must be between 70 and 73
Exit the Virtual Box and run composer require --dev staudenmeir/dusk-updater
. Go back in your Virtual Box. Here you run php artisan dusk:update
. Test it again: php artisan dusk
.
You can make a new Dusk test with: php artisan dusk:make TestName
=> replace with a name for your test!
Arne ==> Login & home page
Lars ==> Regsiter for Companies/Students & Checking if you can visit the student page without Auth.