Category: Linux

How to make phpmyadmin publicly available in aws ec2 bitnami ubuntu 16.04

Introduction

This article will be helpful for those who is using Ubuntu 16.04 – bitnami based server on amazon aws EC2 instance only. In this post i’m explaining how make phpmyadmin publicly available in bitnami based servers.

 

nano /opt/bitnami/apps/phpmyadmin/conf/httpd-app.conf

Use the following rules

<IfVersion < 2.3 >
Order allow,deny
Allow from All
Satisfy all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>

 

restart apache

sudo /opt/bitnami/ctlscript.sh restart apache

 

After doing the above step phpmyadmin will be accessible using the following url pattern

http://<your domian OR ip>/phpmyadmin

 

 

 

 

Integrate Let’s Encrypt on an Amazon Linux AMI EC2 Instance Using Certbot

I’m using some latest Amazon Machine Image ( AMI ) called LAMP Stack PHP 5.3 LTS, Actually i was using some old AMI that released in 2013 and the instance also created at that time. It was almost impossible for me to integrate certbot in it, so that i finally decided to migrate my codeignitor app into new instance that support php 5.3

Here also i struggled so much to integrate certbot but finally i did it by the following steps.

  1. cd /tmp
  2. git clone https://github.com/certbot/certbot
  3. cd certbot
  4. chmod a+x certbot-auto
  5. ./certbot-auto certonly --webroot -w /var/www/html/ -d <domainName> --debug
  6. sudo ln -s /etc/letsencrypt/live/<domainName>/fullchain.pem /jet/etc/apache//server.crt
    sudo ln -s /etc/letsencrypt/live/<domainName>/privkey.pem /jet/etc/apache//server.key
  7. cd /jet/etc/apache
  8.  nano httpd.conf
  9. uncomment the following line of code in httpd.conf file
  10. Include /jet/etc/apache//extra/httpd-ssl.conf
  11. nano extra/httpd-ssl.conf     // uncomment and set the following things with newly created crt and key file paths
  12. DocumentRoot
  13. ServerName
  14. SSLCertificateFile
  15. SSLCertificateKeyFile
  16. restart service by using the following command
  17. /jet/enter restart

Auto-renew your SSL certificates.

You are all set now. But take a note, Let’s Encrypt’s certificates are only valid for 90 days. This is to encourage users to automate their certificate renewal process. You can setup a cron job which will run everyday at a particular time to renew certificates. Certificates are renewed only when they expire.

  • To test the renewal process, you can do a dry run with certbot:
sudo /tmp/certbot/certbot-auto renew --dry-run

  • Then update the crontab:
sudo crontab -e
  • Then, add the following line to crontab:
12 3 * * *   /tmp/certbot/certbot-auto renew --post-hook "sudo /jet/enter restart" >> /etc/letsencrypt/log/renew.log

This runs the renew everyday at 3:12 am. Remember that certs don’t get renewed unless they are near to expiration, and monthly/weekly cron job would cause your existing certs to occasionally be expired already before they get renewed.

 

You can contact me in case you need any help to setup the above things, I will providing premium support

 

How to setup subdomain and virtual host in ubuntu 16.04 bitnami server

Introduction

This article will be helpful for those who is using Ubuntu 16.04 – bitnami based server on amazon aws EC2 instance only. I’m writing this blog post because, i did’t find any best blogs which explain how to create a subdomain in aws ec2 instance and which also using bitnami based image to configure the instance. I can see, so many blogs and stackoverflow results about this topic, but most of those are talking about creation of virtual host on the standard ubuntu server only. Actually creation of the virtual host was the complex task for me at first and subdomain creation is almost easy.

subdomain-virtual-host-on-bitnami-ubuntu-aws-ec2

Steps to create virtual host and create subdomain in bitnami based ubuntu server

  1. Login on your sever via terminal window with bitnami as the user
  2. Copy demo directory from /home/bitnami/stack/docs/demo to a new location ( You may rename the directory “demo” as something else )
  3. Change the path and hostname on the config files on the new demo directory with new file paths ( in my example, it is located in /home/bitnami/htdocs/demo )
  4. Include the path /home/bitnami/htdocs/demo/conf/httpd-vhosts.conf  on the /home/bitnami/stack/apache2/conf/bitnami/bitnami-apps-vhosts.conf file
  5. Restart the apache2 server ( sudo /opt/bitnami/ctlscript.sh restart )
    (  Virtual host creatio has been completed )
  6. Create a subdomain record ( ‘A’ Record ) on aws route53
  7. Check the sub domain on the browser after 5 minutes
  8. Upload your files to your subdomain root directory
  9. Hire me if you need more help ( optional  🙂

Please watch this video to get more clarity on this.

How to download all files from a web server using your linux machine

If you have enough experience in linux server or similar things then only use the following solution.

The Problem,

I have an Australian client, she want to migrate her websites to another hosting company, ixwebhosting.com was her old hosting company. There were not supporting her for anything related with web server problems like changing php versions and this server blocking suddenly stopped working and not supporting HTTP POST request sometimes. Actually I was working fine before. Finally I suggested to migrate to another hosting company called A2Host, they have some cool pricing plans and almost good technical support.

Actual problem starts when i try to using their ( ixwebhosting ) website control panel, It was not user friendly and don’t have most of the features available in CPanel, There was an Option for zip the project directory in their control panel, but it was not working anyway.  It is not possible to download all the files to my local machine using filezilla and again upload the same to the new service provider.

So, how can i solve this issue ?

Solution

1. I logged in the new webserver ( A2host ) via SSH

Find your webserver host, port number,  username and password , in case of A2H, username and password will be different than your usual login credentials of the control panel

login to the server via linux terminal or user putty in windows

2. Connecting to the old webserver from the current terminal window

Choose your directory you want to save the files being downloaded

use cd <your directory>

connect to the old server via FTP

use

lftp <hostname your using in you desktop ftp client such as filezilla>

ex: lftp web111.ixwebhosting.com

after doing this you have to login to FTP server

use

user <your ftp username>

ex: user webuser

now enter your password

Probably you will be logged in to the FTP server.

use the ls command to list all the directories and files

use the following command to download a particular directory to your new server

mirror <source directory> <target directory>

That’s it

NB: Please use experts help to do the same, otherwise it might cases server issues or data loss