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.
ASKER
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
php 5.6.
Functionallythe same, centos will maintain the app versions.
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.
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-availab
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>
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
I do receive the Ubuntu/Apache success page when I enter //localhost in web browser bar.
However, when I enter //localhost:80/marthatest.
The requested URL was not found on this server.
And yes the phpinfo.php page does exist under /var/www/marthatest.com directory.
What am I doing wrong now??
ASKER
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
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.
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
ASKER