Deploying a LAMP Stack on Ubuntu Server
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