When working with PHP on Ubuntu 9.10 (Karmic Koala) or similar versions, you'll often need additional extensions beyond the base installation. The good news is that Ubuntu's package manager (apt-get) provides a streamlined way to handle PHP extensions.
The proper way to install PHP extensions on Ubuntu is through the package manager. Here's the general syntax:
sudo apt-get install php5-[extension-name]
For the requested extensions (mcrypt, curl, gd), here are the exact commands:
sudo apt-get install php5-mcrypt php5-curl php5-gd
After installation, restart Apache to load the new extensions:
sudo service apache2 restart
Create a PHP info file to verify the extensions are properly installed:
<?php
phpinfo();
?>
Save this as info.php
in your web root and access it through your browser. Look for the mcrypt, curl, and gd sections.
Most extensions will work immediately after installation, but some might require additional configuration:
; Example php.ini configuration for mcrypt
extension=mcrypt.so
mcrypt.algorithms_dir=/usr/lib/mcrypt
If you encounter problems:
- Ensure all dependencies are installed:
sudo apt-get -f install
- Check for proper Apache/PHP integration:
sudo apt-get install libapache2-mod-php5
- Verify the extensions are enabled in php.ini
In rare cases where an extension isn't available in the Ubuntu repositories:
sudo pecl install [extension-name]
sudo echo "extension=[extension-name].so" >> /etc/php5/apache2/php.ini
When working with PHP on Ubuntu servers, extensions are typically installed as separate packages through the system's package manager. For Ubuntu 9.10 (Karmic Koala), these packages follow the naming convention php5-*
.
sudo apt-get update
sudo apt-get install php5-mcrypt php5-curl php5-gd
This single command will install all three requested extensions:
php5-mcrypt
- Provides encryption functionsphp5-curl
- Enables HTTP request functionalityphp5-gd
- Adds image manipulation capabilities
After installation, create a test PHP file to verify the extensions are loaded:
<?php
phpinfo();
?>
Access this file through your web browser and search for "mcrypt", "curl", and "gd" to confirm they appear in the loaded modules.
Some extensions may require additional configuration in php.ini:
sudo nano /etc/php5/apache2/php.ini
After making any changes, restart Apache:
sudo /etc/init.d/apache2 restart
If an extension isn't loading:
- Check if the package is installed:
dpkg -l | grep php5
- Look for the .so file:
ls /usr/lib/php5/*/
- Verify the extension is enabled in php.ini