According to : https://serversforhackers.com/video/apache-and-php-fpm
sudo apt-get update
sudo apt-get install -y vim tmux curl wget unzip software-properties-common
sudo add-apt-repository -y ppa:ondrej/apache2
sudo add-apt-repository -y ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-cache show apache2
sudo apt-cache show php5.6-fpm
sudo apt-get install -y apache2
cd /etc/apache2/mods-enabled
ll | grep mpm
# mpm_event is used!
sudo apt-get install -y php5.6-fpm \
php5.6-mcrypt php5.6-mysql php5.6-gd php5.6-curl
php -v
sudo service php5.6-fpm status
Edit /etc/php/5.6/fpm/pool.d/www.conf to listen on network listen = 127.0.0.1:9000:
sudo service php5.6-fpm restart
# See what's available
ll /etc/apache2/mods-available | grep proxy
# Enable proxy modules
sudo a2enmod proxy proxy_fcgi
sudo service apache2 restart
Virtualhost:
sudo vim /etc/apache2/sites-available/example.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAlias example.*.xip.io
DocumentRoot /var/www/example.com/public
<Directory /var/www/example.com/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
# 2.4.10+ can proxy to unix socket
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
# Else we can just use a tcp socket:
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>
sudo a2dissite 000-default
sudo a2ensite example
sudo service apache2 reload
sudo a2enmod rewrite
sudo vim /var/www/example.com/public/.htaccess
Add the below, then:
sudo service apache2 restart
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L].htaccess
sudo service apache2 restart