Deployment Guide For Ubuntu Server From Scratch With Laravel GitHub
Deployment Guide For Ubuntu Server From Scratch With Laravel GitHub
vicgonvt / deployment_guide.md
Last active 2 months ago
Star
Code Revisions 11 Stars 213 Forks 159
deployment_guide.md
Let's take a
servers, look at
Setting Up setting-up-
laravel, settting up April
Laravel in servers, laravel-in-
coderstape, a server 1, ht
Ubuntu / laravel ubuntu-
coder's from 2019
DigitalOcean digitalocean
tape scratch for
Laravel.
In this post, we are looking at the steps necessary to create an Ubuntu droplet in
DigitalOcean from scratch. This is the companion guide to the video series in Laravel
5.8 from scrath. Follow along with those to get the video guide.
Part 1 https://coderstape.com/lesson/112-deployment-basic-server-setup-part-1
Part 2 https://coderstape.com/lesson/113-deployment-basic-server-setup-part-2
Part 3 https://coderstape.com/lesson/114-deployment-basic-server-setup-part-3
Getting Started
Paste key
Repeat steps for laravel user
su laravel then mkdir ~/.ssh fix permissions chmod 700 ~/.ssh
Setting Up Firewall
Enable Firewall
sudo ufw enable
Nginx
sudo apt update enter root password
MySQL
sudo apt install mysql-server enter Y to install
sudo apt install php-fpm php-mysql to install the basic PHP software
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name YOUR.DOMAIN.COM;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
sudo vim /var/www/html/info.php to start a new PHP file, fill it with <?php
phpinfo();
sudo rm /var/www/html/info.php optional command to get rid of test file
FLUSH PRIVILEGES;
exit
composer install
APP_NAME=Laravel
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=http://YOUR.DOMAIN.COM
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=root
DB_USERNAME=laravel
DB_PASSWORD=STRONG_PASSWORD_HERE
Modify Nginx
server {
listen 80;
listen [::]:80;
root /var/www/html/first-project/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name YOUR.DOMAIN.COM;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
sudo nginx -t
server {
listen 80;
listen [::]:80;
server_name YOUR.DOMAIN.COM;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name YOUR.DOMAIN.COM;
root /var/www/html/first-project/public;
ssl_certificate /etc/letsencrypt/live/YOUR.DOMAIN.COM/fullchain.pem;
ssl_certificate_key
/etc/letsencrypt/live/YOUR.DOMAIN.COM/privkey.pem;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-
SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-
AES256-SHA384;
ssl_prefer_server_ciphers on;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
}
sudo nginx -t
Extra Credit
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-
zsh/master/tools/install.sh -O -)" for Oh My Zsh
If you don't have AllowOverride set to All, your Laravel .htaccess file (/public/.htaccess) won't be
able to enable mod_rewrite, and your routes won't work.
I solved it by adding in block
<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>
I think you need to install php7.2-mbstring and php7.2-xml. You can see if you have mbstring enable
with:
If you got:
Try:
Thank you
@gabrielsmenezes I restarted with a new instance of Ubuntu 18.0.4 instead of Ubuntu 19 and it works
fine now, thanks!
@stesvis nice :)
Please сan you create record a tutorial about How to Set Up a Full-Featured Mail Server on Ubuntu 18.04
(e.g. with PostFix / iRedMail)
chmod -R 777
Encryption not working anymore therefore I dont get the ssl certificate, anybody have an idea how to fix
it?
Encryption not working anymore therefore I dont get the ssl certificate, anybody have an idea how to
fix it?
If u have problems, just restart nginx
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'IDENTIFIED BY 'muhamm4dy'' at line 1
Thanks
Thanks
No, it's from MySQL console. I already put Password like that.
GRANT ALL ON laravel.* TO 'laraveluser'@'localhost' IDENTIFIED BY 'password';
Any advice?
Thanks
mostafizurhimself commented on Jan 3, 2021
Not working on Laravel 8, Only home page is showing. Any other routes are not accessible. It returns 404
error.
No, it's from MySQL console. I already put Password like that.
GRANT ALL ON laravel.* TO 'laraveluser'@'localhost' IDENTIFIED BY 'password';
I had the same error, i've try with GRANT ALL PRIVILEGES ON database_name.* TO
'username'@'localhost'; and it works.
Not working on Laravel 8, Only home page is showing. Any other routes are not accessible. It returns
404 error.
location / {
try_files $uri $uri/ =404;
}
with
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
in the Let's Dial in The Laravel Ecosystem section, fourth line which is about granting all privileges to root
user on newly created database, the command should be
GRANT ALL PRIVILEGES ON laravel.* TO 'root'@'localhost';
thanks to this article link
abedcodes commented on Oct 27, 2021
there is a conflict between command 2 & 3, at line 2 we give the user & group full access to the storage &
bootstrap/cache(ie xwr),
in the next line however we change the permissions on all files of project including those two directories
to 755 which means taking away write permission from storage & bootstrap/cache directory which were
set in the line before! this causes an issue with laravel not being able to write to log file at
storage/log/laravel.log file.
& last line looks unnecessary to give the world write access to storage directory,
best regards :)
use this link to install certbot & get a certificate, ridiculously easy!
just select the webserver & os & follow easy instructions to get yours
now that i configured my server using this amazing reference & it is running & i am happy :))
i wanna thank Mr.Victor Gonzales for his amazing contents & contributions
wish you bests dear sir ❤️