Last active
November 19, 2019 06:45
-
-
Save sebastiansommer/9c686008e75875609f9a42c4f96b16ce to your computer and use it in GitHub Desktop.
Install Nginx + PHP 7.3 for Flow Application
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
amazon-linux-extras install nginx1 | |
amazon-linux-extras install php7.3 | |
mkdir -p /var/www/html | |
chown -R ec2-user:nginx /var/www/html | |
cat << EOF > /etc/yum.repos.d/MariaDB10.repo | |
[mariadb] | |
name = MariaDB | |
baseurl = http://yum.mariadb.org/10.4/centos7-amd64 | |
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB | |
gpgcheck=1 | |
EOF | |
yum -y install MariaDB-server MariaDB-client | |
cat << EOF > /etc/php-fpm.d/www.conf | |
[www] | |
user = nginx | |
group = nginx | |
listen = /run/php-fpm/www.sock | |
listen.acl_users = apache,nginx | |
listen.allowed_clients = 127.0.0.1 | |
pm = dynamic | |
pm.max_children = 50 | |
pm.start_servers = 5 | |
pm.min_spare_servers = 5 | |
pm.max_spare_servers = 35 | |
slowlog = /var/log/php-fpm/www-slow.log | |
php_admin_value[error_log] = /var/log/php-fpm/www-error.log | |
php_admin_flag[log_errors] = on | |
php_value[session.save_handler] = files | |
php_value[session.save_path] = /var/lib/php/session | |
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache | |
EOF | |
# Configure NGINX | |
cat << EOF > /etc/nginx/nginx.conf | |
user nginx; | |
worker_processes auto; | |
error_log /var/log/nginx/error.log; | |
pid /run/nginx.pid; | |
# Load dynamic modules. See /usr/share/nginx/README.dynamic. | |
include /usr/share/nginx/modules/*.conf; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" ' | |
'\$status \$body_bytes_sent "\$http_referer" ' | |
'"\$http_user_agent" "\$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
# Load modular configuration files from the /etc/nginx/conf.d directory. | |
# See http://nginx.org/en/docs/ngx_core_module.html#include | |
# for more information. | |
include /etc/nginx/conf.d/*.conf; | |
} | |
EOF | |
cat << EOF > /etc/nginx/conf.d/###URL###.conf | |
server { | |
listen 80 ; | |
server_name ###URL###; | |
root /var/www/html/Web; | |
index index.php index.html index.htm; | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location / { | |
try_files \$uri \$uri/ /index.php?\$args; | |
} | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico)\$ { | |
expires max; | |
log_not_found off; | |
} | |
error_page 404 /404.html; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location ~ \.(php|phar)(/.*)?\$ { | |
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)\$; | |
fastcgi_pass unix:/run/php-fpm/www.sock; | |
fastcgi_intercept_errors on; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param FLOW_CONTEXT Production; | |
fastcgi_param FLOW_REWRITEURLS 1; | |
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; | |
fastcgi_param PATH_INFO \$fastcgi_path_info; | |
} | |
} | |
EOF | |
rm -f /etc/nginx/conf.d/php-fpm.conf | |
rm -f /etc/nginx/default.d/php.conf | |
systemctl start mariadb | |
systemctl enable mariadb | |
systemctl start nginx | |
systemctl enable nginx | |
systemctl start php-fpm | |
systemctl enable php-fpm | |
yum -y install git php-xml php-mbstring |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment