Category Archives: CentOS

CentOS “Error: php-mysql conflicts with php-mysqlnd” updating with PHP 7.0

If you get an error about a conflict between php-mysql and php-mysqlnd when updating CentOS packages after installing and activating the PHP 7.0 remi package source like this one:

# yum -y install php-mysql

...

--> Finished Dependency Resolution
Error: Package: php-mysql-5.4.45-7.el6.remi.x86_64 (remi)
           Requires: php-pdo(x86-64) = 5.4.45-7.el6.remi
           Removing: php-pdo-5.3.3-46.el6_7.1.x86_64 (@updates)
               php-pdo(x86-64) = 5.3.3-46.el6_7.1
           Updated By: php-pdo-7.0.5-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.5-1.el6.remi
           Available: php-pdo-5.3.3-40.el6_6.x86_64 (base)
               php-pdo(x86-64) = 5.3.3-40.el6_6
           Available: php-pdo-5.3.3-46.el6_6.x86_64 (updates)
               php-pdo(x86-64) = 5.3.3-46.el6_6
           Available: php-pdo-5.4.45-5.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-5.el6.remi
           Available: php-pdo-5.4.45-7.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-7.el6.remi
           Available: php-pdo-7.0.4-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.4-1.el6.remi
Error: php-mysql conflicts with php-mysqlnd-7.0.5-1.el6.remi.x86_64
Error: Package: php-mysql-5.4.45-5.el6.remi.x86_64 (remi)
           Requires: php-pdo(x86-64) = 5.4.45-5.el6.remi
           Removing: php-pdo-5.3.3-46.el6_7.1.x86_64 (@updates)
               php-pdo(x86-64) = 5.3.3-46.el6_7.1
           Updated By: php-pdo-7.0.5-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.5-1.el6.remi
           Available: php-pdo-5.3.3-40.el6_6.x86_64 (base)
               php-pdo(x86-64) = 5.3.3-40.el6_6
           Available: php-pdo-5.3.3-46.el6_6.x86_64 (updates)
               php-pdo(x86-64) = 5.3.3-46.el6_6
           Available: php-pdo-5.4.45-5.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-5.el6.remi
           Available: php-pdo-5.4.45-7.el6.remi.x86_64 (remi)
               php-pdo(x86-64) = 5.4.45-7.el6.remi
           Available: php-pdo-7.0.4-1.el6.remi.x86_64 (remi-php70)
               php-pdo(x86-64) = 7.0.4-1.el6.remi
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

You can just remove the PHP 5.x version of php-mysql:

# yum remove php-mysql

Update all the packages:

# yum -y update

And finally just install php-mysql again but this time it will be from PHP 7.0:

# yum -y install php-mysql

Install MongoDB and the PHP driver in CentOS

Install MongoDB server

Create the /etc/yum.repos.d/mongodb-org-3.0.repo file with this content:

[mongodb-org-3.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1

Then install mongodb with this commando:

# yum install -y mongodb-org

This are the important files and folders for MongoDB in CentOS:

  • Configuration file: /etc/mongod.conf
  • Data files: /var/lib/mongo/
  • Logs files: /var/log/mongodb/

By default the used port is 27017 and also you can ONLY make connections to it within the localhost or 127.0.0.1. If you want to change that you have to edit the bind_ip option:

bind_ip=127.0.0.1

To start the server run this command:

# service mongod start

To stop the server run this command:

# service mongod stop

If you want the server to start on boot:

# chkconfig mongod on

Once the service is running we can connect to it with the mongo command:

$ mongo
MongoDB shell version: 3.0.6
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
>

Install the PHP driver

Install the required dependencies and the mongo PHP driver itself:

# yum -y install gcc openssl-devel php-devel php-cli php-pear
# pecl install mongo

Note: the library will be installed in /usr/lib64/php/modules/mongo.so

Activate it in /etc/php.ini or in it’s own file in /etc/php.d/30-mongo.ini:

extension=mongo.so

And finally restart httpd:

# service httpd restart

mongodb-logo

Ref: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat/
http://docs.mongodb.org/ecosystem/drivers/php/

Fix “Clocksource tsc unstable” kernel message in a virtualized CentOS

If you use CentOS in a virtual environment it may be possible to get hundreds or messages like this from the kernel (using dmesg):

Clocksource tsc unstable (delta = -227342541 ns).  Enable clocksource failover by adding clocksource_failover kernel parameter.

clocksource_failover

First check which clocksources are available:

$ cat /sys/devices/system/clocksource/clocksource0/available_clocksource

And which is being used at the moment:

$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource

Most probably CentOS is using tsc and it also will be available acpi_pm.

To fix the issue edit /etc/grub.conf and add to the kernel configuration line clocksource_failover=acpi_pm:

kernel /vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=/dev/mapper/vg_centos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_centos/lv_swap  KEYBOARDTYPE=pc KEYTABLE=es rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg_centos/lv_root rd_NO_DM rhgb quiet clocksource_failover=acpi_pm

Then reboot and the problem should be gone.

Useful yum commands

Those are some commands that you’ll probably need sometime to install, remove, update, etc. software in your CentOS/Fedora/Red Hat box. As I’m more used to apt-get I’ve searched a fairly complete list of tasks I’ll need in the future.

centos

See installed packages:

yum list installed

Search for an installed package:

yum list installed | grep php

See available packages:

yum list available

Search for available packages:

yum list available | grep php

See information of a package:

yum info php
Name        : php
Arch        : x86_64
Version     : 5.3.3
Release     : 27.el6_5
Size        : 3.5 M
Repo        : installed
...

Install a package:

yum install package-name

Install a package without being asked for permission before installation process:

yum -y install package-name

Remove a package:

yum remove package-name

Remove a package without being asked for permission before removing process:

yum -y remove package-name

Remove orphan packages:

package-cleanup --quiet --leaves --exclude-bin | xargs yum remove -y

Check if a package has an update available:

yum check-update package-name

Update a package:

yum update package-name

See if any update is available:

yum check-update

Update everything:

yum update

Automatic updates

su -c '/sbin/chkconfig --level 345 yum on; /sbin/service yum start'

Note: There is no separate yum service that runs on your system. The command given above enables the control script /etc/rc.d/init.d/yum. This control script activates the script /etc/cron.daily/yum.cron, which causes the cron service to perform the system update automatically at 4am each day.

Add EPEL and Remi repositories:

For i686:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

For x86_64:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Now you’ll see the new files that configure those repositories:

$ ls -1 /etc/yum.repos.d/
CentOS-Base.repo
CentOS-Debuginfo.repo
CentOS-Media.repo
CentOS-Vault.repo
epel.repo
epel-testing.repo
remi.repo

The Remi repository comes disabled by default so you’ll have to enable it by changing it’s enabled option to 1 or executing this command:

yum-config-manager --enable remi

Add ElRepo repository:

Import the public key:

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

Install the repo:

rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm

Add RPMforge repository:

Import the GPG key:

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Install for i686:

rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm

Install for x86_64:

rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Now you can install any software from that repository:

yum install htop

See available group of packages (for example MySQL is made by many packages):

yum grouplist
...
Installed Groups:
   Administration Tools
   DNS Name Server
   Dialup Networking Support
...
Available Groups:
   Authoring and Publishing
   Base
   Beagle
...

Install a grouplist:

yum groupinstall 'Beagle'

Update a grouplist:

yum groupupdate 'Beagle'

Remove a grouplist:

yum groupremove 'Beagle'

Clean the cache to delete files from /var/cache/yum

yum clean all

View the history of different installations, removes, etc.:

yum history
D     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   12 |  <user>                  | 2014-05-22 21:33 | Install        |    2
   11 |  <user>                  | 2014-05-22 21:31 | Install        |    3
   10 |  <user>                  | 2014-05-22 21:29 | Install        |    6
    9 |  <user>                  | 2014-05-22 21:05 | Install        |    4
    8 | System <unset>           | 2014-04-19 01:55 | I, U           |  117 EE
    7 | root <root>              | 2013-08-14 14:48 | I, U           |  156 EE
    6 | root <root>              | 2013-08-14 14:37 | Erase          |    1
    5 | System <unset>           | 2011-12-20 20:03 | I, U           |  162 EE
    4 | System <unset>           | 2011-07-10 19:29 | Install        |    3
    3 | System <unset>           | 2011-07-10 19:22 | Update         |   60  < 
    2 | System <unset>           | 2011-07-08 20:03 | Erase          |    6 > 
    1 | System <unset>           | 2011-07-08 20:43 | Install        |  276

To see a detailed information of an specific history operation use this command:

yum history info 11
Loaded plugins: fastestmirror
Transaction ID : 11
Begin time     : Thu May 22 21:31:08 2014
Begin rpmdb    : 292:63d8bb066751f0def9baf9c3aca697fa2dfaef21
End time       :            21:31:10 2014 (2 seconds)
End rpmdb      : 295:0f2bb4c03af71739f9be1f59c7bcfab9540de5d8
User           :  <user>
Return-Code    : Success
Command Line   : install php
Transaction performed with:
    Installed     rpm-4.8.0-37.el6.x86_64                         @base
    Installed     yum-3.2.29-43.el6.centos.noarch                 @updates
    Installed     yum-plugin-fastestmirror-1.1.30-17.el6_5.noarch @updates
Packages Altered:
    Install     php-5.3.3-27.el6_5.x86_64        @updates
    Dep-Install php-cli-5.3.3-27.el6_5.x86_64    @updates
    Dep-Install php-common-5.3.3-27.el6_5.x86_64 @updates

You can see in the “Packages Altered” area what packages were installed, deleted, updated or whatever.

See the list of configured repositories:

yum repolist
repo id                        repo name                                 status
base                           CentOS-6 - Base                           6.365+2
extras                         CentOS-6 - Extras                              14
updates                        CentOS-6 - Updates                          1.103
repolist: 7.482

Ref: http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x
http://wiki.centos.org/AdditionalResources/Repositories/RPMForge
http://elrepo.org/tiki/tiki-index.php
http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/

Network not running in a CentOS VirtualBox machine

Be sure that your network options in VirtualBox are configured like this:

virtualbox-network

  • Attached to: Bridget Adapter
  • Name: (your network device)
  • Promiscuous Mode: Deny
  • Cable Connected: Check

Then inside the CentoOS virtual machine edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file so the eth0 device is loaded on boot and it’s fully controlled by the /etc/sysconfig/network-scripts/ scripts instead of the NetworkManager daemon:

ONBOOT=yes
NM_CONTROLLED=no

Then restart the network:

service network restart

Now you should have an eth0 adapter up and running:

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:08:CA:1C:18:5A
          inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.224
          inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2341604 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2217673 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293460932 (279.8 MiB)  TX bytes:1042006549 (993.7 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:5019066 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5019066 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:816 (816.0 b)  TX bytes:816 (816.0 b)