Forked from yu81/InitAmazonLinux_201509_for_PHP7.sh
Created
February 3, 2016 03:13
-
-
Save phpdave/c6a5bb73b5e29cd7cfba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xv | |
# Initialize Amazon Linux AMI 2015.09 for PHP7 Web Application | |
# yum | |
# update default | |
sudo yum upgrade --enablerepo="*" -y | |
# install php | |
for i in $(seq 3) | |
do | |
[ ! -s remi-release-6.rpm ] && curl --connect-timeout 3 http://remi.kazukioishi.net/enterprise/remi-release-6.rpm > remi-release-6.rpm | |
done | |
sudo yum localinstall -y remi-release-6.rpm | |
sudo yum install unixODBC -y | |
sudo yum install scl-utils --enablerepo="*" -y | |
sudo yum install httpd --enablerepo="*" -y | |
sudo yum install mysql --enablerepo="*" -y | |
sudo yum install php --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-fpm --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-bcmath --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-cli --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-common --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-debuginfo --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-json --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-ldap --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-litespeed --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-mbstring --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-mysqlnd --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-odbc --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-opcache --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pdo --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-lzf --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-lzf-debuginfo --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-msgpack --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-uuid --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-uuid-debuginfo --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-xmldiff --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-redis --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-process --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-zip --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install php-pecl-redis --enablerepo="remi,remi-test,remi-php56*" --disablerepo="amzn*" -y | |
# install others | |
sudo yum install nginx --enablerepo="remi,remi-test,remi-php70*" -y | |
sudo yum install git --enablerepo="epel*,remi,remi-test,remi-php70*" -y | |
sudo yum install tig --enablerepo="epel*,remi,remi-test,remi-php70*" -y | |
sudo yum install redis --enablerepo="epel*,remi,remi-test,remi-php70*" --disablerepo="amzn*" -y | |
sudo yum install perl gawk bash zsh sed wget s3cmd rsync htop dstat memcached spawn-fcgi --enablerepo="*" -y | |
# New Relic | |
[ ! -s newrelic-repo-5-3.noarch.rpm ] && curl 'http://download.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm' > newrelic-repo-5-3.noarch.rpm | |
sudo yum localinstall newrelic-repo-5-3.noarch.rpm -y | |
sudo yum install newrelic-sysmond -y | |
sudo nrsysmond-config --set license_key=LICENSE_KEY # LICENSE_KEY required | |
sudo /etc/init.d/newrelic-sysmond start | |
sudo chkconfig newrelic-sysmond on | |
sudo yum install newrelic-php5 -y | |
sudo newrelic-install install | |
# Additional manual configration required for New Relic. | |
# See below. | |
# https://docs.newrelic.com/docs/agents/php-agent/installation/php-agent-installation-redhat-centos | |
# https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/php-agent-installation-non-standard-php-advanced | |
# edit php.ini | |
if [ -s /etc/php.ini ]; then | |
timezone_exists=$(sudo cat /etc/php.ini | egrep "^date.timezone = " | head -1 | awk '{if($1 ~ /date\.timezone/){print "true"}else{print "false";}}') | |
if [ "${timezone_exists:-_false}" != "true" ]; then | |
echo 'date.timezone = "Asia/Tokyo"' | | |
sudo cat /etc/php.ini - > ./php.ini.new | |
sudo cp -p /etc/php.ini /etc/php.ini.bak.$(date +%Y%m%d%H%M%S) | |
sudo mv -f ./php.ini.new /etc/php.ini | |
fi | |
fi | |
# Install composer for global. | |
if [ ! -s /opt/composer/composer.phar ]; then | |
mkdir -p /opt/composer | |
pushd /opt/composer | |
wget https://getcomposer.org/composer.phar | |
if [ -s composer.phar ]; then | |
php composer.phar global require symfony/console=~2.3 | |
# Install psysh | |
php composer.phar global require psy/psysh:dev-master | |
# Install Laravel | |
php composer.phar global require "laravel/installer=~1.1" | |
# Install Lumen | |
php composer.phar global require "laravel/lumen-installer=~1.0" | |
php composer.phar update | |
fi | |
popd | |
echo 'export PATH=/opt/composer/:$PATH' >> .bash_profile | |
ln -s /opt/composer/composer.phar /opt/composer/composer | |
chmod +x /opt/composer/composer.phar | |
echo 'export PATH=/opt/composer/vendor/bin:$PATH' >> .bash_profile | |
source .bash_profile | |
fi | |
# FuelPHP | |
curl 'http://get.fuelphp.com/oil' | sh | |
# TODO : configuration of nginx,php-fpm | |
# add www user | |
sudo groupadd www | |
sudo useradd www -g www | |
sudo chown -R www:www /var/www | |
sudo chmod 2775 /var/www | |
sudo find /var/www -type d -exec sudo chmod 2775 {} + | |
sudo find /var/www -type f -exec sudo chmod 0664 {} + | |
# override php-fpm.d/www.conf | |
sudo cp -p /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.bat.$(date +%Y%m%d%H%M%S) | |
wget https://gist.githubusercontent.com/YU81/375a0e91b9cfd15d4f2c/raw/php-fpm_d_www.conf | |
sudo cp -p php-fpm_d_www.conf /etc/php-fpm.d/www.conf | |
# override nginx.conf | |
sudo cp -p /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak.$(date +%Y%m%d%H%M%S) | |
wget https://gist.githubusercontent.com/YU81/b1b7ce53389374ca2711/raw/fuelphp_nginx.conf | |
sudo cp -p fuelphp_nginx.conf /etc/nginx/nginx.conf | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment