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
Related
I have been trying to update PHP on my install of WordPress on Google Cloud.
I have followed these instructions: How do I upgrade from PHP 7.0 to 7.3 on google cloud platform?.
When I do a php -v command, it shows that it is updated, but within WordPress it is still showing version 7.0, not the updated version.
Your system appears to have two installations of PHP. One for the CLI and another Apache or you have not restarted Apache after the update. First restart Apache and recheck.
The command to install Apache PHP is sudo apt install libapache2-mod-php7.3.
Warning: Be careful with manual updates of PHP and other software that may have interdependencies. Make sure you have backed up your system (image) before so that you can recover is something goes wrong. Debian 4.9 is very old (obsolete) and might not be supported or even tested with the latest versions of third-party software.
The Linux command where php will tell you where PHP is installed. To figure out if you have a different installation for Apache, create a new web page, such as myphpinfo.php with the following contents. Then use your browser to view the page:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Your browser will display a page like this:
Use SSH commands:
Go to root
sudo -i
install latest version of php
apt-get install php7.4
update it
apt-get update
install packages
apt-get install ca-certificates apt-transport-https
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
check your php version
php -v
enable php7.4 and disable your current php7.0
sudo a2dismod php7.0
sudo a2enmod php7.4
install the libraries
sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo apt-get install php-mysql
sudo apt-get install php-curl
sudo apt-get install php-xml
sudo apt-get install php-gd
restart apache
sudo service apache2 restart
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've found an error on a page in my Magento application; it always show this message error when I visit it:
Fatal error: Class 'DOMDocument' not found in /home/.../lib/Zend/Feed/Abstract.php on line 95
Can you give me a solution? I'm using magento 1.4.1.1.
You need to install the DOM extension. You can do so on Debian / Ubuntu using:
sudo apt-get install php-dom
And on Centos / Fedora / Red Hat:
yum install php-xml
If you get conflicts between PHP packages, you could try to see if the specific PHP version package exists instead: e.g. php53-xml if your system runs PHP5.3.
PHP 8.2
Ubuntu: apt-get install php8.2-xml
CentOS 8 [with php:remi-8.2 enabled]: dnf install php-xml
PHP 8.1
Ubuntu: apt-get install php8.1-xml
CentOS 8 [with php:remi-8.1 enabled]: dnf install php-xml
PHP 8.0
Ubuntu: apt-get install php8.0-xml
CentOS 8 [with php:remi-8.0 enabled]: dnf install php-xml
PHP8: (latest version)
sudo apt-get install php8.0-xml
PHP7:
sudo apt-get install php7.1-xml
You can also do:
sudo apt-get install php-dom
and apt-get will show you where it is.
Package php-dom is a virtual package provided by:
php7.1-xml 7.1.3+-3+deb.sury.org~xenial+1
php7.0-xml 7.0.17-3+deb.sury.org~xenial+1
php5.6-xml 5.6.30-9+deb.sury.org~xenial+1
You should explicitly select one to install.
In case anyone using 5.6 versions then go with this way
sudo apt-get install php5.6-xml
For PHP ver PHP7, Ubuntu:
sudo apt-get install php7.1-xml
or by
yum install php-xml
I'm using Centos and the followings worked for me , I run this command
yum --enablerepo remi install php-xml
And restarted the Apache with this command
sudo service httpd restart
After a long time suffering from it in PHPunit...
For those using namespace, which is very common with Frameworks or CMS, a good check in addition to seeing if php-xml is installed and active, is to remember to declare the DOMDocument after the namespace:
namespace YourNameSpace\YourNameSpace;
use DOMDocument; //<--- here, check this!
Create an empty PHP file and put only <?php phpinfo(); in it, look at it in a browser.
Check if you can spot --disable-dom in the configuration options and/or if you can see details about the DOM extension in the list below.
If you cannot see DOM in the list or you see it is disabled, your PHP installation does not include the DOM extension. You'll need to recompile your PHP installation from source to remedy that.
In my case the problem was it was the use of namespace at the top of php file, exemple :
namespace MediaWiki\Extensions\ParserFunctions;
To solve this problem add the following line:
use DOMDocument;
So no need of installing dom or xml if they are already installed. It is a php language trap.
This help for me (Ubuntu Linux) PHP 5.6.3
sudo apt-get install php5.6-dom
Thats work for me.
For PHP 7.4 Install the DOM extension.
Debian / Ubuntu:
sudo apt-get update
sudo apt-get install php7.4-xml
sudo service apache2 restart
Centos / Fedora / Red Hat:
yum update
yum install php74w-xml
systemctl restart httpd
For previous PHP releases, replace with your version.
Using Suse Linux (Linux linux 3.16.7-48-default) and PHP 5.6.1 as root, this helped:
zypper in php5-dom
plus restart
systemctl restart apache2
On fedora 26:
dnf install php-dom
Fixes it !
If compiling from source with --disable-all then DOMDocument support can be enabled with
--enable-dom
Example:
./configure --disable-all --enable-dom
Tested and working for Centos7 and PHP7
I'm using CentOS 7 with virtualmin and three PHP versions. I also have REMI repo enabled. it worked for me:
Step 1:
Just append PHP major version number like this php{version number}-xml. And run yum install
yum install php70-php-xml
yum install php71-php-xml
yum install php72-php-xml
Step 2:
Don't forget to restart Apache:
service httpd restart
On a Amazon Linux 2 with PHP 8.0, I had to
yum-config-manager --enable remi-php80
yum install php-xml
Do not forget to restart PHP
systemctl restart php-fpm
For Centos 7 and php 7.1:
yum install php71w-xml
apachectl restart
If you are using PHP7.0 to install Magento, I suggest to install all extensions by this command
sudo apt-get install php7.0 php7.0-xml php7.0-mcrypt php7.0-curl php7.0-cli php7.0-mysql php7.0-gd libapache2-mod-php7.0 php7.0-intl php7.0-soap php7.0-zip php7.0-bcmath
I need to Google some times to meet Magento requirement.
I think you can replace the PHP version to 7.x if you use another PHP version
And restart Apache is needed to load new extensions
sudo service apache2 restart
PHP 7.X Centos 7
I got dependency issues when trying to install module with above suggestions, adding this flag:
--enablerepo=remi-php7X
Resolved dependencies.
So
sudo yum --enablerepo=remi-php7X install php-xml
Then
service httpd restart
Ref:
Install PHP Modules
this is the lastest for php v 8.0
sudo apt-get install php8.0-xml
I want to use SPLEnum, a part of the PECL-Extension SPL-Types, in my Web Application.
Now, I've never worked with extensions, so I don't know how they are working. I've asked my hoster to install the package, but they could not because of security reasons on their servers.
Is it somehow possible to manually include files, just like in Java (manually copy the files to the webserver and include them)?
Thanks for your answers
Regards, Flo
PECL contains C extensions for compiling into PHP. Therefore you need the appropriate rights on the server running PHP, which you will never get on a shared hosting. Try to find a similar PEAR extension, these are written in PHP and behave like any other PHP file.
I'm using Ubuntu 14.04 with Apache rather than nginx. Using the script from here works.
sudo apt-get install libpcre3-dev php5-dev php-pear -y
sudo pecl install SPL_Types
echo extension=spl_types.so | sudo tee /etc/php5/mods-available/spl_types.ini
sudo php5enmod spl_types
sudo service apache2 reload
The key difference between this and Michael Noyb's answer is that this continues on to take care of loading the extension into Apache by using the php5enmod system, which you can read about here.
Shared Hosting
CodeZombie's answer is spot on that a shared host will not let you do this, but you can spin up your own virtual private server (VPS) on something like DigitalOcean for $5 a month which is roughly the same cost of a shared hosting plan.
Ubuntu 14.04 using php5-fpm and nginx and php 5.5+
sudo apt-get install libpcre3-dev
sudo apt-get install php5-dev
sudo pecl install SPL_Types
then go to /etc/php5/fpm/php.ini and add this line
extension=spl_types.so
Note: you may have to do the same for /etc/php5/cli/php.ini
then
sudo service nginx restart
sudo service php5-fpm restart
Then you can write classes like this (real life example for me):
<?php
namespace Metronic\Lib;
use SplEnum;
class PortletColor extends SplEnum {
const __default = self::YELLOW;
const YELLOW = 'yellow';
}
When you need to call the constant yellow, you use \Metronic\Lib\PortletColor::YELLOW;
Ubuntu 12.04+ installation order:
sudo apt-get install libpcre3-dev
sudo apt-get install php5-dev
sudo apt-get install php-pear
sudo pecl install SPL_Types
I am new to this of course.
I am trying to configure PHP and Apache on a new Amazon EC2 AMI. This is a very lightweight server so the Micro instance fits the bill.
I just need
Apache
PHP
I ran
sudo yum install apache2
sudo yum install php
I copied info.php to /var/www/html
info.php only contains
<? phpinfo(); ?>
when i browse to http://www.example.com/info.php Apache serves info.php but it does not render it. I looks like apache is not configured to handle php files. What step or steps am I missing?
Thanks,
First try using full tags, so your script would be.
<?php phpinfo(); ?>
instead of <? ?>
If no luck, try:
sudo yum remove php
sudo yum install php
then service httpd restart
Alternatively try using one of the pre-built AMI's. Community AMI's have several LAMP configurations.
Just for those who get here from Google, try this:
sudo yum install -y php
sudo yum -y install httpd
If you need development versions:
sudo yum install -y php-devel
sudo yum -y install httpd
If you need Apache 2.4 and PHP 5.4:
sudo yum install -y php54
sudo yum -y install httpd24
From:
Install Apache, PHP, and MySQL on Amazon Linux
Install Apache 2.4, PHP 5.4, and MySQL on Amazon Linux
Just tar your info.php;
Upload it to another public directory;
Get the file to ec2 with wget;
Untar the file.
That's it ;)