NeevAI SuperCloud
LoginSIGN UP
  • NeevCloud Account
    • Getting Started with Neev account
      • Create & activate NeevCloud account
        • NeevCloud Account Signup
          • Email Verification
          • KYC Validation
          • Enter Billing Profile
          • Payment Validation
        • Customer Validation Process for Indian Customers
          • If you are the primary contact of the Organization
          • If you are not a Primary Contact in NeevCloud Account
      • Customer Validation Process FAQs
  • NeevCloud Products
    • Dashboard
    • Computes
      • Compute Flavors
      • Getting Started Launch VMs
        • Launch Alma Linux
        • Launch Window Server
        • Launch Instance using the Password
      • Launch instance by 1-click Marketplace platform
        • Create a Tally instance from the Neevcloud Marketplace
        • Create a PostgreSQL instance from Neevcloud Marketplace
        • Create a Nginx instance from Neevcloud Marketplace
        • Create a MariaDB instance from Neevcloud Marketplace
        • Create a Docker instance from Neevcloud Marketplace
        • Create a Nodejs Instance from Neevcloud Marketplace
        • Create a MongoDB Instance from the Neevcloud Marketplace
        • Create a CloudPanel Instance from the Neevcloud Marketplace
        • Create a GitLab Instance from the Neevcloud Marketplace
        • Create a Ubuntu RDP Instance from the Neevcloud Marketplace
        • Create a Clickhouse Instance from the Neevcloud Marketplace
        • Create an OpenLiteSpeed WordPress Instance from the NeevCloud Marketplace
        • Create a FortiGate instance from the Neevcloud Marketplace
      • Manage Cloud Instance
        • Overview
        • Volumes
        • Snapshots
        • Networking
        • Security Group
          • Add Rules to the Security group
        • Rescale
        • Pricing
      • Default username of operating systems
      • Volume-based instances and image-based instances.
      • How to Delete the Instance
    • GPU
      • Deploy GPU Instance with Tesla T4
    • Networking
      • Network
        • Create a Network
        • Create Network With Private IP
      • LoadBalancer
        • Configure Load Balancing
      • Floating IPs
        • Create Floating IPs
        • Assign Floating IPs
      • Routers
        • Create Router
      • Security Groups
        • Add Security Group
        • Allow SSH Port to Specific IP Address
        • Allow ICMP for ping
        • Allow RDP Port to Specific IP Address
      • Subnets
        • Create Subnets
    • Volumes
      • Create a volume
      • Delete a volume
      • Attach Volume to Instance
      • Extend Instance Volume Size
      • To create a server using volume
    • Backups
      • Here's a guide on how to create a backup.
    • Snapshots
      • Create snapshosts
      • Create an Instance using Snapshot
    • Storage
      • Object storage
        • Create Bucket
        • Service URLs for NeevCloud S3
      • Neevcloud S3 integration
        • Connect Acronis Backup Gateway With Neevcloud Storage
        • Connect Veeam Backup Gateway With Neevcloud Storage
        • Connect MSP360 Backup With Neevcloud Storage
        • Connect Vembu Backup with Neevcloud storage
        • Connect Ahsay cloud backup suite(ACBS) with NeevCloud Storage
        • Connect ARQ Backup Solution with NeevCloud Storage
        • Backup your WordPress Site to Neevcloud s3 storage with using Updraft plugin
        • Connect Bucket with S3 Client
        • Connect Bucket with Cyberduck
        • Connect S3 storage to CPanel
        • Connect S3 Drive to NeevCloud S3 Bucket
        • Mount S3 Bucket to Linux operating system
        • How To Mount NeevCloud S3 Bucket as a Window Drive
      • S3 data migrations
        • Migrate from AWS s3 storage to NeevCloud s3 storage
        • Migrate from Wasabi s3 storage to NeevCloud s3 storage
    • Kubernetes
      • Launch Kubernetes Cluster
    • Financial Information
      • Add Fund
      • Bill History
      • Billing Address
      • How Does NeevCloud Billing Works
    • Access Details
      • SSH KEY
        • Generate SSH_KEY
      • Application Credentials
      • S3/EC2 Credentials
        • Create S3/EC2 Credentials
    • Abuse Complaints
      • What is Phishing?
    • Support
    • Security
  • NeevCloud Guide
    • NeevCloud KnowledgeBase
      • Set up LEMP (Linux, Nginx, MySQL, PHP) in Ubuntu Linux
      • Set up LAMP (Linux, Apache, MySQL, PHP) in Ubuntu Linux
      • Set up WordPress in Linux instance
      • Set up Plesk in Ubuntu
      • Set up Cpanel in Linux Instance
      • Set up Grafana
        • Install Grafana and Prometheus on Ubuntu 22.04
      • Set up a MongoDB Cluster using 3 Linux Instances
        • MongoDB Cluster with 3 Linux Instances
      • Setup Ansible Linux Instance and Application deployment on Instances
        • Deployment Application on Instances
      • Install Node.js & NPM on Linux
        • Installation of Node.js and NPM in Alma Linux
      • How to use SFTP for Uploading & Downloading files
      • Two-factor Authentication
      • How to use PuTTY for SSH key-based authentication
      • How To Create VPC on NeevCloud
      • How to Install Nginx on Ubuntu 22.04
      • How To Install Apache on Ubuntu 22.04
      • How To Install MySQL on Ubuntu 22.04
        • Mysql database backup and restore by mysqldump
      • How To Install MariaDB on Ubuntu 22.04
      • How To Install PostgreSQL on Ubuntu 22.04
      • How To Install MongoDB on Ubuntu 22.04
      • How To Install phpMyAdmin on Ubuntu 22.04
      • How To Open Port on Linux
      • How to Install Metabase on Ubuntu 22.04
      • How to transfer data from a Windows server to a NeevCloud bucket using Rclone
      • How to Integrate QNAP NAS storage and Backup to Neevcloud
      • How to Install Remote Desktop (xrdp) on Ubuntu.
      • Setup MLflow in Neevcloud Instance
      • Docker
        • Docker Installation in Ubuntu/Debian
        • Some Best practices for using Docker in application development include:
          • Create a Docker File and using Docker file Build Images
          • Docker Container
          • Docker-Compose
      • Acronis Backup Gateway With Neevcloud
    • Kubernetes
      • Deploy Nginx Service in Kubernetes
      • Deploy Lamp in Kubernetes with using Helm.
      • Deploy WordPress in Kubernetes.
      • Deploy Argocd in Kubernetes
      • Deploy Jenkins in the Kubernetes cluster
    • Troubleshoot
      • How to Access Instances
        • Access Linux instance
        • Access with Password Authentication
        • Access Windows Instance
        • Change the RDP Port and access the windows server
      • How to change the SSH Port
      • Troubleshooting Steps If your Instance is not accessible
      • How to Monitor Server Load on a Windows Cloud Instance
      • Why cloud instance is Out Of disk space
      • High Processor Load on your cloud instance
      • Steps If your Website URL is down
      • Best Practices After Reboot.
      • Reset the root password.
    • Use case
      • High-Level Architecture with Load Balancer and Jump Server in a VPC Setup
    • FAQ
      • Setup Zabbix app
      • How to change the instance Password
      • How to Access a Server Using a Static IP Address
      • What is the billing process for NeevCloud?
      • What payment methods are accepted by NeevCloud?
      • What happens if I miss a payment?
      • What is YAML
      • How can I get support for billing-related issues?
      • Can I contact NeevCloud's technical support team?
      • How to raise the ticket in the NeevCloud
      • Where can I find additional information on pricing and billing?
      • What are the terms and conditions for using Neevcloud services
