OKdevTV Docs
Home OKdevTV
ESC
nginx 1 min read 1.2 KB Raw Markdown
On this page (4)

PHP-FPM with nginx

  • PHP FastCGI Process Manager
  • on AWS

install

text
sudo dnf install nginx -y
sudo dnf install php-fpm -y
text
sudo chmod 644 /var/log/nginx
sudo chown -R ec2-user:ec2-user /usr/share/nginx/html
echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/info.php

nginx config

text
sudo vi /etc/nginx/nginx.conf
text
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            try_files $uri =404;
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass   unix:/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

php-fpm config

text
sudo vi /etc/php-fpm.d/www.conf
text
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm.sock

listen.owner = nginx
listen.group = nginx
listen.mode = 0666

user = nginx

group = nginx
text
sudo service php-fpm restart
sudo service nginx restart

open http://ipaddress/info.php

참고