RMTWeb

View Original

Setting up the LAMP Stack from scratch on Ubuntu

When migrating servers to AWS, its great to be able to set them up easily and quickly. This is effectively a lovely cheat-sheet. By running the scripts below you can have a full LAMP Stack running on an EC2 instance running Ubuntu in less than 5 minutes./* Set locale to UK - V IMPORTANT!! */sudo locale-gen en_GB.UTF-8/* Run update and upgrades */sudo apt-get updatesudo apt-get upgrade/* Install Apache 2 */sudo apt-get install apache2/* Server internal firewall config */sudo ufw allow OpenSSHsudo ufw allow in "Apache Full"sudo ufw enable/* Install MySQL */sudo apt-get install mysql-servermysql_secure_installation(No,No,Yes,Yes,Yes,Yes)/* Install php and associated plugins as needed */sudo apt-get install php libapache2-mod-php php-mcrypt php-mysqlsudo apt-get install php-curl php-gd php-mbstring php-mcrypt php-xml php-xmlrpc/* Restart services */sudo systemctl restart apache2/* Update Apache2 config to allow .htaccess files and modified file permissions */sudo nano /etc/apache2/apache2.conf<Directory /var/www/html/>AllowOverride (Change None to All)</Directory>/* Turn on rewrite rules for Apache2 */sudo a2enmod rewritesudo systemctl restart apache2/* Update permissions so that FTP can write to the web root folder */sudo chown -R ubuntu:www-data /var/www/html/* Reboot server */sudo reboot