Skip to content

Instantly share code, notes, and snippets.

@hydeenoble
Forked from nrollr/Commands.sh
Last active November 17, 2018 14:04
Show Gist options
  • Save hydeenoble/41af7b686bd60a4703fc70b06d50fdfc to your computer and use it in GitHub Desktop.
Save hydeenoble/41af7b686bd60a4703fc70b06d50fdfc to your computer and use it in GitHub Desktop.
Install PHP and NGINX on Amazon Linux AMI
## Install NGINX
$ sudo yum install nginx -y
## Install PHP and PHP-FPM
$ sudo yum install php -y
$ sudo yum install php-fpm -y
## Configure NGINX (see below)
$ sudo nano /etc/nginx/conf.d/default.conf
## Configure PHP-FPM (see below)
$ sudo nano /etc/php-fpm.d/www.conf
## Add NGINX and PHP-FPM service start to boot sequence
$ sudo chkconfig nginx on
$ sudo chkconfig php-fpm on
## Start NGINX and PHP-FPM service
$ sudo service nginx start
$ sudo service php-fpm start
## Add <file>.php to /var/www/html
## Verify configuration via http://www.domain.com/<file>.php
# you can check this article for more
https://medium.com/@fdcgoncalves/how-to-install-nginx-php7-1-php-fpm-in-amazon-ami-ec2-for-laravel-5-x-ea4ca8b0fcb4
server {
listen 80;
server_name www.domain.com domain.com;
location / {
root /var/www/html;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args; #add this line if you can't access routes other than "/"
}
location ~ \.php$ {
root /var/www/html;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
## Comment out the following entries (with ;)
;listen = 127.0.0.1:9000
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0666
;user = apache
;group = apache
## Add the following values instead
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
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