PHP: Check if PID is running

I needed to write a small function, that can check if a specific PID is running an linux/unix system.

Check it out on Gist: https://gist.github.com/3096556

CentOS 6.2: Make eth0 work with DHCP

I recently installed CentOS 6.2 in a VirtualBox and was pretty astonished, because it did not have networking or a eth0 working.

You need to change this file:
/etc/sysconfig/network-scripts/ifcfg-eth0
to this:
ONBOOT="yes"
NM_Controlled="no"
BOOTPROTO="dhcp"

More info about that problem:
http://it.toolbox.com/blogs/linux-gnu/configuring-the-ethernet-nic-in-centos-6-rhel-6-scientific-linux-6-48390

Configure eth0:
http://www.cyberciti.biz/faq/linux-configure-a-static-ip-address-tutorial/

Linux: Use Git to backup/store /etc directory

If more than one person has to manage a server, it might come in handy to have some kind of versioning of the config files.
But also having the possibility to keep track of local configuration changes in your system could be very usefull.

I found 2 tools that can help you:

1. etckepper
http://joeyh.name/code/etckeeper/

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It’s quite modular and configurable, while also being simple to use if you understand the basics of working with revision control.

2. Changetrack:
http://changetrack.sourceforge.net/

Changetrack logs modifications of a set of files, and allows recovery of the tracked files from any stage of development. The changes are presented in a powerful web-based form, a text file, or an email message. A handful of options allow situation-specific configuration, but the code is readily available for more complex modifications.

Apache2: apr_sockaddr_info_get() failed for HOSTNAME

If your apache2 outputs this warning when starting, read along how to fix it:

Problem is that Apache2 is told to use a hostname that the system can not resolve.
Simple solution is to put HOSTNAME to the /etc/hosts file, like this:

If you have the problem that your /etc/hosts is ignored, check this article:
Linux: /etc/hosts gets ignored

Linux: /etc/hosts gets ignored

I had the problem that my /etc/hosts wasn’t read by the system.

First: Use ping to test local Hostname lookups, because dig calls the nameservers directly.

There are two files that can configure in which order the lookup system are tried.
The two systems are the local hosts file and the normal DNS system.

/etc/host.conf

“order hosts,bind” tells the system to use the hosts file first, and then try bind == DNS system.

/etc/nsswitch.conf

“hosts: files dns” tells the system to use the hosts files first, and then try DNS system.

Try which file has to be edited, because it is not clear which is used.

Symfony2: Doctrine github Repos moved from symfony to doctrine

Today i tried to run php bin/vendors install and got this output:

and this:

You have to change dour deps file like this to resolve the problem:

old:

new:

Official change:
https://github.com/doctrine/DoctrineFixturesBundle/commit/479f10d068bd0b01e055aa2f555946893322b79c

Linux: Using apt-get behind a http/ftp proxy

You need to create a file /etc/apt/apt.conf with the following content:

For HTTP:

For FTP:

You need root permissions to create/edit that file, but for using apt-get you already do so.

Bash: Set HTTP / FTP Proxy with Username and Password

You can set a HTTP Proxy for the CURRENT BASH with this command:

A FTP Proxy can be set like this:

With username and password it looks like this:

You can unset it with this commands:

Maybe use telnet to check if your proxy is reachable:

Press CTRL-C to abort if necessary.