Skip to content

Instantly share code, notes, and snippets.

@sl-digital
Last active May 24, 2021 11:03
Show Gist options
  • Save sl-digital/9838411 to your computer and use it in GitHub Desktop.
Save sl-digital/9838411 to your computer and use it in GitHub Desktop.
Install Apache, MySQL and PHP 5.5 on Amazon Linux AMI
:: UPDATE YUM ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo yum update -y
:: INSTALL WEBSERVER :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo yum install httpd24
sudo service httpd start
sudo chkconfig httpd on
chkconfig --list httpd
:: CONFIGURE HTTPD :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo nano /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
Options All
AllowOverride All
Require all granted
</Directory>
:: CONFIGURE VHOSTS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo nano /etc/httpd/conf.d/vhosts.conf
<create log and vhost folders in html>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/var/www/html"
ErrorLog "/var/www/html/logs/error_log"
CustomLog "/var/www/html/logs/access_log" combined
<Directory "/var/www/html">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.other-site.com
ServerAlias *.other-site.com
DocumentRoot "/var/www/html/www.other-site.com"
ErrorLog "/var/www/html/www.other-site.com/logs/error_log"
CustomLog "/var/www/html/www.other-site.com/logs/access_log" combined
<Directory "/var/www/html/www.other-site.com">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
:: ADD EC2 USER TO WWW :::::::::::::::::::::::::::::::::::::::::::::::::::::::
ls -l /var/www
sudo groupadd www
sudo usermod -a -G www ec2-user
<exit>
<login>
groups
sudo chown -R root:www /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} +
find /var/www -type f -exec sudo chmod 0664 {} +
:: ADD APACHE USER TO WWW :::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo usermod -a -G www apache
<also change the apache config to use apache:www>
:: INSTALL MYSQL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo yum localinstall http://repo.mysql.com/mysql-community-release-el6-3.noarch.rpm
sudo yum install mysql-community-server
sudo service mysqld start
sudo /usr/bin/mysql_secure_installation
<enter>
<new-pass>
<new-pass>
<Y>
<Y>
<Y>
<Y>
sudo chkconfig mysqld on
:: INSTALL PHP 5.5 WITH MYSQL AND SOME BASICS ::::::::::::::::::::::::::::::::
sudo yum install php55 php55-devel php55-common php55-cli php55-pecl-apc php55-pdo php55-mysql php55-xml php55-gd php55-mbstring php-pear php55-mysqlnd php55-mcrypt
sudo service httpd restart
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
:: EDIT PHP.INI ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sudo nano /etc/php.ini
expose_php = Off
error_log = /var/log/php-error.log
date.timezone = "America/Chicago"
sudo service httpd restart
:: ADD KEY for TRANSMIT FTP ::::::::::::::::::::::::::::::::::::::::::::::::::
<cd to directory with key>
ssh-add [yourkey].pem
@niklasenB
Copy link

line 75 can be updated to

sudo yum localinstall http://repo.mysql.com/mysql-community-release-el6-7.noarch.rpm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment