background image

Content tagged with: yum

Eric's picture

This morning, I encountered a PHP fatal error on my development environment. Upon further inspection, one of my third party modules (XML Sitemap) required a later version of PHP. A fresh installation of Centos 5.3 comes with version 5.1.6 of PHP. Here is an easy way to upgrade PHP to a later version by using the Utter Ramblings Yum repository.

I created a new yum repo file:

$ sudo emacs /etc/yum.repos.d/utterramblings.repo

# FILE CONTENTS - START
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# FILE CONTENTS - END

Ran a yum update:

$ sudo yum update
# ...snip...
Updated: apr.i386 0:1.2.12-2.jason.1 apr-util.i386 0:1.2.12-5.jason.1 curl.i386 0:7.15.5-2.1.el5_3.5 httpd.i386 0:2.2.8-jason.3 ksh.i386 0:20080202-2.el5_3.1 mod_ssl.i386 1:2.2.8-jason.3 mysql.i386 0:5.0.58-jason.2 mysql-server.i386 0:5.0.58-jason.2 pcre.i386 0:7.6-jason.1 php.i386 0:5.2.6-jason.1 php-cli.i386 0:5.2.6-jason.1 php-common.i386 0:5.2.6-jason.1 php-gd.i386 0:5.2.6-jason.1 php-mbstring.i386 0:5.2.6-jason.1 php-mssql.i386 0:5.2.6-jason.1 php-mysql.i386 0:5.2.6-jason.1 php-odbc.i386 0:5.2.6-jason.1 php-pdo.i386 0:5.2.6-jason.1 php-pear.noarch 1:1.6.2-1.jason.1 php-xml.i386 0:5.2.6-jason.1 php-xmlrpc.i386 0:5.2.6-jason.1 subversion.i386 0:1.4.4-jason.1 tzdata.noarch 0:2009k-1.el5
Complete!

After updating all these packages, I checked out my new PHP version:

$ php -v | head -1
PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)

Now, my PHP fatal error has been resolved.

NOTE: This blog entry is a re-post of a previous article.

Eric's picture

I just encountered a PHP fatal error when running my cron.php:

Fatal error: Call to undefined function timezone_open() in /MYSERVERPATH/httpdocs/sites/all/modules/date/date_api.module on line 607

A quick Google search, and I found the issue is documented here. The solution is to enable the Date PHP4 module. But, this issue does not happen in our production environment, so I decided to compare PHP versions:

# on the production server:
$ php -v | head -1
PHP 5.2.8 (cli) (built: Dec  9 2008 14:03:11)

It turns out, a fully updated installation of Centos 5.2 only supplies PHP 5.1.x. So, I decided to upgrade PHP in my development environment according to this documentation.

I created a new yum repo file:

$ sudo emacs /etc/yum.repos.d/utterramblings.repo

# FILE CONTENTS - START
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# FILE CONTENTS - END

And, ran another yum update:

$ sudo yum update
# ...snip...
Resolving Dependencies
# ...snip...
Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Updating:
apr                     i386       1.2.12-2.jason.1  utterramblings    257 k
apr-util                i386       1.2.12-5.jason.1  utterramblings    159 k
httpd                   i386       2.2.8-jason.3    utterramblings    2.5 M
mod_ssl                 i386       1:2.2.8-jason.3  utterramblings    314 k
mysql                   i386       5.0.58-jason.2   utterramblings    6.4 M
mysql-server            i386       5.0.58-jason.2   utterramblings     10 M
pcre                    i386       7.6-jason.1      utterramblings    562 k
php                     i386       5.2.6-jason.1    utterramblings    3.7 M
php-cli                 i386       5.2.6-jason.1    utterramblings    2.6 M
php-common              i386       5.2.6-jason.1    utterramblings    481 k
php-devel               i386       5.2.6-jason.1    utterramblings    568 k
php-gd                  i386       5.2.6-jason.1    utterramblings    320 k
php-ldap                i386       5.2.6-jason.1    utterramblings     56 k
php-mbstring            i386       5.2.6-jason.1    utterramblings    1.3 M
php-mssql               i386       5.2.6-jason.1    utterramblings     61 k
php-mysql               i386       5.2.6-jason.1    utterramblings    258 k
php-odbc                i386       5.2.6-jason.1    utterramblings    112 k
php-pdo                 i386       5.2.6-jason.1    utterramblings    159 k
php-pear                noarch     1:1.6.2-1.jason.1  utterramblings    418 k
php-soap                i386       5.2.6-jason.1    utterramblings    342 k
php-xml                 i386       5.2.6-jason.1    utterramblings    316 k
php-xmlrpc              i386       5.2.6-jason.1    utterramblings    130 k
subversion              i386       1.4.4-jason.1    utterramblings    4.3 M

