Fading Coder

One Final Commit for the Last Sprint

Home > Tools > Content

Deploying a LAMP Stack on Ubuntu Server

Tools May 9 3

Establishing Remote Access and Privileged Users

Connect to the target machine via SSH using your terminal:

ssh <username>@<server_ip_address>
# Example: ssh admin@10.0.0.55

Operating directly as the root user is discouraged. Create a dedicated administrative account and grant it elevated privileges:

adduser deployer
usermod -aG sudo deployer

Switch to the new account before proceeding with package management.

Configuring the Apache Web Server

Update the package index and deploy the Apache HTTP daemon:

sudo apt update && sudo apt install apache2 -y

Verify that the service is active and configured to start on boot:

sudo systemctl is-active apache2
sudo systemctl enable apache2

Ubuntu relies on UFW for network traffic filtering. Permit standard web traffic by enabling the predefined Apache profile:

sudo ufw allow in "Apache Full"
sudo ufw status

Navigating to the server's public IP address in a browser should render the default Apache landing page.

Deploying and Securing MySQL

Install the relational database management system:

sudo apt install mysql-server -y

Confirm the database daemon is operational:

sudo systemctl status mysql

Execute the built-in security script to remove anonymous users, disable remote root login, and eliminate test databases:

sudo mysql_secure_installation

Follow the interactive prompts to enforce password validation policies and set a strong credential for the database administrator. Accept the default recommendations for subsequent security questions.

Integrating PHP and Required Modules

Install the core PHP interpreter alongside the Apache module and MySQL driver:

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

Dynamic applications typically require additional libraries. Deploy a comprehensive set of extensions in a single operation:

sudo apt install php-{curl,gd,xml,mbstring,zip,intl,soap,bcmath} -y

Reload the web server to apply the newly installed PHP modules:

sudo systemctl reload apache2

Valiadte the runtime environment by checking the installed version:

php -v
Tags: ubuntu

Related Articles

Efficient Usage of HTTP Client in IntelliJ IDEA

IntelliJ IDEA incorporates a versatile HTTP client tool, enabling developres to interact with RESTful services and APIs effectively with in the editor. This functionality streamlines workflows, replac...

Installing CocoaPods on macOS Catalina (10.15) Using a User-Managed Ruby

System Ruby on macOS 10.15 frequently fails to build native gems required by CocoaPods (for example, ffi), leading to errors like: ERROR: Failed to build gem native extension checking for ffi.h... no...

Resolve PhpStorm "Interpreter is not specified or invalid" on WAMP (Windows)

Symptom PhpStorm displays: "Interpreter is not specified or invalid. Press ‘Fix’ to edit your project configuration." This occurs when the IDE cannot locate a valid PHP CLI executable or when the debu...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.