EC2 Configuration - GnUfTw/Love-Is-Everywhere GitHub Wiki

Install Apache Web Server w/ PHP

Get latest bug fixes & security updates.

sudo yum update -y

Install Apache web server w/ PHP software package.

sudo yum install -y httpd24 php56

Start the web server.

sudo service httpd start

Configure web server to start with ea. system boot.

sudo chkconfig httpd on

Set File Permissions for Web Server

Add www group to EC2 instance.

sudo groupadd www

Add ec2-user to www group.

sudo usermod -a -G www ec2-user

Refresh permissions by logging out.

exit

Log back in & verify www group is in the command output.

groups

Change group ownership of _/var/www & content to www group.

sudo chown -R root:www /var/www

Change directory permissions of /var/www & subdirectories to add group write permissions & set group ID on subdirectories created in the future.

sudo chmod 2775 /var/www

find /var/www -type d -exec sudo chmod 2775 {} +

Recursively change permissions for files in /var/www directory & subdirectory to add group write permissions.

find /var/www -type f -exec sudo chmod 0664 {} +

Adding Environment Variables to Apache Configuration

I utilized environment variables to hold sensitive information. When a user submits a location they found the project box, they have to include a passphrase (written on the box) to ensure that someone can't enter a location unless they found the box. In my PHP code, I use the getenv() function to validate this passphrase.

I added an Apache environment variable by adding the following to my /etc/httpd/conf/httpd.conf apache configuration file.

SetEnv loe_passphrase <the_passphrase_here>