The "GD Enabled" Illusion in PHP 5.5 on Ubuntu
You are encountering a classic configuration mismatch. The error message Call to undefined function imagecreatefromjpeg() is unambiguous: PHP cannot find the function, even though your application settings claim the GD library is enabled. This discrepancy usually stems from how the GD extension interacts with the specific version of PHP and the operating system you are running.
In your scenario, you are using Ubuntu 14.04 LTS with PHP 5.5.9. While this stack often includes GD by default, the output bool(false) from var_dump(function_exists('imageantialias')) confirms that the extension is not loaded at runtime. The phrase "GD enabled" in your environment likely refers to a configuration option or a belief based on package installation status, rather than the actual state of the PHP interpreter.
To resolve this without recompiling PHP from source, you must inspect the active extensions and ensure the GD module is explicitly loaded. The most direct way to diagnose this is by checking the php.ini file for your specific PHP instance. You need to verify that the line containing extension=gd.so (or extension=gd2 depending on your build) is present and uncommented. In many Debian-based distributions, including Ubuntu 14.04, the default php.ini might not load this extension unless explicitly told to do so, or the file path specified in php.ini does not match where the .so files actually reside.
Check which PHP binary your application is using:
which php
php -m
If gd is missing from the output of php -m, the extension is definitely not active for that interpreter instance.
Next, look at the specific error log to see if there are any warnings about missing .so files. Sometimes the configuration file points to a location where GD is not installed, or the library was compiled against a different architecture than your PHP binary.
If editing php.ini feels like guessing in the dark, you can force-enable extensions dynamically at runtime without touching the config file. Run the following command to explicitly load the GD extension:
php -d extension=gd.so -r "var_dump(function_exists('imagecreatefromjpeg'));"
If this returns bool(true), then your fix is simply to add or uncomment the line in your php.ini and restart your web server (Apache, Nginx with PHP-FPM, etc.).
However, if you are running a LAMP stack on an older system like Ubuntu 14.04, there is a distinct possibility that your system installed PHP 5.5 via the system package manager (apt-get), but your web server (e.g., Apache or Nginx) was configured to use a custom-built PHP binary located in /usr/local/bin/. In this case, the system packages have GD enabled, but your application is running against the custom build which lacks it. Ensure that php.ini is actually being loaded by checking the value of display_errors or creating a .info.php file to inspect its configuration.
Another common pitfall involves the order of operations in php.ini. If you have multiple php.ini files (one for CLI and one for web), ensure you are editing the correct one. Additionally, check for zend_extension=opcache or similar lines that might be interfering with extension loading in rare versions of PHP 5.5.
If dynamic loading fails or you need a permanent fix without recompiling, verify that the GD library files exist in the expected directory:
ls /usr/lib/php/5.5/gd*
If these files are missing, the package installation was incomplete or corrupted. You may need to reinstall the PHP and GD packages using your package manager rather than compiling from source.
For modern projects, relying on legacy stacks like PHP 5.5 on Ubuntu 14.04 introduces significant security risks beyond just missing functions. If you are maintaining a Laravel application (or similar framework) on this stack, consider upgrading both the OS and the PHP version. Frameworks often require newer PHP versions for performance features and security patches. If you need specific image processing functionality in a new context, libraries like Intervention Image provide a cleaner abstraction layer, but they still depend on the underlying GD or Imagick extensions being correctly installed and loaded by your PHP runtime.
Ultimately, the error is not a bug in PHP; it is a configuration state where the code expects a library that the interpreter cannot see. Aligning the php.ini configuration with the actual file system layout will restore the missing function.