PHP Unable to send email from web application .. (but commandline works)

This issue seems to have popped up a couple times over the past couple weeks so I figure I would capture the resolution here in the event someone stumbles onto this post and it's able to help them. Security is rarely convenient and this is an example of that.

Symptom:

CentOS machine running current on patches and running a current version of PHP, let's say PHP 5.3 or higher. PHP script is able to sent email from the command line, but when trying to send an email with PHP through the web browser it fails. Actually it doesn't "fail" it just doesn't seem to ever send.

Resolution:

SELinux is running on the machine and is preventing the Apache process to send out emails. There are a couple approaches you can take for this. To quickly test and confirm that the problem is in fact SELinux, and not something else, you can temporarily disable SELinux.

  • First verify SELinux is running with the command (as root) getenforce
  • Next, if SELinux is running you can disable with the command, again as root, setenforce Permissive

 

SELinux with be disable until you reboot the machine or enable it with setenforce Enforcing. You can permanently disable SELinux is you so desire editing the file /etc/sysconfig/selinux and changing the setting SELINUX=

Test your PHP Mail functionality now from the web application. If it works then you need to have SELinux allow the apache process to send emails. In order to do this, run the commands

  • setsebool -P httpd_can_sendmail 1
  • setsebool -P httpd_can_network_connect 1

 

You should now be able to re-enable SELinux and successfully send emails from your application in the browser.

Added photos to SCALE 12x – Southern California Linux Expo.

Added photos to SCALE 12x - Southern California Linux Expo.

Hanging out at #scale12x in Los Angeles today. Conference gets bigger and bigger every year.

Hanging out at #scale12x in Los Angeles today. Conference gets bigger and bigger every year. 

Scale11x Interview: Jorge Castro – Juju

I was asked if I would be interested in conducting some interviews of speakers who are going to speak at The Eleventh Annual Southern California Linux Expo (Scale11x) February 22-24, 2013 Hilton Los Angeles International Airport and needless to say I jumped at the opportunity.

This is my first interview with Jorge Castro of Canonical and we discuss Juju, MaaS, Ubuntu Cloud, and his upcoming presentations and workshop.

You can catch Jorge and learn more about Juju at the Eleventh Annual Southern California Linux Expo, February 22-24, http://www.socallinuxexpo.org/blog/interview-jorge-castro-juju

Getting some functionality back in the system tray on Ubuntu 11.04

Ubuntu 11.04 introduced a new, cleaner user interface called Unity. I'm not a huge desktop GUI guy, doing a large majority of my work in the command line, but I do like to try and stay current on the latest greatest interfaces.

I'm not overwhelmed with Unity. It's OK but not really earth shattering. You have the option to switch back to the "classic" Gnome interface if you wanted to but I haven't done that.

One huge annoyance I've noticed about the new Unity interface was a lack of a true "system tray". Many application in Ubuntu (or Linux in general) leverage a similar approach Windows machine do and allow applications to run in a System Tray, cleaning up any task bars you might have. In Unity, there were a couple applications that were visible, like Dropbox, the clock and Volume but several others were not such as Skype and Truecrypt.

This became a big problem for Truecrypt because once I closed the Truecrypt interface I couldn't figure out how to get back to it. If I tried to launch the application again the system would report that it the application was already running, which it was. In the past I would get back to the interface through the icon in the system tray but this icon would not display in Unity, at least not until I found a posting on Facebook http://www.facebook.com/topic.php?uid=6723083591&topic=17003

This simple command in a terminal window corrected my problem and life is good again

  1. gsettings set com.canonical.Unity.Panel systray-whitelist "['all']"

As you can see I got all my system tray icons back and I am now a little happier with Unity.

 

Screenshot-1

 

Posted via email from shocm

Nasty Bug – Ubuntu 10.04 on VMWare Fusion OSX

Came across a nasty little bug when I installed the latest Ubuntu 10.04 (LTS) into a virtual machine using VMWare Fusion 3.02 on my OSX box. This was a fresh install and the install itself went smooth, the problem occured when the initial login screen appeared. Although my mouse worked just fine and I was able to click on the user to log in, I wasn't able to type anything. My keyboard was completely unusable within the virtual machine. I was not able to type any input via the keyboard.

