Skip to content

Instantly share code, notes, and snippets.

@macerier
Forked from sumardi/nginx.default.conf
Last active December 6, 2019 07:06
Show Gist options
  • Save macerier/378202e77d7eb8ea0cf6cdf15f5ac059 to your computer and use it in GitHub Desktop.
Save macerier/378202e77d7eb8ea0cf6cdf15f5ac059 to your computer and use it in GitHub Desktop.
Install PHP-FPM, Nginx & MariaDB on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php70 php70-fpm
# Install PHP extensions
sudo yum install php70-gd
sudo yum install php70-imap
sudo yum install php70-mbstring
sudo yum install php70-mysqlnd
sudo yum install php70-opcache
sudo yum install php70-pecl-apcu
# Install PHP-APC
sudo yum install -y php-pecl-apc
sudo yum install -y pcre-devel
# Install MariaDB
/etc/yum.repos.d/MariaDB.repo
sudo yum install -y MariaDB-server MariaDB-client
# Nginx Configuration
sudo nano /etc/nginx/conf.d/default.conf
# PHP-FPM Configuration
sudo nano /etc/php-fpm.d/www.conf
# Autostart Nginx, PHP-FPM and MySQL
sudo chkconfig nginx on
sudo chkconfig mysql on
sudo chkconfig php-fpm on
# MariaDB 10.2 CentOS repository list - created 2017-06-19 06:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
server {
## Your website name goes here.
server_name domain.tld;
## Your only path reference.
root /var/www/html;
## This should be in your http block and if it is, it's not needed here.
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
[...]
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock
;listen.owner = nobody
listen.owner = nginx
;listen.group = nobody
listen.group = nginx
;listen.mode = 0666
listen.mode = 0664
user = nginx
group = nginx
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment