Skip to content

Instantly share code, notes, and snippets.

@santoshachari
Forked from sumardi/nginx.default.conf
Last active February 22, 2022 22:11
Show Gist options
  • Save santoshachari/23ef757d593e5ccd3d31 to your computer and use it in GitHub Desktop.
Save santoshachari/23ef757d593e5ccd3d31 to your computer and use it in GitHub Desktop.
PHP5.6 and NGINX: Install PHP56-FPM, Nginx & MySQL 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 php56-FPM
sudo yum install -y nginx php56-fpm
# Install php56 extensions
sudo yum install -y php56-devel php-mysql php56-pdo php56-pear php56-mbstring php56-cli php56-odbc php56-imap php56-gd php56-xml php56-soap
#Install php mysql for pdo
sudo yum install php56-mysqlnd
# Install php56-APC
sudo yum install -y php56-pecl-apc
sudo yum install -y pcre-devel
# Install MySQL
sudo yum -y install mysql-server mysql
# Nginx Configuration
sudo nano /etc/nginx/conf.d/default.conf
# php56-FPM Configuration
sudo nano /etc/php-fpm.d/www.conf
# Autostart Nginx, php56-FPM and MySQL
sudo chkconfig nginx on
sudo chkconfig mysqld on
sudo chkconfig php-fpm on
server{
location / {
root /var/www/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
include fastcgi_params;
}
}
[...]
user = nginx
group = nginx
;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
[...]
@punchi
Copy link

punchi commented Nov 17, 2015

thanks for the instructions =) some questions, why install "gcc", "make" and "pcre-devel" ? if you already have php56-mysqlnd, you need php-mysql too?

@santoshachari
Copy link
Author

@punchi, Just a fork of this version https://gist.github.com/sumardi/5559803.
Had to fix to work for 5.6. You could be right of not needing it.

@Modelizer
Copy link

Modelizer commented May 22, 2016

It seems that sudo nano /etc/nginx/conf.d/default.conf should be change to sudo nano /etc/nginx/nginx.conf or else might be some nginx version conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment