Philadelphia Reflections

The musings of a physician who has served the community for over six decades

Related Topics

No topics are associated with this blog

Amazon Web Services LAMP Server

Philadelphia Reflections is a traditional LAMP application:

The original ISP for Philadelphia Reflections had hardware problems in early 2019, an annual feature of these people, and when they finally came back online after weeks of darkness, they supported only PDO as a MySQL interface to PHP.

Since I had to convert to PDO anyway, I decided to move to AWS so that I would have end-to-end control and eliminate my reliance on an unreliable ISP. Turns out it’s a lot cheaper, too, and works like a champ. PDO happens to be an improvement as well.

As of August 2019, the conversion was complete. The configuration is:

The whole thing was loaded with the bash script below; it worked immediately and has not needed any modification since. I was pretty good at AWS already, but I think it would be pretty simple for anyone. Note that this is an AWS Linux AMI; Linux 2 has some differences.

I use an .htaccess file to control Apache for URL conversion, security, error pages and compression. Much easier than futzing with comf files.

FileZilla Pro gives GUI SSL access to both EC2 and S3 which makes routine updates and backups very easy. I have long used PHPStorm and Twig, which I highly recommend. phpMyAdmin is a must.

#!/bin/bash   
#
# update all software
# install apache, php, mysql
# start apache, set to auto-start, set permissions
#
yum update -y   
yum install -y httpd24 php70 mysql56-server php70-mysqlnd  php70-gd php70-common 
yum install php70-mbstring.x86_64 php70-zip.x86_64 -y   
service httpd start   
sudo chkconfig httpd on    
usermod -a -G apache ec2-user   
chown -R ec2-user:apache /var/www   
chmod 2775 /var/www   
find /var/www -type f -exec sudo chmod 0664 {} \;  
#
# set Apache default timezone
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
#
# install SSL/TLS software
#
yum install -y mod24_ssl
service httpd restart
mkdir -p /etc/httpd_backup
cp -r /etc/httpd  /etc/httpd_backup
yum-config-manager --enable epel
#
# start mysql
# install phpmyadmin  
service mysqld start   
cd /var/www/html   
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz   
mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1   
rm phpMyAdmin-latest-all-languages.tar.gz
cd
#
# start mysql, set auto-start
# download the latest philad backup & installation script 
#
service mysqld start   
chkconfig mysqld on   
mysql -u xxxx -e "SET PASSWORD FOR xxxx@localhost = PASSWORD('xxxxx')";   
mkdir /home/ec2-user/sql-backup
aws s3 cp s3://xxxxx/philad_philadelphiareflectionscom-2019-07-20.sql.gz /home/ec2-user/sql-backup
gunzip /home/ec2-user/sql-backup/philad_philadelphiareflectionscom-2019-07-20.sql.gz
aws s3 cp s3://xxxxxxx/setup-philad.sql /xxxxx/sql-backup
#
# give ec2-user access to /var/www
setfacl -Rm d:u:ec2-user:rwX,u:ec2-user:rwX /var/www


# manual configurations after the initial instance creation
# #########################################################
#
# MANUAL Enable .htaccess
#    sudo nano /etc/httpd/conf/httpd.conf
#    search ^W for AllowOverride
#    AllowOverride None ==> AllowOverride All for /var/www and /var/www/html
#    sudo service httpd restart
#
#    
#
# MANUAL set default php timezone
# sudo nano /etc/php.ini
#     date.timezone = "America/New_York"
#
#




Originally published: Sunday, September 01, 2019; most-recently modified: Monday, September 02, 2019

 

Please Let Us Know What You Think

 
 

(HTML tags provide better formatting)