I am trying to set up a web server to host Moodle on and I've been running into problems when trying to install PHP7.
I am currently using VirtualBox to host CentOS 7.4. By default, CentOS comes packaged with PHP 5.4.16. Now, from what I have read, the options for upgrading and installing from scratch are different. I have tried to follow multiple sites that guide towards getting PHP7 but have had no luck. The majority of guides tell you to install two repositories, Remi and EPEL. The main problem I have is that every time I install epel, yum either breaks or prevents me from installing another package.
[root#localhost ~]# yum update
Loaded plugins: fastestmirror, langpacks
Could not retrieve mirrorlist http://mirrorlist.centos.org/?
release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
I have tried many ways of fixing this. Some of the main ways are:
yum clean all
yum --enablerepo=base clean metadata
rm -rf /var/cache/yum
I did get around this once or twice by using
yum --enablerepo=epel clean metadata
and also
sed -i "s/mirrorlist=https/mirrorlist=http/" /etc/yum.repos.d/epel.repo
I know there are more ways that I have tried, but I cannot remember all of them. Moral of the story is that they don't usually help. Sometimes yum works fine and I will run yum clean all, and it stops functioning again.
Method 2:
Another method I tried was installing the rpm packages from their respective websites. I used WinSCP to transfer the files to my VM and then used yum to install them. Everything works well and I got epel and remi to install. But then yum doesn't work properly.
Sometimes it will install packages, but some will not install. I've set the yum timeout value higher and other packages get through, but some still do not. Then I clean up the yum cache and once again I see the message with five options.
Method 3:
I found documentation on installing PHP 7 from https://wiki.centos.org/HowTos/php7 and I thought it must work because this is the supported way.
I followed along right up until the first part.
root # centos7-vm: ~ # yum -y install centos-release-scl.noarch
I will either get the error message stating the package could not be downloaded from a mirror or if yum is already giving me issues, it will show the five options to clean yum.
Method 4:
Building PHP from source was another option I attempted. I navigated to http://php.net/downloads.php and downloaded the tarball and used WinSCP to get it on my machine.
I extracted the files and then navigated into the php directory.
I attempted to get things going by using ./configure, but it stated I needed gcc.
I tried to install gcc with yum install gcc, but could not install all of the packages.
I made a new VM and instantly tried installing gcc, but still not luck.
Summary
Sometimes I understand why yum does not work, other times I'm slamming my head on my desk.
Is there a standardized method of getting PHP 7 on CentOS? Can anyone link an accurate guide?
What is the reason that CentOS comes packaged with PHP 5.4 and not 7?
I feel like I have tried almost everything, but I know there is some webpage that I just haven't found yet. I think I did about all the research I possibly could for today.
I'm sure my question is probably not structured the best and might be a little confusing, but I've been working on this for about 6-7 hours now.
This is my first post, so I apologize if it is not perfect.
in my vps, I just added remi repo,
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ rpm -Uvh remi-release-7.rpm
or
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
then you enable on /etc/yum.repos.d/ on remi.repo, and remi-php72.repo files.
later you update, and install php and its libraries.
epel is not necesary, but is in the official repo. you just got to do a
$ yum install epel-release
and enable the file in /etc/yum.repos.d/
have you check some logs files? to see if there's any errors
Related
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
apache2 : Depends: apache2-bin (= 2.4.27-2ubuntu3) but 2.4.27-2ubuntu4.1 is to be installed
E: Unable to correct problems, you have held broken packages.
Thanks in Advance
Maybe you should take a look at this article:
https://askubuntu.com/questions/223237/unable-to-correct-problems-you-have-held-broken-packages
thomasrutter: "That particular error message may indicate that you have held packages, but it may also indicate a different problem."
He basically says to do some trouble shooting with some of these commands:
You are able to get a list of held packages with the following command
dpkg --get-selections | grep hold
If none show up or none of them seem related to you it might be something else.
Also have you tried aptitude instead of apt-get to install the package?
I personally think that is a great place to start
sudo aptitude install <apache2 or whatever package you're trying to install>
And last but not least:
sudo aptitude -f install <packagename>
I myself struggled with apache for a while on ubuntu, I believe Thomas Rutter explained it a lot better so again I suggest you take a look at his answer on ask ubuntu
I hope this helped.
Run the following command and your problem will be solved.
apt-get purge apache2-bin
I have PHP 5.6.18-1+deb.sury.org~trusty+1 and am trying to update to 5.6.19. However, when I do apt-get update && apt-get upgrade, PHP does not get updated.
I have tried add-apt-repository ppa:ondrej/php5-5.6 as well as manually adding in deb http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu trusty main to my sources.list file to no avail.
How can I update PHP to 5.6.19 and make sure I don't run into this problem again in the future?
The ppa:ondrej/php5-5.6 repository is discontinued in favour of just ppa:ondrej/php. At the time of writing, this gives me an up-to-date version of PHP 5.6:
php --version
PHP 5.6.27-1+deb.sury.org~trusty+1
Note that, once you've added the repository, you'll need to uninstall any packages beginning php5* and reinstall php5.6* equivalents; also, you will probably have to switch Apache modules. More information on some of the steps required on this blogpost.
Note that, because of the quirk of the package maintainer's name containing a non-ASCII character, you might also need to install e.g. language-pack-en to fix all your server locales first. There's some other suggestions of what to do on this ServerFault question but for me it was trivial to install the language pack and let that take care of all locale settings.
I had noticed that an application I have setup on heroku only shows sessions variables on random requests when I refresh the browser. I put this down to the fact the application is running on 5 dynos.
I followed the following tutorial to solve this with memcached using memcachedcloud.
https://devcenter.heroku.com/articles/php-sessions#storing-sessions-in-memcached
The issue still remains though. I am using the PHP slim framework, is there any further config I need for this? I cant seem to find anything in the slim docs.
EDIT:
I can not produce the required composer.lock file because when running.
composer update
I get the error
The requested PHP extension ext-memcached * is missing from your system.
But it is in fact installed. I can see the version from typing.
memcached -h
But it is not present when typing
composer show --platform
Depending on what platform you're running, you have to make sure you that composer updates. Even if you have memcached installed, it has to match your PHP version. Then, once installed, run composer update
For example:
If you have PHP5.6.15, get memcached with, either, brew install php56/memcached or sudo apt-get install php56/memcached.
Then run composer update.
If you have an issue installing composer on Mac, you have to enable rootless install. More info can be found here:
https://donatstudios.com/OS-X-Mavericks-Memcached-PHP-Extension-Installation
The gist of the steps to take are:
Restart computer and hold Command + R to get into recover mode
Get into the terminal from Utilities
Run csrutil disable and restart
This should be done prior to installing memcached from Homebrew.
Hope this helps.
I had a similar issue, where I was getting the same "ext-memcached * is missing" error and could not see ext-memcached when running composer show --platform.
I noticed that when I originally installed memcached, homebrew showed me various alternatives. So on Mac OSX El Capitan, I ended up installing the one that matched my PHP version:
brew install homebrew/php/php55-memcached
And then I had to add it to php.ini:
extension=/usr/local/Cellar/php55-memcached/2.2.0/memcached.so
You can get the correct version path with:
brew info php55-memcached
And then I restarted Apache:
sudo apachectl restart
It finally showed up in the composer list and I was able to update composer without error.
What is the best way to get PHP 5.3 up and running on CentOS 5.4.
My machine says I have PHP 5.3 installed but running into an issue with my script that says
Fatal error: Class 'PDO' not found in /var/www/html/lib/rb.php on line 45
It fails trying to new up a PDO class in the RedbeanPHP 3.0 lib.
How can I fix this missing PDO problem?
I tried to follow these instructions:
from http://www.computingunplugged.com/issues/issue201102/00002619002
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# THIS LINE FAILED FOR ME
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
UPDATE
Someone removed their answer. It was good. I'm putting it back in with exact steps.
First I had to yum install php53u-devel
To quote "
You need the PDO extension. Usually the best way to install extensions is via PECL.
Before you can install any PECL extensions you need to install the php5-dev package
sudo pecl install pdo
sudo pecl install pdo_mysql
You then need add the following to the end of your php.ini file(s). Depending on which version of PHP you installed they’ll be /etc/php5/apache2/php.ini, /etc/php5/cgi/php.ini and /etc/php/cli/php.ini.
extension=pdo.so
extension=pdo_mysql.so
"
Now I get a mysql_query_missing when trying to run sudo pecl install pdo_mysql
and not sure how to get past this.
You'll have to install the php-pdo package as well.
Edit: Maybe this helps as well: How do I enable PDO using CentOS?
I have been successfully able to install PHP-5.3 on CentOS 5.4 Linux. I needed this to be able to successfully install and run Drupal 7 - which also worked out for me. Here are the details:
This is a copy of the answer I wrote up in ServerFault: https://serverfault.com/a/392168/29205
(...for my question: https://serverfault.com/questions/391772/php-xml-install-complains-of-dependency-php-common-but-this-is-already-installed/392168#392168 )
The solution is based on the accepted answer in:
https://serverfault.com/questions/391839/how-to-force-centos-yum-to-use-a-later-version-of-a-package-dependency-already-i
In summary: move to php5.3.
Reason: support for php5.2 as been removed owing to security issues as explained in that other question's accepted answer. This removal causes mismatch of the versions of the dependencies and therefore the error seen.
Background
I wanted to run Drupal 7 on a CentOS 5.4 machine. So I needed 5.3 version of PHP.
Here are the full working steps to upgrade to PHP 5.3 with working repositories as of May 24 2012 ( I provide comments preceded by # - you don't need these, just for your info)
# Comment: sites like http://www.computingunplugged.com/issues/issue201102/00002619001
# provide a good start for remedying the problem whereby we need 5.3 on CentOS 5.4 to run Drupal 7. But although their packages worked at the time, the links are now outdated, and updates to these are below.
# comment: (as of May 2012 - the following work, the reason for failures was use of 1) older packages no longer on the server and 2) change of address of one of the servers to dl.fedoraproject.org/pub/epel (credit to: http://osdir.com/ml/centos/2012-03/msg00057.html )
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm
yum erase php php-pear php-mysql php-cli php-common
yum install php53u php53u-pear php53u-cli php53u-common php53u-gd
yum install php53u-mbstring php53u-mcrypt php53u-mysql php53u-soap
yum install php53u-xml php53u-xmlrpc php53u-bcmath
# After doing the above, php -v shows 5.3.x But on attempting to install Drupal 7 you may get complaint of something "Your PHP installation is too old 5.1.6 Drupal requires at least PHP 5.2.4. See the system requirements page for more information." and php.info shows the same
# The remedy is to simply restart your apache server
service httpd restart
# credit to following for suggesting service httpd restart :-
# https://serverfault.com/a/207806/29205
# https://serverfault.com/questions/207762/centos-updating-php-via-yum-doesnt-change-the-version-apache-uses
# Drupal 7 install on CentOS 5.4 worked after applying the above steps
# If your MySQL server is not running (check by ps -ef | grep mysql ) then you can run:
/etc/init.d/mysqld
# ...to start it, and to make sure it starts when the machine is restarted or cold booted:
chkconfig mysqld on
I'm using yum on CentOS 5.1 - I hand-compiled PHP 5.2.8 from source, but have other packages installed using yum. I need to install a PHP extension via pecl, and it requires phpize to be installed as well. However, doing the following yields a dependency error:
sudo yum install php-devel
Error: Missing Dependency: php = 5.1.6-20.el5_2.1 is needed by package php-devel
Since I actually have a newer version of PHP already installed, how can I force yum to ignore this? Do I need to hand-compile pecl/phpize from source? I admittedly never had a problem before, it only seems to be because of a combo of compiles and yum installs.
Any thoughts?
Thanks,
Kyle
In general:
If you build it yourself, it goes into /usr/local, and is only accessible to other things in /usr/local.
If you install from RPM/Yum, it goes into /usr, and is accessible to /usr and /usr/local.
So, if you want to install PHP tools using home-compiled PHP, install them into /usr/local as well: typically, with GNU-type software, that'd be something like:
./configure --prefix=/usr/local && make && sudo make install
or
make prefix=/usr/local all && sudo make prefix=/usr/local install
…although most software should default to /usr/local unless you override its prefix setting.
If you want to “hand-build” packages that are based upon RPM's, you can use
yumdownloader --source WHATEVER-PACKAGE
rpm -i WHATEVER-PACKAGE.rpm
rpmbuild -bp ~/rpm/SPECS/WHATEVER-PACKAGE.spec
(your path equivalent to ~/rpm may vary; rpmbuild --showrc will tell you where)
This downloads the .src.rpm package, which contains the upstream (original author's) source (usually a tarball) as well as OS-specific patches; installs the sources into ~/rpm (or your rpmbuild prefix); and then unpacks the sources and applies the patches into ~/rpm/BUILD/WHATEVER-PACKAGE/
From there, you can do the configure/make steps yourself, with the /usr/local prefix
Of course, just installing from RPM's is far easier :-)
yum doesn't know anything about your hand-compiled php version. You can either bypass RPM's dependency resolution by installing the package using rpm --nodeps and hope it works.
Or install the php version you compiled yourself in another directory so it can coexist with the old version from yum, so everyone is happy (not sure if that's possible, I guess it depends on whether your apps use a hardcoded path to php or not).
Or, if you are lucky, a third-party repository like EPEL or RPMForge might have a newer php package, so you don't have to compile your own.
As a rule of thumb, it's better to have one package management in the system, so you'll be better off packaging everything in RPMS and managing it via yum. It will save you lots of time in the long run.
If you absolutely want to have something (fe PHP) compiler from sources by hand, use stow/checkinstall/... or any other solution which would enable you to do rudimentary package management for source-compiled stuff.
Regerding your question, you could try to override dependency checking by downloading RPM of the required package an doing "rpm -i --force file.rpm", since yum does not have any option for forced installations