PRE-REQUISITES:
1) login to amazon.aws.com, and launch ubuntu 22.04 instance with 30 GB EBS
2) SSH to the AWS Server
To install the LAMP (Linux, Apache, MySQL/MariaDB, PHP) stack on Ubuntu 22.04, follow these steps:
Step 1: Update the System
Before you begin, ensure your package list and installed packages are up-to-date by running the following command:
sudo apt update && sudo apt upgrade -y
Step 2: Install Apache
Install Apache by running the following command:
sudo apt update
sudo apt install apache2
press Y and hit ENTER to continue
TEST:
http://your_server_ipVerify Apache Installation: After installation, you can check the status of Apache to ensure it's running:
sudo systemctl status apache2
Step 3: Install MySQL
1) Install MySQL Server:
sudo apt install mysql-server -y
Secure MySQL Installation: Once MySQL is installed, run the security script to secure your installation:
sudo apt install mysql-server
switch its authentication method from auth_socket to mysql_native_password
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
FLUSH PRIVILEGES;
TEST
SELECT user,authentication_string,plugin,host FROM mysql.user;
exit2)sudo mysql_secure_installation
--VALIDATE PASSWORD PLUGIN.-NO
REST- YES
Verify MySQL Installation: Check the MySQL service status:
sudo systemctl status mysql
Step 4: Install PHP 8.2
To install PHP 8.2 and all the necessary modules for Laravel on Ubuntu 22.04, follow these steps:
Step 1: Update the System
First, ensure your package lists are up-to-date:
Step 2: Add the PHP Repository
The default Ubuntu repositories might not have the latest PHP versions. To get PHP 8.2, you'll need to add the ondrej/php repository:
Install the
software-properties-common
package if it’s not already installed:sudo apt install software-properties-common -y
Add the PHP repository:sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2 php8.2-cli php8.2-fpm php8.2-mysql php8.2-pgsql php8.2-sqlite3 php8.2-xml php8.2-mbstring php8.2-curl php8.2-zip php8.2-bcmath php8.2-gd php8.2-intl php8.2-readline php8.2-soap php8.2-imagick -yStep 4: Install Composer (PHP Dependency Manager)
Download and install Composer:
curl -sS https://getcomposer.org/installer | php
2. Move Composer to a directory in your
PATH
:
sudo mv composer.phar /usr/local/bin/composer3. Verify Composer installation:
composer --version
Step 5: Configure Apache or Nginx (Optional)
If you're using Apache or Nginx, you might need to configure them to use PHP 8.2.
For Apache:
Install the PHP 8.2 module for Apache:
sudo apt install libapache2-mod-php8.2 -y
Disable the old PHP module and enable the new one:
sudo a2dismod php8.1
sudo a2enmod php8.2
4.Restart Apache2
sudo systemctl restart apache2
-------------------------------------------------------------------------------------------------------------------------
git clone
git checkout branch
sudo composer install --ignore-platform-req=ext-mongodb
----------------------------------------------------------------------------------
update DNS Record in the domain registrar add A record with elastic IP:--------------------------------------------------------------------
Step 1 — Create a conf file
Copy 000-default.com.conf
to create a new file in /etc/apache2/sites-available
:
$ cd /etc/apache2/sites-available $ sudo cp 000-default.com.conf example.com.conf
-include that directory to sites available
using <directoryname>.conf file- sudo nano
/etc/apache2/sites-available/directoryname.conf
<VirtualHost
*:80>
ServerName example.com
ServerAlias www.example.com //for www domain
DocumentRoot /var/www/html/example.com/public
<Directory /var/www/html/example.com>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Step 3 — Enabling a virtual host
-to enable the site
sudo a2ensite <directoryname>
-to
test for syntax errors
sudo
apachectl configtest
-syntax ok
-restart apache services
sudo systemctl restart apache2
Step 4— Enabling SSL
Install certbot
sudo snap install --classic certbot
$ sudo certbot --apache -d example.com -d www.example.com sudo systemctl restart apache2