Get $100 in digital ocean credits: [ Ссылка ]
In this tutorial, I'm going to show you how to deploy a Laravel application to a Digital Ocean Ubuntu Linux VPS with Nginx and MySQL.
#### COMMANDS ###
- Server set up:
adduser name_of_user
usermod -aG sudo name_of_user
sudo - name_of_user
mkdir .ssh
chmod 700 .ssh
// vim or nano
vim .ssh/authorized_keys
// in your computers terminal cat the public key
cat ~/.ssh/id_rsa.pub
- Firewall configuration
sudo ufw allow 'Nginx HTTP'
- Mysql configuration
sudo mysql_secure_installation
sudo mysql -u root -p
// MySQL queries
create user 'username'@'localhost' identified by 'password';
alter user 'username'@'localhost' identified with mysql_native_password by 'password';
create database database_name;
grant all on database_name.* to 'username'@'localhost';
flush privileges;
exit;
- PHP extension
sudo apt update
sudo apt install php-bcmath php-mbstring php-xml
- Composer
sudo apt install unzip
curl -sS [ Ссылка ] |php
mv composer.phar /usr/local/bin/composer
- Clone and set up the app
sudo chown name_of_user ./
git clone url_from_github
cd repo_name
composer install
cp .env.example .env
php artisan generate:key
// vim or nano
vim .env
php artisan migrate --force
- Nginx configuration
sudo vim /etc/nginx/sites-available/tutorial
// nginx configuration
server {
listen 80;
server_name DOMAIN_NAME_OR_IP_ADDRESS;
root /var/www/name_of_repo/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ .php$ {
# HEY!!! make sure to use the PHP version that you have installed
# otherwise you will get an error
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/tutorial /etc/nginx/sites-enabled/tutorial
sudo nginx -t
sudo service nginx restart
// change owner of storage and bootstrap/cache
cd path/to/repo
sudo chown -R www-data.www-data storage
sudo chown -R www-data.www-data boostrap/cache
00:00 - Intro
00:35 - Create server
03:01 - User setup
05:57 - Firewall configuration
06:20 - Mysql configuration
10:04 - Install php extensions
11:01 - Composer installation
12:02 - Application setup
15:52 - Nginx configuration
17:57 - Change file permissions
18:36 - End
Ещё видео!