You are on page 1of 2

LARAVEL SETUP PROCESS IN PHP, MYSQL and NGINX:

##NGINX Installation:
sudo apt update
sudo apt upgrade
sudo apt install nginx -y
sudo systemctl status nginx
sudo systemctl disable --now apache2
sudo ufw status

##PHP and essential php packages:


sudo apt update
sudo apt install php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd
php-mbstring php-curl php-xml php-pear php-bcmath

##NGINX Configuration:
====================
sudo mkdir /var/www/domain_name
sudo chown -R $USER:$USER /var/www/domain_name

sudo vi /etc/nginx/sites-available/domain_name

server {
listen 80;
server_name domain_name www.domain_name;
root /var/www/domain_name/public;

index index.html index.htm index.php;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}

location ~ /\.ht {
deny all;
}

sudo ln -s /etc/nginx/sites-available/domain_name /etc/nginx/sites-enabled/


sudo nginx -t
sudo systemctl reload nginx

##MySQL Configuration:
====================
CREATE DATABASE db_name;
CREATE USER 'db_user'@'localhost' IDENTIFIED BY 'db_password';
GRANT ALL PRIVILEGES ON * . * TO 'db_user'@'localhost';
FLUSH PRIVILEGES;

##For Checking Users created:


mysql> use mysql;
mysql> SELECT user FROM user;

##Composer Installation:
======================
sudo apt install unzip
curl -sS https://getcomposer.org/installer -o composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`

cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php

HASH=`curl -sS https://composer.github.io/installer.sig`


echo $HASH

php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo


'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-
setup.php'); } echo PHP_EOL;"

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

##Enable SSL: Lets Encrypt (NGINX, Ubuntu 20.04)


=================================================

sudo snap install core


sudo apt-get remove certbot
sudo dnf remove certbot
sudo snap install --classic certbot
sudo certbot --nginx

Certificate location:
/etc/letsencrypt/live/domain_name/fullchain.pem
/etc/letsencrypt/live/domain_name/fullchain.pem

You might also like