After doing some Googling I discovered that once you got past the login screen the keyboard would work fine. The only way to login was to initiate the on-screen keyboard and type in your password. You can bring up the on-screen keyboard by clicking on the Universal Access icon on the lower right hand side of the screen and choosing "Use on-screen keyboard". One side note here, when I first checked the box to use the on-screen keyboard, the keyboard would flash and disappear. What I needed to do was keep the box check and reboot the machine, when the login screen returned, the keyboard was there.

Once I logged in the physical keyboard worked fine. I was able to use it in all the applications and didn't notice any problems, but once I logged out and returned to the login screen, again no input from the physical keyboard. Now I needed to fix this.

What didn't work 🙁

At this point I go into basic trouble resolution mode and decided to start by reinstalling and upgrading the VMWare tools. Not going to get into a step by step here how to do that but the short of it is after reinstalling the VMWare tools and rebooting I was stuck in the same situation and needed to use the on-screen keyboard to log in. Next obvious step, apply all patches to the Ubuntu desktop, did this, rebooted, still no go.

What did work 🙂

Clearly, you are not reading this article to learn how not to fix it. Trust me after doing enough searches there are plenty discussion threads out there with "This doesn't work for me either, anyone fix this yet?" to keep you reading for hours. I found a couple good links that I will post at the end of this article that got things resolved. The short answer is I logged into the machine, fired up and console window, type in the command
[bash]
sudo dpkg-reconfigure console-setup
[/bash]
For keyboard I selected "Apple" and then just selected the defaults for everything else. Once I exited the configuration wizard, I restarted the machine and all was right with the Ubuntu world again. Did a couple reboots to make sure and everything seems to be working fine now.

One more side note

This issue  occurred on a clean install of the current Ubuntu 10.04 LTS release. I had been previously running the beta version of the 10.04 release which worked fine and never had a problem with the keyboard input. However, after patching that box today, same issue occurred.

The Links

Two links basically lead me to my resolution

[Nagios] Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’!

System: Ubuntu 9.10 | Nagios 3.x

This is another post that is more of a note to myself than anything else. Been doing a lot of Nagios configuring and decided to implement the ability to push commands from the web interface. I followed the basic instructions to configure "External Commands" but after doing and going to the web interface to test it, I got the following error message;

Error: Could not stat() command file '/var/lib/nagios3/rw/nagios.cmd'!

The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands. An error occurred while attempting to commit your command for processing.

The file was there so I did what any good geek should do, I did a quick google search. The closet thing I could find was some commands to fix the issue on Debian systems. Since I was running Ubuntu, which is for all intensive purposes Debian, I figured I would try it.  So I ran the following set of command;

sudo /etc/init.d/nagios3 stop
sudo dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
sudo dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3
sudo /etc/init.d/nagios3 start

This worked like a charm and the web interface began accepting commands.

Open Source, Open World

Came across this great graph outlining some interesting facts around Open Source. Original article was called "Should Open Source Be An Enemy Of The State?" and is itself a good article discussing some of the paradox around recent suggestion made is US policies and Open Source. 

Posted via email from shocm

My First Linux Servers at Work – 2002

Buddy of mine posted a video he had of me when I first worked for Sony as a consultant. Took this video right before I was leaving the gig, sometime in 2004 2002, and we were walking through one of our data centers. Of course the one proud points of achievement I wanted to point out was the fact that I had finally implemented Linux in the environment. Now of course, I am back at Sony and 90% of the environment I am is responsible for is Linux based.

Posted via web from shocm's posterous

Dropbox Client for Linux

Recently I got my invite to try out the new Dropbox service. I am a long time Folder Share user and had heard some good things about Dropbox. I have to say, I am very happy with the performance of Dropbox and was even more pleased when I found out there was a Open Source Linux client. Figured I wouldn't be a good geek if I didn't do a quick install and see how it performed. Here is a video of that effort.

Dropbox has clients that run on Windows, Mac, and Linux
http://www.getdropbox.com/

Running Adobe Air On Linux

I had made mention last week to a couple of friends how I got a few Adobe Air applications up and running on my Ubuntu install. I walked one person through how I did it and decided to also make a quick video tutorial on the process.

A couple disclaimers, first one is that I use my Ubuntu laptop on a daily basis and I have had it up and running for awhile so I am not sure if I installed some supporting packages that make this work. I haven't tried this on a fresh default install of Ubuntu. Second, I was trying to keep the video somewhat short so I didn't get into some of the corkyness that I see in the applications, like on Pownce you don't get the embedded video feeds. Remember, this is Alpha software and it seems like how well the applications are written also factors into how well they are going to run under Linux.

