The most common instructions to installing php5 and apache is the following:
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
However, you can just install apache and libapach2 mod and run php5. So why do you need the php5 package if the libapach mod package runs it just fine??
The php5 package is a metapackage whose job is solely to ensure that one of a number of different ways of running PHP for websites is installed. In actual use it's completely unnecessary; it's a convenience for people who just want PHP5. Type sudo apt-get install php5 on a system without PHP5 at all, and it'll prompt you with the options available.
Related
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
I am trying to setup phppgadmin and it requires php5-fpm but as I have ubuntu 16.04 and it comes with php 7. So when i try to run install php5-fpm it give me following error:
sudo apt-get install php5-fpm
Package php5-fpm is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'php5-fpm' has no installation candidate
I can't use php7-fpm as phppgadmin requires only php5-fpm. When I run sudo apt-get install php-fpm it installed php7-fpm . I am using nginx as web server. I tried many ppa but none of them worked for me.
TL;DR: If you want to stay with php5, you will need to stay at Ubuntu 14.04 LTS
You can use phpbrew to install older/different php-version, that are not part of the actual package-repositories of ubutu.
phpbrew builds and installs multiple version php(s) in your $HOME directory.
Another way is to modify the sources.list and a repository which still provides php5 packages. But you really should not do that!
You will need to use a PPA to do this. Consider:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php-xdebug libapache2-mod-php5.6
That's PHP5.6, not exactly PHP5-FPM. I don't think FPM is in that PPA but it's a close enough solution. Maybe you can find an FPM PPA but I'm not seeing one at first glance.
I recently switched to PHP 7 on my development server, which has worked just fine - until now.
Since I updated to PHP 7.0.3-10+deb.sury.org~trusty+1 (earlier today), the utf8_decode and utf8_encode functions are no longer accessible. They were, however, in previous versions of PHP7. When called, a fatal error is raised.
I read that these functions are provided by the mbstring extension, which I checked with var_dump(extension_loaded('mbstring')); is loaded.
How can I get the above functions to work again?
I had the same problem. Just install php7.0-xml package. Ubuntu 16.04:
sudo apt-get install php7.0-xml
Edit: Restart apache2 to load the new package.
On Ubuntu, you got the following message during the upgrade of PHP7:
php7.0 (7.0.3-6) unstable; urgency=medium
* Several extensions have been split into separate extension packages:
- php-dba - Database (dbm-style) Abstraction Layer
- php-mbstring - Multibyte String
- php-soap - SOAP
- php-xml - DOM, SimpleXML, WDDX, XML, XMLReader and XMLWriter
- php-zip - Zip
* The new packages are not installed automatically, so you will need to
install them by hand, if you use the functions in those modules.
* Most modules that have been builtin before are now included in
php7.0-common package and they are enabled by default for your
convenience. You can disable unneede modules via phpdismod tool.
-- Ondřej Surý <ondrej#debian.org> Mon, 22 Feb 2016 12:37:09 +0100
so it's one of those packages that's causing the problem. In this case, it's php-xml.
Note the
The new packages are not installed automatically
You can fix that by
sudo apt-get install php-xml
sudo apache2ctl graceful
If you are on CentOS, following command should work:
yum install php-xml
As the top voted answer did not work for me i found yet another package for php7 which (obvious by its name) fixed it for me
sudo apt-get install php7.0-mbstring
In Ubuntu 16.04 LTS, with php 5.6, try:
sudo apt-get install php5.6-xml
sudo service apache2 restart
The utf8_decode and utf8_encode functions are accessible in php 7:
function.utf8-encode - manual - php
This is because the php-xml package is missing in your php installation.
If your server is running Mandrake, enter "urpmi php-xml".
If your server is running EASYPHP on Windows, click on the EASYPHP logo to activate the php-xml module.
On debian or ubuntu try :
apt-get install php7.0-xmlrpc
I encountered the same problem and for me,
sudo apt-get install php-patchwork-utf8
and restarting the apache2 server solved the problem (on Ubuntu 16.04 LTS).
I'd like to know a basic run down of command line inputs to install Apache, PHP and a SQL database on a VPS.
I'm not sure if sudo apt-get install php5 is enough to install php5 while getting the dependencies such as gcc.
I'm looking at Debian (Wheezy) as that is what a friend of mine suggested. I'm testing different websocket/wamp router solutions probably alongside if not dependent on node.js eg. socket.io or crossbar.io.
sudo apt-get install mysql-server
sudo apt-get install apache
sudo apt-get install php5-common libapache2-mod-php5 php5-cli
There are additional instructions for installing the mysql-server:
http://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
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