1. Create password file and add user/pass:
sudo htpasswd -c /etc/httpd/passwd/.easybiny user
2. Add the following directive to your desired virtual host/folder:
<Directory "/var/www/html/easybiny/stage">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/passwd/.easybiny
Require valid-user
</Directory>
3. Test - it shall work like a charm:
After you have your site in place, but https traffic is not enabled, you shall follow the next steps to generate free certificate from https://letsencrypt.org/ :
1. Install and enable proper EPEL
cd /tmp
wget -O epel.rpm –nv https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y ./epel.rpm
2. Install required certbot tool:
sudo yum install python2-certbot-apache.noarch
3. Use following command to install first certificate with certbot:
sudo certbot -i apache -a manual --preferred-challenges dns -d easybiny.com
Note: At some point, you are prompted to deploy a DNS TXT record with the name “_acme-challenge.easybiny.com” with the supplied value.
If using AWS Route53, this is fairly simple by adding another TXT record with proper value.
Before going forward, please make sure the value was properly propagated:
nslookup
set ty=txt
>_acme-challenge.easybiny.com
4. Optional security step:
Edit the file
vi /etc/letsencrypt/options-ssl-apache.conf
Look for the line beginning with SSLProtocol and change it to the following - this is to prevent TLS 1.2 from being used:
SSLProtocol all -SSLv2 -SSLv3 -TLSv1
5. Restart Apache:
service httpd restart
6. Make sure port 443 is inbound enabled at AWS SecurityGroup Level.
Note: To renew certificate or add a new one (e.g. for subdomain like stage.easybiny.com), following commnad is to be used:
certbot certonly --webroot -w /var/www/html/easybiny/stage -d stage.easybiny.com
Important: If Basic Auth is enabled for the site, you will need to temporary disable it for the certificate renewal to succeed.
I'm getting a blank pahe for my 7.3 PHP page on top of Apache 2.4 and AWS Linux 2 OS:
<?
phpinfo();
echo "test";
?>
What I'm doing wrong? Well, it's just a php missing as per below:
<?php
phpinfo();
echo "test";
?>
After this addition, it works like a charm.
Following scenario is outlined below: First will install default PHP that comes with AWS Linux 2 (5.x) then will install by mistake 7.2 and after properly install 7.3. All steps are done using sudo root privilegies:
1. Check the following command to see available php packages available and versions:
yum list available php\*
2. Install PHP:
yum install php
3. Using the below command check installed version of PHP - it shall default to 5.x:
php -v
4. Install php 7.2 using amazon-linux-extras:
amazon-linux-extras install php7.2
5. Now you get proper version:
php -v
6. But wait, you want to install latest version (7.3), how do you do that? It shows enabled only 7.2:
amazon-linux-extras list
7. First, disable 7.2 version:
amazon-linux-extras disable php7.2
8. Enable 7.3:
amazon-linux-extras enable php7.3
9. Install PHP, it shall install 7.3:
yum install php
10. Check version:
php -v
PHP 7.3.11 (cli) (built: Oct 31 2019 19:16:47) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
Good Job! You are now using the latest and greatest PHP.
1. Install HTTPD on AWS Linux:
sudo yum -y install httpd
2. Start HTTPD service:
sudo service httpd start
3. Check status:
sudo service httpd status
Active: active (running) since Wed 2019-12-25 23:27:19 UTC; 1s ago
4. Default webfolder is under:
cd /var/www/html
5. Create a sample hmtl file:
touch index.html
vi index.html
Add Test:
Hello dtechie!
Save.
5. Under AWS Security Group, add the following inbound rule:
6. Test by navigating to instance public IP/DNS: