Skip to content

Instantly share code, notes, and snippets.

@saxenap
Last active April 9, 2018 16:14
Show Gist options
  • Save saxenap/571c05380c62c865c96ef32c578eb573 to your computer and use it in GitHub Desktop.
Save saxenap/571c05380c62c865c96ef32c578eb573 to your computer and use it in GitHub Desktop.
Sets up Apache and Php-7 Environment with folder permissions.
#!/bin/bash
#
# Copyright (c) 2014-2017 Praveen Saxena <>
# License: BSD-3-Clause
#
# To get:
# rm -rf apache-php7-environment && wget -O apache-php7-environment https://gist.githubusercontent.com/saxenap/571c05380c62c865c96ef32c578eb573/raw && chmod 777 apache-php7-environment && ./apache-php7-environment
sudo ln -sf /usr/share/zoneinfo/EST /etc/localtime
echo " Timezone modified to EST."
yum -y update
yum -y install gcc gcc-c++ make
echo " Installed: Core Yum Packages."
yum -y install git
yum -y install pcre-devel
yum -y install httpd24-devel
chkconfig httpd on
echo " Installed: Apache Server."
yum -y install glibc-devel libcurl-devel libuuid-devel libyaml
yum -y install php71 php71-devel
yum -y install php71-json
yum -y install php71-mbstring
yum -y install php71-mcrypt
yum -y install php71-pecl-memcached
yum -y install php71-mysqlnd
yum -y install php71-opcache
yum -y install php71-pdo
#yum -y install php71-pecl-uuid
#yum -y install php71-pecl-yaml
echo " Installed: PHP 7.1 and Libraries."
#wget http://pear.php.net/go-pear.phar
#php go-pear.phar
#sed -i "$ s|\-n||g" /usr/bin/pecl
#pecl config-set php_ini /etc/php.ini
#pear config-set php_ini /etc/php.ini
#echo " Installed and Configured PEAR and PECL"
#printf "\n" | pecl install redis uuid uri_template-alpha
#echo " Installed: PECL Extensions"
sudo curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer
echo " Installed: Composer Package Manager."
groupadd www
usermod -a -G www apache
usermod -a -G www ec2-user
rm -rf /var/www/cgi-bin /var/www/icons /var/www/noindex /var/www/error
chgrp -R www /var/www
chown -R root:www /var/www
find /var/www -type d -exec sudo chmod 2775 {} +
find /var/www -type f -exec sudo chmod 0664 {} +
echo " /var/www folder permissions modified."
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
echo " PHPINFO available in /phpinfo.php"
service httpd restart
echo "Success: Environment Init Finished."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment