How to install Lamp stack on AWS EC2 .htaccess enabled,get phpmyadmin,and backup database daily using automysqlbackup

Signup to AWS or login to your dashboard if you already have an account and then create an  EC2 instance, remember to associate an elastic IP.
Attach a security group to your instance to enhance better security, connect to your new instance  by SSH, check this link on how to connect to your instance via SSH....follow as it is
Install PHP, Apache, Mysql, PHPMyAdmin on your EC2 instance using this link ....follow as it is Jump point 8 for SSL creation and use this link
If you installed  PHPMyAdmin for which I recommend secure it using this link
Allow access privileges to the folders and the files.
sudo chgrp -R www-data /var/www/html
sudo find /var/www/html -type d -exec chmod g+rx {} +
sudo find /var/www/html -type f -exec chmod g+r {} +

Give access user read/write privileges to the folders and the files and permit folder access to traverse the directory structure.
sudo chown -R ubuntu /var/www/html/
sudo find /var/www/html -type d -exec chmod u+rwx {} +
sudo find /var/www/html -type f -exec chmod u+rw {} +

Make sure every new file after this is created with www-data as the 'access' user.
sudo find /var/www/html -type d -exec chmod g+s {} +
Final security cleanup, if you don't want other users to be able to see the data
sudo chmod -R o-rwx /var/www/html/
Make .htaccess work by running the following
First, run this command:-
sudo a2enmod rewrite
Navigate to the file /etc/apache2/sites-available/000-default.conf by typing this in the command line
sudo nano /etc/apache2/sites-available/000-default.conf

Edit 000-default.conf file, by adding  this

<Directory "/var/www/html">
  AllowOverride All

after the line DocumentRoot /var/www/html.If your root Html directory is something other, then write that:-

Open the file apache2.conf by using this command   sudo nano  /etc/apache2/apache2.conf
Remove comment sign (#) AccessFileName .htaccess if you find it before this line ( line number 187 approx.)
Then find the line where there is
<Directory /var/www/>
     Options Indexes FollowSymLinks
     AllowOverride None
     Require all granted

replace "AllowOverride None"  with  "AllowOverride All"

Setup AutoMySQLBackup

Step 1: Install AutoMySQLBackup
sudo apt-get update -y
sudo apt-get upgrade -y
sudo shutdown -r now
sudo apt-get install automysqlbackup

Step 2: Configure AutoMySQLBackup
sudo nano /etc/default/automysqlbackup


0 1


No Coments Available for This Post

Leave a Comment

Subscribe to our newsletter to get the latest News and offers..