Created
May 10, 2022 15:23
-
-
Save koramit/98413776ea74d83d2e0eeca9219292a7 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
#!/usr/bin/env bash | |
set -e | |
## | |
# Note: This script is assumed to be run as user root | |
## | |
## Add PHP repository | |
add-apt-repository -y ppa:ondrej/php | |
## Add nginx mainline repository | |
add-apt-repository -y ppa:ondrej/nginx-mainline | |
apt-get update | |
## Install utilities and PHP | |
## Configure PHP-FPM to run as user "ubuntu" | |
## php8.1-readline php8.1-igbinary(optimize memcached), php8.1-ldap | |
apt-get install -y ca-certificates curl wget jq zip unzip ripgrep pv \ | |
nginx supervisor \ | |
php8.1-fpm php8.1-cli \ | |
php8.1-pgsql php8.1-sqlite3 php8.1-gd php8.1-imagick \ | |
php8.1-curl php8.1-memcached \ | |
php8.1-imap php8.1-mysql php8.1-mbstring \ | |
php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \ | |
php8.1-intl \ | |
php8.1-msgpack \ | |
php8.1-redis \ | |
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ | |
&& sed -i "s/user = .*/user = ubuntu/" /etc/php/8.1/fpm/pool.d/www.conf \ | |
&& sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/8.1/fpm/php.ini \ | |
&& sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/8.1/fpm/php.ini \ | |
&& service php8.1-fpm restart \ | |
&& curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh \ | |
&& bash nodesource_setup.sh \ | |
&& apt-get install -y nodejs \ | |
&& rm nodesource_setup.sh | |
systemctl enable nginx | |
## init test default page | |
mkdir /home/ubuntu/html | |
tee /home/ubuntu/html/index.php > /dev/null <<EOT | |
<?php | |
phpinfo(); | |
EOT | |
## Install h5bp nginx config and default server block | |
service nginx stop | |
cd /etc | |
mv nginx nginx-previous | |
git clone https://github.com/h5bp/server-configs-nginx.git nginx | |
cd /etc/nginx/conf.d | |
rm .default.conf no-ssl.default.conf | |
wget https://gist.githubusercontent.com/koramit/0da934c0d56736793ff66a6dd1cfea66/raw/963729a2cd15bcd2bc3251cab38106538ea8d830/default.conf | |
# install-specific edits | |
service nginx start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment