I've recently created LAMP servers on EC2 instances using Amazon Linux AMI.
using
sudo yum install -y php70-gd
I installed the GD extension.
This all worked fine and i could upload and manipulate images using PHP.
Now I've created a LAMP server using Amazon Linux 2 using the tutorial here :https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-lamp-amazon-linux-2.html
My problem is that I can't get the GD extension to work.
i tried using
sudo yum install -y gd
and this seemed to install an older version of GD.
I tried
sudo yum install php-gd
and this seems to install the latest version of the extension.
But the gd extension still doesn't seem to work.
when I enter
yum info gd
In the console it shows :
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
Name : php-gd
Arch : x86_64
Version : 7.2.5
Release : 3.amzn2.0.2
Size : 769 k
Repo : installed
From repo : amzn2extra-lamp-mariadb10.2-php7.2
Summary : A module for PHP applications for using the gd graphics library
URL : http://www.php.net/
License : PHP and BSD
Description : The php-gd package contains a dynamic shared object that will add
: support for using the gd graphics library to PHP.
when I try an image resize script I get an error.
I've tried this test script :
$testGD = get_extension_funcs("gd"); // Grab function list
if (!$testGD){ echo "GD not installed."; exit; }
echo"<pre>".print_r($testGD,true)."</pre>";
and this gives me the result
GD not installed.
so obviously something is not right.
Can anyone help?
thanks
Amazon Linux 2 uses Apache with PHP-FPM instead of mod_php. So you need to restart the php-fpm process to reload PHP with the new extension.
sudo systemctl restart php-fpm
I'm running php 7.2.14 on Amazon Linux 2 and this worked for me:
$ sudo yum update -y
$ sudo yum install -y php-gd
$ sudo reboot
And solved...
Turns out restarting apache with
sudo systemctl restart httpd
wasn't enough to load the newly installed component...
what i needed to do was
sudo reboot
and everything works...
Why did't i try that 24 hours ago!
my PHP version was - PHP 7.2.18
$ php -v
I had to install -y php72-gd
$ sudo yum update -y
$ sudo yum install -y php72-gd
$ sudo reboot
$ sudo yum install -y php-gd
$ sudo systemctl restart php-fpm
No need to reboot
I was getting error Required extension GD is not loaded while using Claviska Simple Image Library in my project on AWS with Php 7.0
So I needed to update the GD php library:
sudo yum install -y php70-gd
and then restart httpd service to load the updated php.
sudo /etc/init.d/httpd restart
Worked for me!
You may have done nothing wrong and might not need to reboot either. Sometimes, the extensions are not directly mapped in the php.ini file. As such, you may need to map the newly added extensions (or which are not mapped already) in the php.ini file. In your case, add
extension=gd.so
In general,
extension=<my_extension_name>.so
I have an AWS server running a website with NGINX and PHP. I originally installed these using the following:
sudo yum install -y nginx php-fpm
The version of PHP that is installed is 5.3.29 which but I need at least 5.4 to run a payments plug-in. All the info online indicates a PHP upgrade actually involves a reinstall. So I ran the series of commands below to upgrade to 7.1 (based on various online postings):
sudo yum remove php* httpd*
sudo yum clean all
sudo yum update -y
sudo yum install php71
After the upgrade all php files on my site result in a 404. But html files work fine, so NGINX is running. The resulting install of php7.1 doesnt seem to run as a service. If I run service --status-all I see no mention of any PHP. There is now no *.sock file in the /var/run/ folder hierarchy for nginx to link to. There is no www.conf file for php so I cannot configure a sock file location. The tutorials online mention running php afterwards using sudo systemctl restart php7.1-fpm.service but systemctl is not a command and there seems to be no PHP service to run anyway.
Am I missing something here? I am at a loss what to do next. Can anybody offer some direction or indication as to what I have done wrong and how I can debug this?
FINALLY! Seems the instructions on virtually every site I have looked at did not work. What did work was the following:
sudo yum install php71-fpm
I dont understand the difference between php71 and php71-fpm but using the latter seems to install the service and other files I needed. Not everything on my site is working though, as I now need to track down the various php components that are needed. It seems that the various php modules have changed name in assorted ways. For example, php71-pdo exists but php71-mysql does not.
Change PHP version.
sudo yum-config-manager --enable epel
yum install dnf -y
yum install epel-release yum-utils -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
dnf install php74.x86_64
dnf clean metadata
dnf install php-cli php-pdo php-fpm php-json php-mysqlnd
dnf list installed php-cli php-pdo php-fpm php-json php-mysqlnd
which php
php -v
yum update
sudo systemctl restart httpd
stack: PHP 5.4.23, php-fpm, nginx 1.4.x, centos 6.5
I was trying to install xdebug, had to run phpize command.
I have php5-devl already installed and pecl command works
When I ran the command, it gave me the following error output:
# phpize
Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.
How to fix this error?
I think you have not installed php-pear . I am not seeing it in that link.
You can do it by yum install php-pear
Info
You can install xdebug also using these steps
1) Install PHP’s devel package for PHP commands execution
yum install php-devel
Make sure you also have php-pear package installed
yum install php-pear
2) Install GCC and GCC C++ compilers to compile Xdebug extension yourself.
yum install gcc gcc-c++ autoconf automake
3) Compile Xdebug
pecl install Xdebug
4) Find the php.ini file using
`locate php.ini`
And add the following line
[xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable = 1
5) Restart Apache
service httpd restart
6) Test if it works – create test.php with the following code
<?php phpinfo(); ?>
The problem got solved by the PHP version that is used in the system.
My PHP Version was 5.6
So by running the following command I solved the problem
yum install php56-devel
Where "56" is your version of PHP.
If you're on PHP 7 such as in my case just installing php-devel won't solve your problems, but you'll need to install some additional packages:
yum install php-devel pcre-devel gcc make
And then you'll be able to follow Harikrishnan steps to get xdebug working (if not yet configured).
My problem hasn't been solved using
yum install php-devel
But this helped me to solve the problem:
yum --enablerepo=remi,remi-php55 install php55-php-devel
I'm needing mailparse installed on my xampp.
I've done pecl install mailparse but I get an error that mbstring is not installed, but it is.. Or at least that is what phpinfo() says.
So I'm doing /Applications/XAMPP/xamppfiles: sudo ./bin/pecl install --nodeps mailparse
BUT.. when the make starts it fails with a big load of errors... How can I install mailparse on a xampp installation? Or maybe I could compile it? but not sure how, not in osx...
Any ideas?
Here you can see the complete trace done with sudo ./bin/pecl install --nodeps mailparse > dump
FIXED! if someone is interested on the solution, you must have installed devel-package of XAMPP, and run the pecl script having in mind that must be comipled for i386 arch.
sudo su -
export CFLAGS="-arch i386"
/Applications/XAMPP/xamppfiles/bin/pecl install --nodeps mailparse
sudo /Applications/XAMPP/xamppfiles/bin/pear install pecl/mailparse
From: http://wiki.cerb4.com/wiki/Installing_PHP_Mailparse#Mac_OS_X_.28XAMPP.29
sudo /Applications/XAMPP/xamppfiles/bin/pear install pecl/mailparse-2.1.6
Try this is if you have installed Php 5.X
If you got error like
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
and then retry.
brew install autoconf
and run the command
NOTE: The libraries MCrypt support depend on have not been updated in years and MCrypt should no longer be considered a viable or secure method of encrypting data. What's more, MCrypt has been deprecated in PHP 5, and removed entirely in PHP 7. If you have any code that runs MCrypt you should refactor it to use a more modern encryption library.
Does anyone know why this error message: (Call to undefined function mcrypt_encrypt() ) displays when I run the following code below?
Am I missing some steps perhaps any setting in PHP I have to do before this code can work?
$key = 'password to (en/de)crypt';
$string = 'string to be encrypted';
$test = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key),
$string, MCRYPT_MODE_CBC, md5(md5($key)));
If you have recently updated to ubuntu 14.04 here is the fix to this problem:
$ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
What had worked for me with PHP version 5.2.8, was to open up php.ini and allow the php_mcrypt.dll extension by removing the ;, i.e. changing:
;extension=php_mcrypt.dll to extension=php_mcrypt.dll
For windows
;extension=php_mcrypt.dll to extension=php_mcrypt.dll
then restart your apache server
For Redhat
sudo yum install php55-mcrypt //if php5.5
sudo yum install php-mcrypt //if less than 5.4
sudo service httpd restart //if apache 2.4
sudo /etc/init.d/httpd restart //if apache 2.2 or less
For Ubuntu
sudo apt-get install php5-mcrypt
sudo service apache2 restart //if server not reloaded automatically
Still not working?
sudo php5enmod mcrypt && sudo service apache2 restart
If you are using PHP 7.2 or up:
This function was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0.
source: http://php.net/manual/en/function.mcrypt-encrypt.php
So you have to replace the php code and find a solution without mcrypt.
Or, I just found out, you can STILL use mcrypt in PHP 7.2.0, but you have to install it as a PHP Extension Community Library. (https://pecl.php.net/)
On Debian/Ubuntu Linux distros:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
then:
sudo pecl install mcrypt-1.0.1
Source: https://www.techrepublic.com/article/how-to-install-mcrypt-for-php-7-2/
You don't have the mcrypt library installed.
See http://www.php.net/manual/en/mcrypt.setup.php for more information.
If you are on shared hosting, you can ask your provider to install it.
In OSX you can easily install mcrypt via homebrew
brew install php54-mcrypt --without-homebrew-php
Then add this line to /etc/php.ini.
extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so"
Under Ubuntu I had the problem and solved it with
$ sudo apt-get install php5-mcrypt
$ sudo service apache2 reload
On ubuntu 14.10 :
Install module mcrypt
sudo apt install php5-mcrypt
Enable module mcrypt on apache2
sudo a2enmod mcrypt
Reload module configuration
sudo service apache2 restart
On Linux Mint 17.1 Rebecca - Call to undefined function mcrypt_create_iv...
Solved by adding the following line to the php.ini
extension=mcrypt.so
After that a
service apache2 restart
solved it...
I had the same issue for PHP 7 version of missing mcrypt.
This worked for me.
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
sudo service apache2 restart (if needed)
Is mcrypt enabled? You can use phpinfo() to see if it is.
One more thing: if you are serving PHP via a web server such as Apache, try restarting the web server. This will "reset" any PHP modules that might be present, activating the new configuration.
Assuming you are using debian linux (I'm using Linux mint 12, problem was on Ubuntu 12.04.1 LTS server I ssh'ed into.)
I suggest taking #dkamins advice and making sure you have mcrypt installed and active on your php5 install. Use "sudo apt-get install php5-mcrypt" to install. My notes below.
Using PHP version PHP Version 5.3.10-1ubuntu3.4, if you open phpinfo() as suggested by #John Conde, which you do by creating test file on web server (e.g. create status page testphp.php with just the contents "" anywhere accessible on the server via browser)
I found no presence of enabled or disabled status on the status page when opened in browser. When I then opened the php.ini file, mentioned by #Anthony Forloney, thinking to uncomment ;extension=php_mcrypt.dll to extension=php_mcrypt.dll
I toggled that back and forth and restarted Apache (I'm running Apache2 and you can restart in my setup with sudo /etc/init.d/apache2 restart or when you are in that directory just sudo restart I believe)
with change and without change but all no go. I took #dkamins advice and went to install the package with "sudo apt-get install php5-mcrypt" and then restarted apache as above. Then my error was gone and my application worked fine.
If you are using php5-fpm do remeber to restart it, after installing mcrypt
service php5-fpm restart
If you using ubuntu 14.04 here is the fix to this problem:
First check php5-mcryp is already installed apt-get install php5-mcrypt
If installed, just run this two command or install and run this two command
$ sudo php5enmod mcrypt
$ sudo service apache2 restart
I hope it will work.
My Environment: Windows 10, Xampp Control Panel v3.2.4, PHP 7.3.2
Step-1: Download a suitable version for your system from here: https://pecl.php.net/package/mcrypt/1.0.3/windows
Step-2: Unzip and copy php_mcrypt.dll file to ../xampp/php/ext/
Step-3: Open ../xampp/php/php.ini file and add a line extension=php_mcrypt.dll
Step-4: Restart apache, DONE!
In Ubuntu 18.04, and for php7.0
$ sudo apt-get install php7.0-mcrypt
$ sudo systemctl reload apache2
for Linux based (Fedora)
yum -y install php-mcrypt
Enable the module by adding: 'extension=mcrypt.so' to PHP.ini. (/etc/php.ini)
systemctl restart httpd.service
Done!
For me it helped to uninstall mcrypt with:
sudo apt-get purge php5-mcrypt
and simply reinstall it:
sudo apt-get install php5-mcrypt
and dont forget to restart apache as described above.
Dont know why and how this was different in my case (using a vm with provisioned php55), but maybe this will help someone else. I also had this problem with some other modules like xcache...
Check and install php5-mcrypt:
sudo apt-get install php5-mcrypt