Thursday, February 12, 2015

Configure your LAMP on Amazon Elastic Compute Cloud (EC2) Red Hat instance

Connect to your instance via ssh

ssh -i aws-xxx.pem ec2-user@x.x.x.x 

Update Red Hat 

[ec2-user ~]$ sudo yum update -y 

Install the Apache web server, MySQL, and PHP

[ec2-user ~]$ sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support" 

Install the php-mysql package.

 [ec2-user ~]$ sudo yum install -y php-mysql 

Start the Apache web server.

[ec2-user ~]$ sudo service httpd start 
Starting httpd: [ OK ] 

Configure the Apache web server to start at each system boot.

[ec2-user ~]$ sudo chkconfig httpd on 

To set file permissions Add the www group to your instance.

[ec2-user ~]$ sudo groupadd www 

Add your user (in this case, ec2-user) to the www group.

[ec2-user ~]$ sudo usermod -a -G www ec2-user 

Log-out and log back in after above changes

[ec2-user ~]$ exit 

Verify your membership in the www group.

[ec2-user ~]$ groups
ec2-user adm wheel systemd-journal www

Change the group ownership of /var/www and its contents to the www group.

[ec2-user ~]$ sudo chown -R root:www /var/www 

Change the Directory permissions of /var/www and its subdirectories to add group write permissions and to set the group ID on future subdirectories.

[ec2-user ~]$ sudo chmod 2775 /var/www 
[ec2-user ~]$ find /var/www -type d -exec sudo chmod 2775 {} + 

Recursively change the File permissions of /var/www and its subdirectories to add group write permissions.
[ec2-user ~]$ find /var/www -type f -exec sudo chmod 0664 {} + 

Create a simple PHP file in the Apache document root.

[ec2-user ~]$ echo "" > /var/www/html/testphpinfo.php

View page


No comments: