Coder Social home page Coder Social logo

install-nginx-php7-on-aws-ec2's Introduction

Cheatsheet (Install nginx server + PHP 7 on AWS EC2 Linux)

Install PHP 7 on EC2 micro Instance running Amazon Linux Distribution

Install linux update, followed by GCC and Make

sudo yum -y update
sudo yum install -y gcc make

to see what's new (optional)

sudo yum install -y yum-plugin-changelog
sudo yum update --changelog

Install PHP

Install additional commonly used php packages

sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum install --enablerepo=webtatic-testing php70w php70w-devel php70w-fpm php70w-mysqlnd php70w-mbstring php70w-pdo php70w-mcrypt php70w-xml php70w-mbcrypt php70w-pear php70w-gd php70w-curl php70w-opcache php70w-pecl-apcu php70w-imap php70w-pecl-redis

install nginx

sudo yum install -y nginx 

Config

Php-fpm

/etc/php-fpm.d/www.conf(Add or uncomment by removing ; in the start)

[global]
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s

[www]
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0664
user = nginx
group = nginx

pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 200

php_admin_value[memory_limit] = 64M

### run at startup, and start them up
sudo chkconfig nginx on
sudo chkconfig php-fpm on
sudo service nginx start
sudo service php-fpm start

reload nginx config & restart

sudo nginx -s reload && sudo service nginx restart && sudo service php-fpm restart

to check php version

php -v

Database & Drivers

install mysql

sudo yum -y install mysql-server sudo service mysqld start

install mongodb driver for php7

sudo yum install -y openssl-devel 
sudo pecl install mongodb

Note:

  • check file exists ====> /usr/lib64/php/modules/mongodb.so
  • add extension=mongodb.so to php.ini

install composer

cd ~
curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar
mv composer.phar /usr/local/bin/composer

Errors

502 Bad Gateway NGINX or 502 Service Temporarily Overloaded

Filter by category

Check the owner permission for php-fpm sock (/var/run/php-fpm/php-fpm.sock) sudo chown -R nginx /var/run/php-fpm/php-fpm.sock

Happy Coding

๐Ÿ˜ƒ sdev.in

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.