Laravel Deployment Ubuntu
Laravel Deployment Ubuntu
Package needed :
apache2 or nginx webserver | php8.0 | mysql-server | zip | unzip |
ffmpeg | git | composer 2x | imagemagick | graphicsmagick |
libapache2-mod-php8.0
Credentials Needed :
Server SSH root access & Domain Access
First of all we need to login your server through ssh console using putty(for windows) or git
bash or terminal (Unix based system like mac, ubuntu etc..)
Now we need to run the command from our linux or windows terminal.
sudo apt-get update #For Repository Update
Php8.0-xm The Below Command for the php installation. Required php
package for laravel and composer
Need to Run This Command For Configure The php.ini Files for Avoiding
Another Server Issue.
sudo service apache2 restart #Restart Apache2 For Reflect The New
Changes
sudo service mysql restart #Restart Mysql Server
After restarting we need to upload/clone the source code in your webserver. For this process
you need to run the following command
Then You need to Upload The Files In Your WebServer or You Can Clone The Code From Your
Git Repository.
For example:
cd /srv/www/html
git clone https://github.com/project/repository.git
Otherwise you can manually upload your files/source code using filezilla or another ftp/sftp
client.
After That We need to create DataBase And Apache2 Virtualhost for your web application using
following command
Mysql Part
sudo -i #For go to the root user
mysql -u root -p #And Hit enter without password for mysql server
login
#For Create a new database user with mysql native password for phpmyadmin login
CREATE USER 'Your-DB-User-Name-Here'@'localhost' IDENTIFIED WITH
mysql_native_password BY 'Enter-Your-Secret-Password@Here';
#For grant permission to user in your new database
grant all privileges on Your-DB-Name-Here.* to Your-DataBase-User-
Here@localhost;
vim filename-whatever-you-want.conf
#Then hit Enter and copy and paste the following code in your terminal
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName example.com
ServerAlias www.example.com
ServerAlias www.another-traffic-you-want-to-forward-to-this-apps.com
#OtherWise you can remove the another server alias record
ServerAdmin [email protected]
DocumentRoot /path/to/your/source/code/public
After that we need to configure the php-fpm for your web application for run php under another
user:
#ConFigure listen on a TCP socket to a specific IPv4 address on a specific port.
After that we need to run the following command for reflect the changes:
#create an info.php file for get php version info, extertion info etc...
And now to to install the php dependency in your web application using this command
cd /path/to/your/web/application #Go to your project webroot
cp .env.example .env
vim .env
MAIL_HOST=smtp.email.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=Your-Email_Password-Here
MAIL_ENCRYPTION=tls
[email protected]
composer install
php artisan config:cache
php artisan migrate:refresh --seed
php artisan config:cache
For example
sudo chown -R ubuntu:ubuntu .
Everything is done and ust hits your application url in your browser and see the result.
And Thank You Very Much For Reading This Tutorial, If Anything Else In
There Then Don’t Heist Your Time To Ask Me.