Powered by GitBook
On this page
  • Prerequisites
  • Update && Upgrade the server
  • Install MySQL
  • Creating a MySQL Database
  • Installing and testing PHP processing
  • Modifying Apache's DirectoryIndex Configuration
  • Creating a Virtual Host for your Website
  1. NeevCloud Guide
  2. NeevCloud KnowledgeBase

Set up LAMP (Linux, Apache, MySQL, PHP) in Ubuntu Linux

In this guide, we will explain how to install the Linux, Apache, MySQL, and PHP (LAMP) stack on an Ubuntu 22.04 server. You will set up a basic web application to test the stack's functionalities.

PreviousSet up LEMP (Linux, Nginx, MySQL, PHP) in Ubuntu LinuxNextSet up WordPress in Linux instance

Last updated 6 months ago

LAMP: A Comprehensive Open Source Web Development Platform

LAMP, an acronym for Linux, Apache, MySQL, and PHP, serves as a robust open-source framework for web development. Utilizing Linux as the operating system, Apache as the web server, MySQL as the relational database management system, and PHP. LAMP is the go-to choice for creating dynamic websites and web applications. Its popularity stems from its flexibility, making it a staple in the web development community.

Prerequisites

It works on all Linux distributions.

  • Operating system used:

Update && Upgrade the server

Installing Apache and Updating the Firewall

To update and upgrade the package lists from the repositories, run the following command:

sudo apt update -y 
sudo apt upgrade -y

Install Apache

sudo apt install apache2 -y

Once the installation is complete, please modify your firewall settings as necessary.

sudo ufw app list

Here is what each of these profiles means:

Apache: This profile opens only port 80 (normal, unencrypted web traffic).

Apache Full: This profile opens both port 80 and port 443

Apache secure: This profile opens only port 443 (TLS/SSL encrypted traffic.)

To only allow traffic on port 80, use the Apache profile:

sudo ufw allow in "apache"
sudo ufw status 

The default Ubuntu Apache web page serves both informational and testing purposes.

Install MySQL

To store and manage data for your website, you must install a database system. MySQL is a widely used database management system, often partnered with PHP environments.

