We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon 4 on PHP 7.4 - can't follow install instructions successfully

I want to turn up an AWS EC2 server so I can make an AMI from it and use it in an auto-scaling load balanced group. I am failing left and right. I'm not espceially Linux-aware and I am out of my element.

My end result goal is an Ubuntu 18.04/PHP 7.4/Phalcon 4 server. I think i need to install the Phalcon devtools, too, in order to have it set up the applpication folder and subfolders automatically for me? I may need this explained like I'm a brand new student.


What I’ve done so far:

  • T2.micro instance size
  • Launch EC2 using Free Tier Ubuntu 18.04 (ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20200611 (ami-0ac80df6eff0e70b5))
  • Setup elastic IP and assign to staging instance
  • Install Apache
    • Putty to EC2 instance
    • sudo apt-get update
    • sudo apt-get install apache2
    • Config UFW firewall
      • sudo ufw app list
      • sudo ufw allow 'Apache'
  • Install PHP 7.4
    • sudo apt upgrade
    • upgrades all current packages (there were a bunch)
      • Kept local menu.lst etc., when asked
    • sudo apt install software-properties-common
    • sudo add-apt-repository ppa:ondrej/php
    • sudo apt update
    • sudo apt upgrade (again)
    • sudo apt install php7.4
    • php -v (to confirm php installed)
    • default apache webpage loads at this point along with phpinfo() that I added

There is an image made at this point, in case we need to build from here

  • install PSR
    • git clone https://github.com/jbboehr/php-psr.git
    • apt install php7.4-dev (warning said apt install php7.2-dev, was this my prob before?)
    • cd php-psr
    • phpize
    • ./configure
    • make
    • make test
    • sudo make install
    • had to manually add to the /etc/php/7.4/cli/php.ini (do we need to do the apache2 one too?)
      • extension=psr.so

php -v returns ok now and php -m shows Phalcon as a module


I tried to move on to composer, in order to load the devtools, but I got this error:

"PHP Warning: PHP Startup: Unable to load dynamic library 'phalcon.so' (tried: /usr/lib/php/20190902/phalcon.so (/usr/lib/php/20190902/phalcon.so: undefined symbol: php_pdo_get_dbh_ce), /usr/lib/php/20190902/phalcon.so.so (/usr/lib/php/20190902/phalcon.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

I have seen errors like this a few times, like before I got PSR installed, which I'm still not sure I did correctly.

You need to load pdo before phalcon.



6.6k
edited Jul '20

You need to load pdo before phalcon.

I thought I did? Can you elaborate on how I need to do that?

Edit: I ran this command at the cli:

sudo apt-get install php7.4-mysql

Then I re-ran the composer install and did not get an error. I'm still worried I don't have phalcon setup right.

edited Jul '20

apt-get install php7.4-pdo

And make sure that in conf.d folder of fpm/cli pdo.ini is before phalcon.ini(like number prefix on pdo is lower).

Also yes, if you use apache then you need to apache2 phalcon.so too. Also i recommend using nginx + fpm really. It's industry standard pretty much.



6.6k

apt-get install php7.4-pdo

And make sure that in conf.d folder of fpm/cli pdo.ini is before phalcon.ini(like number prefix on pdo is lower).

Also yes, if you use apache then you need to apache2 phalcon.so too. Also i recommend using nginx + fpm really. It's industry standard pretty much.

When i ran that PDO install command, I got this:

Note, selecting 'php7.4-common' instead of 'php7.4-pdo' php7.4-common is already the newest version (7.4.8-1+ubuntu18.04.1+deb.sury.org+3). php7.4-common set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Doesn't that mean PDO is already installed?

I think the ini's are my issue, but there are many. I have /etc/php/7.4/apache and /etc/php/7.4/cli ; all the extensions need to be enabled in both?

Yes, phalcon must be loaded after pdo, simple as that.



6.6k

Yes, phalcon must be loaded after pdo, simple as that.

So, let me see if I understand correctly:

  • I need to install phalcon.
  • I need to edit the /etc/php/7.4/cli/php.ini AND the /etc/php/7.4/apache/php.ini to include "extension=phalcon.so" below anywhere that says "extension=pdo.so"

Or do I need to put something into the /etc/php/7.4/cli/conf/d folder? After I installed phalcon, i saw the 50-phalcon.ini there. I have since restarted the whole process over and I have setup apache and php, but not phalcon at all.

Exactly like this, /etc/php/7.4/cli/conf/ is only for CLI, like command line, you need to add similar file 50-phalcon.ini which will linkd most likely to file from /etc/php/7.4/mods-available

It looks like that you have pdo loaded after phalcon. What "priority"(its this number before file name) have pdo?



6.6k
edited Jul '20

Exactly like this, /etc/php/7.4/cli/conf/ is only for CLI, like command line, you need to add similar file 50-phalcon.ini which will linkd most likely to file from /etc/php/7.4/mods-available

It looks like that you have pdo loaded after phalcon. What "priority"(its this number before file name) have pdo?

In /etc/php/7.4/cli/conf.d, there is a 10-pdo.ini.

/etc/php/7.4/apache2/conf.d is empty.

(contents of mods-available) /etc/php/7.4/mods-available# ls

calendar.ini
fileinfo.ini

json.ini
posix.ini
sysvmsg.ini

ctype.ini
ftp.ini
opcache.ini
readline.ini
sysvsem.ini

exif.ini
gettext.ini
pdo.ini
shmop.ini
sysvshm.ini

ffi.ini
iconv.ini
phar.ini
sockets.ini
tokenizer.ini



6.6k

Exactly like this, /etc/php/7.4/cli/conf/ is only for CLI, like command line, you need to add similar file 50-phalcon.ini which will linkd most likely to file from /etc/php/7.4/mods-available

It looks like that you have pdo loaded after phalcon. What "priority"(its this number before file name) have pdo?

I think I finally got it right, although I'm not sure what I did differently. :)

I reinstalled phalcon again, and I made sure the 50-phalcon.ini was in both the cli and apache2 /conf.d dirs, and it was. I added the "extension=psr.so" line ot the end of the cli and apache2 php.ini's, which I thought I'd done before, too.

Restarted apache and now phalcon shows up in the phpinfo(). Also managed to install the devtools, but a typo on a guide i sued caused some delays.

Happy to report:

/etc/php/7.4/apache2# phalcon

Phalcon DevTools (4.0.3)

Available commands:
  info             (alias of: i)
  commands         (alias of: list, enumerate)
  controller       (alias of: create-controller)
  module           (alias of: create-module)
  model            (alias of: create-model)
  all-models       (alias of: create-all-models)
  project          (alias of: create-project)
  scaffold         (alias of: create-scaffold)
  migration        (alias of: create-migration)
  webtools         (alias of: create-webtools)
  serve            (alias of: server)
  console          (alias of: shell, psysh)