Transaction Summary
=============================================================================
Install      0 Package(s)        
Update      23 Package(s)        
Remove       0 Package(s)        

Total download size: 35 M
Is this ok [y/N]:

After updating all these packages, I checked out my new PHP version:

$ php -v | head -1
PHP 5.2.6 (cli) (built: May  5 2008 10:32:59)

Now, my PHP fatal error has been resolved :)

Eric's picture

I just went to install a package from source on my Centos linux virtual machine and got the following error:

$ ./configure
checking for gcc... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

No worries, you just need to install a C compiler. First I took a look at what's available via yum:

$ yum list | grep -i ^gcc
gcc.i386                                 4.1.2-42.el5           base           
gcc-c++.i386                             4.1.2-42.el5           base           
gcc-gfortran.i386                        4.1.2-42.el5           base           
gcc-gnat.i386                            4.1.2-42.el5           base           
gcc-java.i386                            4.1.2-42.el5           base           
gcc-objc.i386                            4.1.2-42.el5           base           
gcc-objc++.i386                          4.1.2-42.el5           base

And then install one:

sudo yum install gcc

Now, back to installing my package from source...

Eric's picture

I do almost all of my development on Centos virtual machines. This allows me to keep my filesystem, databases, and server configurations contained in a separate environment without harming my host operating system (OSX). This morning, I encountered a problem with my email not being delivered properly. I'm assuming this happened because my virtual machine is not a full qualified email server. I figured the easiest solution would be to setup my virtual machine as an IMAP server instead of trying to fight with DNS, static IPs, spam filters, etc. When it comes down to it, all I need is for my emails sent from my web applications to end up in my email client inbox. Here's what I did to get this to work...

1. Ditch sendmail and install postfix. Postfix is much easier to configure; Sendmail is jibberish.

yum remove sendmail
yum install postfix
chkconfig --level 2345 postfix on

2. Install cyrus, my preferred IMAP service. NOTE: SASL will be the authentication method service

yum install cyrus-imapd cyrus-sasl
chkconfig --level 2345 cyrus-imapd on
chkconfig --level 2345 saslauthd on

3. Configure Postfix service

# edit /etc/postfix/main.cf and change this line:
mailbox_transport = cyrus

# most importantly, I added a few domains (work, personal, etc) to the mydestination variable to ensure that mail sent from my server will be delivered locally, instead of leaving my virtual machine. Make sure you add all the corresponding aliases in /etc/aliases. For instance: If you want to receive email sent to wee@blah.com, you'll have to add blah.com to the list of domains in mydestination and add an alias for wee to redirect to your email account name.

4. Configure Cyrus

# set sasl passwords
saslpasswd2 cyrus
saslpasswd2 eric

# Use Cyrus admin tool to configure mailbox
cyradm --user cyrus --server localhost
> createmailbox user.eric
> setaclmailbox user.eric eric all
> quit

5. Add a new IMAP account in your favorite email client. For my setup, I used the IP address of my virtual machine as the incoming mail server address. Now, when mail is delivered from my virtual machines, it is delivered locally and my email client is used to fetch the new messages!

6. To ensure your setup is working properly, you can send a quick email from the command line (on your virtual machine)

date | mail eric@somedomain.com