Link to home
Start Free TrialLog in
Avatar of Marthaj
MarthajFlag for United States of America

asked on

Installing Apache 2 with Php 5.6 and Php-5.6 fpm on UIbuntu 20.04 server

I need simple steps to install Apache2 and PHP 5.6-fpm on a Ubuntu 20.04 server.

I know there are a lot of examples on the Internet but I have not had much 

success with them -seems to be a 'gotcha' every time.

 I understand the value of PHP-fpm, but does regular PHP, i.e. PHP 5.6, need to also be installed  with the PHP 5.6-fpm? I

 have understood it to be one or other and to set Apache to which version which would also mean if using PHP-fpm, configuring Apache to use it.

I would appreciate it very much.

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I'll be the one to ask why you want to install an obsolete version of PHP?  Current version is 8.1 or 8.2.
Avatar of Marthaj

ASKER

Thank you for responding. I need to install it for a legacy system that will be eventually upgraded.
And the original app needs to loaded first to see the 'what-fors' and 'what-nots'
and 'jeez-petes' things....I think I may have php5.6-fpm and apache installed okay -
don't know yet - I still have 3 additional pkgs to install - all old versions...sigh
Potentially, you should load centos 7  it should come with
php 5.6.

Functionallythe same, centos will maintain the app versions.

Avatar of noci
noci

php comes in a few flavours:
php-fpm - fastcgi / CGI+ connected php (nginx, lighttpd, apache,...)

php-cgi - an external version for apache and old servers

php-mod - a module for apache

php-cli    - Command line php


the cli is for the command line (php as commands, or for cron jobs etc.)  - in general handy to have

php-mod used for  Apache internal inside apache (CGI module) 

php-cgi now mostly obsolete

php-fpm - FastCGI/ CGI+ connected php.

php-fpm can be run on another server, you can have multiple fpm services tuned for specific needs, where some PHP processes can be setup for large memory and others for fast database access etc. 


You may also want to investigate the use of nginx or lighttpd as those run circles around apache in almost any worlkload.

Avatar of Marthaj

ASKER


David - thank you for responding and hoped I answered your question as to why obsolete versions.
Arnold - it needs to be replicated as much as possible as to the original environment before upgrading, per client, hence, using a Ubuntu/Apache installation. Sigh, but a good thought. Thank you.
Noci - good information thank you.

I have finally been able to load Apache and PHP 5.6-fpm successfully.
I also created a website - /var/www/marthatest.com. Created a phpinfo.php page in it. And created the marthatest.conf in /etc/apache2/sites-available.
Here is the contents of that file:

<VirtualHost *:80>

   ServerName marthatest.com
   
   ServerAlias www.marthatest.com

    DocumentRoot "/var/www/marthatest.com/"
  
     <Directory "/var/www/marthatest.com/>"
      Options -Indexes +FollowSymlinks
      AllowOverride All
      Allow from All
     </Directory>

  ErrorLog ${APACHE_LOG_DIR}/marthatest-error.log
  CustomLog ${APACHE_LOG_DIR}/marthatest-access.log combined

</VirtualHost>

Open in new window


Apache2 has no errors, the php5.6-fpm is active w/o errors and shows correct version of PHP is running -

marthaj@testserver:/etc/apache2/sites-enabled$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-01-12 12:17:03 EST; 1min 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 6106 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
    Process: 6263 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
   Main PID: 6110 (apache2)
      Tasks: 55 (limit: 8698)
     Memory: 5.1M
     CGroup: /system.slice/apache2.service
             ├─6110 /usr/sbin/apache2 -k start
             ├─6267 /usr/sbin/apache2 -k start
             └─6268 /usr/sbin/apache2 -k start

Jan 12 12:17:03 testserver systemd[1]: Starting The Apache HTTP Server...
Jan 12 12:17:03 testserver systemd[1]: Started The Apache HTTP Server.
Jan 12 12:17:23 testserver systemd[1]: Reloading The Apache HTTP Server.
Jan 12 12:17:23 testserver systemd[1]: Reloaded The Apache HTTP Server.
Jan 12 12:17:55 testserver systemd[1]: Reloading The Apache HTTP Server.
Jan 12 12:17:55 testserver systemd[1]: Reloaded The Apache HTTP Server.

marthaj@testserver:/etc/apache2/sites-enabled$ service php5.6-fpm status | grep running
     Active: active (running) since Thu 2023-01-12 11:10:06 EST; 1h 32min ago

marthaj@testserver:/etc/apache2/sites-enabled$ php -v
PHP 5.6.40-64+ubuntu20.04.1+deb.sury.org+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Open in new window


I do receive the Ubuntu/Apache success page when I enter //localhost in web browser bar.
However, when I enter //localhost:80/marthatest.com/phpinfo.php or //localhost/marthatest.com- I receive this:

The requested URL was not found on this server.

Open in new window


And yes the phpinfo.php page does exist under /var/www/marthatest.com directory.
What am I doing wrong now??

ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Marthaj

ASKER

Thank you for responding.
noci - I added www.marthatest.com to my host file and used http://www.marthatest.com -  did not display the Ubuntu/Apache page.
I realized I should have a2dissite the default-000-conf file which I did - stopped marthatest.com, restarted it, reload Apache.
Once I did all that I could display the Ubuntu/Apache page with just localhost and my phpinfo.php with localhost/phpinfo
I also re-examined my PHP Info page and spotted an error - the first line was incorrect:

I had this: <? php

But should have been <?php

Open in new window


That took care of the not displaying problem.

I need to list out step-by-step for adding websites. I seem to always become confused.
I know it is not rocket science - lol.
Not sure I undertand,
Upgrading OS would potentially result in app version upgrades from mysql, mariadb,Apache, php with which the PHP code might not be compatible.

I read your question as an intermediary step to host the existing site while any incompativilities are worked out with updating the php, db interactionswith the newer versioni
Avatar of Marthaj

ASKER

Thank you. You are correct Arnold about this installation - it is only an intermediary step but still has to be executing correctly. prior to developing/implementing any upgrades.