ScAlAn

Amazon Linux + Apache + phpFPM

Task: Prepare environment with Apache and phpFPM

Implementation:

install apache:

yum install httpd

install php-fpm:

yum install php-fpm

add autostart:

chkconfig https on
chkconfig php-fpm on

set unix socket for php-fpm:

vi /etc/php-fpm.d/www.conf
comment row:
listen = 127.0.0.1:9000
add row:
listen = /var/run/php-fpm.sock

add demo project into apache :

<VirtualHost *:80>
DocumentRoot /var/www/html
<Directory /var/www/html>
Options -Indexes +FollowSymlinks +MultiViews
AllowOverride All
Require all granted
</Directory>

<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/"
</FilesMatch>
</VirtualHost>

Restart services:

service php-fpm restart
service http restart

Create simple php file: /var/www/html/phpinfo.php:

<?php
phpinfo();

Test php working:

curl http://localhost/phpinfo.php

Check output:

$ curl -I http://localhost/phpinfo.php
HTTP/1.1 200 OK
Date: Fri, 15 May 2020 08:57:16 GMT
Server: Apache/2.4.41 ()
X-Powered-By: PHP/5.4.16
Upgrade: h2,h2c
Connection: Upgrade
Content-Type: text/html; charset=UTF-8

Leave a Reply

Your email address will not be published. Required fields are marked *