sudo apt install mysql-server -y

When the installation is finished, it’s recommended that you run a security script that comes pre-installed with MySQL. This script will remove some insecure default settings and lock down access to your database system.

sudo mysql

Start the interactive script by running:

sudo mysql_secure_installation 

This will ask if you want to configure the VALIDATE PASSWORD PLUGIN.

Answer Y for yes, or anything else to continue without enabling.

If you select "Yes," you'll need to choose a password validation level. Note that choosing the highest level 2means your passwords must include numbers, uppercase and lowercase letters, and special characters. Otherwise, you'll encounter errors.

Run these commands -

mysql -u root -p 

After executing the commands, please enter your password:

Creating a MySQL Database

To create a database in MySQL, follow these steps:

Open your terminal or command prompt. Log into MySQL with the command mysql -u username -p. Replace username with your MySQL username. You'll be prompted to enter your password.

Once logged in, create a new database by executing CREATE DATABASE mydatabase;. Replace mydatabase with your desired database name.

To verify the database was created, use SHOW DATABASES;. Your new database should appear in the list.

This process creates a new MySQL database ready for use.

To create a new database, run the following command from your MySQL console:

mysql> CREATE DATABASE example_database;

Now give this user permission over the example_database database:

mysql> GRANT ALL PRIVILEGES ON example_database.*  TO  'root'@'%';

Now, review MySQL configurations.

sudo mysql

Installing and testing PHP processing

Our setup includes Apache as the webserver to deliver content, MySQL for data storage and management, and PHP to process and render dynamic content to users.

sudo apt install php libapache2-mod-php php-mysql -y

After completing the installation, execute the command below to verify your PHP version:

php -v

Modifying Apache's DirectoryIndex Configuration

To adjust the file Apache uses by default when serving directories, edit the DirectoryIndex directive in your Apache configuration file (httpd.conf or apache2.conf depending on your operating system). This change alters which file types Apache prioritizes when a directory is accessed.

sudo vi /etc/apache2/mods-enabled/test.conf

It will look like this:

Add - index.php

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.p1 index.xhtml index.htm
</TfModule>

After restarting the Apache web server, confirm the apache2 service status using the systemctl command.

sudo systemctl restart apache2
sudo systemctl status apache2

Now that all your services are running create a PHP test script to confirm that Apache can handle and process requests for PHP files on the path /var/www/<DOMAIN_NAME>/.

vi info.php

Add the following text, which is valid PHP code, inside the file by typing i

<?php
phpinfo();ESC
?>

Press ESC :wq to save

To ensure everything is set up correctly, visit your SERVER_PUBLIC_IP address in your web browser for a spot check.

http://<SERVER_PUBLIC_IP>/info.php

Creating a Virtual Host for your Website

To create a directory for your_domain, follow these steps:

  1. Open your terminal.

  2. Navigate to the location where you want to create the directory.

  3. Enter the command mkdir your_domain and press Enter.

This creates a new directory named your_domain in the specified location.

sudo mkdir -p /var/www/example.com

To change the ownership of the directory to your current system user, use the $USER environment variable like this:

sudo chown -R $USER:$USER /var/www/example.com

To create a new configuration file within Apache's sites-available directory, use your favorite command-line editor. We will use vi for this example:

sudo vi /etc/apache2/sites-available/example.com.conf

To create a new blank file, insert the following base configuration and replace yourdomain.com with your actual domain name:

<VirtialHost *:80>
    ServerName <YOUR_DOMAIN>
    ServerAlias www.<YOUR_DOMAIN>
    ServerAdmin admin@localhost
    DocumentRoot /var/www/<YOUR_DOMAIN>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now, use a2ensiteto enable the new virtual host:

sudo a2ensite example.com

To disable the Apache default website—essential when not using a custom domain, as it would override your virtual host configuration—run the following command:

sudo a2dissite 000-default

Ensure Your Configuration File is Error-Free: To verify that your configuration file is free of syntax errors, execute the command below:

sudo apache2ctl configtest

Finally, reload Apache so these changes take effect :

sudo systemctl reload apache2

Your new website is now active, but /var/www/<YOUR_DOMAIN>is still empty. Create an index.html

vi /var/www/example.com/index.html

Include the following content in the file:

<html>
  <head>
    <title>your_domain website</title>
  </head>
  <body>
    <h1>Hello World!</h1>

    <p>This is the landing page of <strong>YOUR_DOMAIN</strong>.</p>
  </body>
</html>

Save and close the file, then go to your browser and access your server's domain name or IP Address:

http://<SERVER_PUBLIC_IP>
http://<YOUR_DOMAIN>

You can leave this file in place as a temporary landing page for your application until you set up a index.php file to replace it. Once you do that, remember to remove or rename the index.html file from your document root, as it would take precedence over a index.php file by default.

Login to browser -

Ubuntu 22.04
Install Apache
Install MySQL
Install PHP
http://your_server_IP