Friday, December 17, 2021

How To Run Apache2 With PHP7.2-FPM On Ubuntu 18.04.1 LTS

 PHP-FPM (FastCGI Process Manager) is an alternative implementation of PHP FastCGI. It provides some additional features like Adaptive process spawning which is useful for sites.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Our Server Specification:-
Os : Ubuntu 18.04.1 LTS Bionic Beaver 64Bit     || Hostname: www.yourdomain.com         || IP Address of Server:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -a ; getconf LONG_BIT
apt install -y apache2 php7.2 php7.2-common php7.2-cli php7.2-fpm  
a2enmod proxy_fcgi setenvif rewrite ; a2enconf php7.2-fpm ; systemctl start apache2 ; systemctl enable apache2
gedit  /etc/apache2/sites-available/000-default.conf &>/dev/null
<VirtualHost *:80>
    ServerAdmin admin@yourdomain.com
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    DocumentRoot /var/www/html/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <FilesMatch \.php$>
     SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>
</VirtualHost>
apache2ctl configtest ; echo '<?php phpinfo(); ?>' > /var/www/html/info.php
systemctl restart php7.2-fpm apache2 ; systemctl status php7.2-fpm
http://127.0.0.1/info.php   
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Method:2  
apt install -y apache2 php7.2 php7.2-common php7.2-cli php7.2-fpm  
a2enmod proxy_fcgi setenvif rewrite ; a2enconf php7.2-fpm ; systemctl start apache2 ; systemctl enable apache2
gedit /etc/apache2/sites-available/default-ssl.conf &>/dev/null
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
    </FilesMatch>
apache2ctl configtest ; echo '<?php phpinfo(); ?>' > /var/www/html/info.php
systemctl restart php7.2-fpm apache2 ; systemctl status php7.2-fpm
http://127.0.0.1/info.php  
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Optional Step: gedit /etc/php/7.2/fpm/php.ini &>/dev/null
file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Optional Step:
Apache2 FastCGI Module install Manuall :-
apt install gdebi -y
wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb
gdebi libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb
________________________________________________________________________________

No comments:

Post a Comment