Decoding the --without-gd Flag on PHP 5.2.4
When you run phpinfo() and see Configure Command: ./configure '...' --without-gd, it means the PHP binary was compiled specifically without support for the GD extension. This isn't a configuration error you can fix via php.ini; it is a hard-coded limitation at the build level. On AWS, this situation almost always indicates that the operating system package manager installed a minimal or legacy version of PHP that shipped with GD disabled by default to reduce footprint or conflict with other image libraries.
Since the source material specifies PHP 5.2.4, we are dealing with a legacy environment. Modern distributions rarely ship PHP versions this old without explicitly excluding modules unless they are running in a very specific container or micro-service context. The absence of gd in the "Core" section of your output confirms that the extension is not loaded, and because the flag --without-gd was present during compilation, the library files likely do not exist on the filesystem at all.
Why Compilation Matters
PHP extensions like GD are not dynamic modules you can simply drop into an extensions folder if they weren't compiled in. The build system uses flags to determine what gets linked into the final binary. When you see --without-gd, the linker was told explicitly to skip this dependency. Attempting to load a pre-built .so file from a third-party repository will result in a fatal error upon PHP startup, as the internal API structures required by GD do not match the compiled version of PHP.
To resolve this on an existing system, you must rebuild PHP or install a different binary that includes GD. If you are managing the underlying OS package (like php on Ubuntu), you might try installing the development packages and rebuilding:
sudo apt-get update
sudo apt-get install php5.2-dev libgd-dev
# Then force a reinstall of the PHP package if your distro supports it
sudo dpkg-reinstall php5.2-cli
However, on AWS EC2 instances using older AMIs or custom packages, this often fails because the package metadata is locked to the version without GD.
The Correct Approach: Rebuilding from Source
For a legacy stack like PHP 5.2.4, the most reliable path forward is to download the specific source tarball for that version and compile it with the correct flags. This ensures you have full control over which extensions are included.
- Download the PHP 5.2.4 source code from the official archive.
- Extract the archive into your directory structure.
- Navigate to the folder and run
./configure.
Here is where the decision-making happens. You must explicitly enable GD by passing the flag --with-gd (or --with-gd=shared if you prefer a shared library) to the configure script:
./configure --with-gd \
--with-jpeg-dir=/usr/lib \
--with-png-dir=/usr/lib \
--enable-mbstring \
--prefix=/usr/local/php5.2
Note that for PHP 5.2, you must also ensure the system dependencies like libjpeg and libpng are installed on the OS, as GD relies on them heavily. After running configure, proceed with make and make install. You will then need to adjust your php.ini to point to this new installation or update your ld.so.conf if installing system-wide.
Trade-offs and Legacy Constraints
Upgrading from PHP 5.2.4 is often the pragmatic solution, as many modern libraries and extensions have dropped support for such old versions. PHP 5.2 reached end-of-life years ago, meaning it receives no security patches. If you are running this on AWS, consider whether your application truly requires 5.2 or if it can migrate to a supported minor version (like 7.4 or 8.x) where GD is enabled by default and well-supported.
If you cannot upgrade the PHP version, sticking with a source-built installation that explicitly enables GD is the only viable option. Be aware that mixing different PHP versions on the same server requires careful management of php.ini paths and user permissions to avoid conflicts.
Final Verification
Once rebuilt and installed, restart your web server (Apache or Nginx) and verify the installation again via phpinfo(). You should now see "gd" listed under the Core or loaded extensions sections, and the Configure Command string should reflect the inclusion of GD. If you still see --without-gd, double-check that you did not accidentally run make install with a stale build directory where an older configuration was cached.