Hope you enjoy the video. Here are the links from the video encase you miss them.

Adobe Labs - http://labs.adobe.com/technologies/air/
Tweet Deck - http://www.tweetdeck.com/beta/
Twhirl - http://www.twhirl.org/
Pownce - http://pownce.com/download/

UPDATE: I mentioned in my video how you don't need to save the .air file but can instead just launch it with the "Open With" in the dialog box. This works fine on my Gutsy box but doesn't seem to work on my newer 8.04 Hardy box. Even though Hardy recognizes that the file should be launched using the "Adobe Air Application Installer", I still get the error that "the associated helper application does not exist" when I trying using it. You can however save the file to disk, right click, and select "Open With Adobe Air Application Installer" and it works fine. Not sure why I have this behavior.

UPDATE (2008-Sept-16): Adobe moved the Linux version of AIR to beta (link) and this has fixed a couple of things. First, the issue from my last update doesn't appear to be a problem anymore on Hardy. Second, now AIR Applications have their pretty icons. And finally, and most exciting, Pandora AIR client now works!! 🙂

Fun with SAY

Sometimes it's the simple things that amaze people and leave them thinking you are some type of computer genius. My daughters have grown up with computers, and I mean hardcore. Their first computer was a SUSE Linux machine; they've worked on Windows and OS X boxes and they know their way around them all. At 10 years old, they've taken over the IT tech support duties for my wife. Next, I am going to install a phone line in their room so other family members can call them when they need help. What I am trying to say is, their Dad's vast knowledge of computers doesn't impress them. Whenever I think I'm showing them something new and cool on the computer, they have an attitude of "huh, I just didn't know how to do it, now I do and its not that cool".

I myself get kind of like that too, I am pretty hardcore geek and bells and whistles on computers don't really impress me. I typically look at things on a much deeper level. That's why when I read an article sometime back called "Having fun with the SAY command in your Terminal" I thought to myself, "Cute" and filed it away in the back of my mind thinking I will never have a use for that command.

The SAY command on OS X is a Speech Synthesis Manager. If you own an OS X machine, open a terminal window and type "man say" (minus the quotes) for more information, or just type "say Hello. do you want to play a game" and start having fun with it.

One day, one of my daughters and I were having somewhat of a disagreement on if it was more important for her to clean her room or finish watching TV; guess which side I was on. As privileges started to get stripped away, right after "no more pool time" but before "no more Playstation3 time", she stomps off into her room. Knowing she wasn't in her room doing what was asked of her, and knowing I was probably too mad myself to try to talk to her, I sat at my laptop tapping the space bar. Then it dawned on me; I fired up a terminal session on my Ubuntu laptop and made a ssh connection to my daughter's computer in her room and proceeded to test out that SAY command. It went something like this;

say Why are you so mad

I hear a deep synthetic voice mumble come from behind my daughters' door followed by a somewhat confused sounding voice of a little girl.

say Didnt your dad ask you to clean your room? I like a clean room

Some more little girl mumbles. Is she arguing with the computer now?

say Your dad is probably the smartest man I know, and may be the smartest man on earth, you should listen to him

OK, that last one might have been too much and may have tipped her off. I hear her door open and she yells, "I don't know how you are doing that but you better show me"

Anyways, SSH with SAY and you can have all sorts of fun with co-workers, family, and friends. Further more they will think you are truly 1337.

If everyone used Linux on the Desktop I wouldn't be cool anymore ….

Interesting, something to think about 🙂

Funny comic, I love UserFriendly.org

Auto Login with Ubuntu

So typically I would not recommend auto login setting be set for your system but there are some exceptions. For example, when that system is a Virtual Machine running on your desktop.

I've been playing around a lot with my Ubuntu configuration on a virtual machine running under VMWare Fusion. I got tired of having to log into the machine every time I booted it when I was already logged onto my desktop of the host machine. So for the first time, I found myself trying to figure out how to auto login my Linux desktop. In my typical “learn the hard way” fashion, I over thought the problem and approach several times before discovering how simple it was. A couple of clicks to be exact.

Step 1: Fire up a terminal screen and type “ sudo gdmsetup ”
commandterminal.png

Step 2: This should bring up the “Login Window Preferences” dialog box. Click on the security tab, click the check box for “Enable Automatic Login”, select the user you want to Auto Login as and click close.
loginwindowpreferences.png

That's it, couldn't be simpler.