June 29, 2012

Command line tools on Linux to beautify CSS ,Javascript, and PHP

For CSS, I use "csstidy", the C++ version. I added CSS 3.0 support to it and also added a default "indented" template. You can get the latest version at:

For Javascript, I use the command line version of jsbeautifier, which can be downloaded at

For PHP, I use an enhanced version of phptidy:

June 18, 2012

php.ini send email on Linux

If you just want to send email (not receiving email) from your PHP server, and you have a SMTP Email server, here is how you do it:

(First, you don't need to edit your php.ini file SMTP settings, because on Linux those are not used by PHP)

1. Install SSMTP on your system (Debian/Ubuntu via apt-get, RHEL/CentOS using the Fedora EPEL Package search to find the package.
2. Use "ssmtp" to replace "sendmail" on your system. ssmtp use the same command argument as sendmail.
3. configure your /etc/ssmtp/ssmtp.conf file:

#this allows you to specify your from address

4.  Now send an email. Type
ssmtp recipient_email@example.com
sSMTP will then wait for you to type your message, which needs to be formatted like this:
To: recipient_email@example.com
From: myemailaddress@gmail.com
Subject: test email

hello world!

Note the blank like after the subject, everything after this line is the body of the email. When you’re finished, press Ctrl-D.

You can also use script. Create a file msg.txt, then send it:
ssmtp myemailaddress@gmail.com < msg.txt

msg.txt is a simple text using the proper formatting for sSMTP:
To: myemailaddress@gmail.com
From: myemailaddress@gmail.com
Subject: alert

The server is down!

Credit: http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/

June 15, 2012

CentOS or RHEL enable PHP to make TCP Connect

setsebool -P httpd_can_network_connect 1

June 7, 2012

RHEL/Centos sysconfig network scripts

The /etc/sysconfig/network-scripts/ifcfg-ethN files

File configurations for each network device you may have or want to add on your system are located in the /etc/sysconfig/network-scripts/ directory with Red Hat Linux 6.1 or 6.2 and are named ifcfg-eth0 for the first interface and ifcfg-eth1 for the second, etc. Following is a example /etc/sysconfig/network-scripts/ifcfg-eth0 file:

If you want to modify your network address manually, or add a new network on a new interface, edit this file -ifcfg-ethN, or create a new one and make the appropriate changes.

  • DEVICE=devicename, where devicename is the name of the physical network device.
  • IPADDR=ipaddr, where ipaddr is the IP address.
  • NETMASK=netmask, where netmask is the netmask IP value.
  • NETWORK=network, where network is the network IP address.
  • BROADCAST=broadcast, where broadcast is the broadcast IP address.
  • ONBOOT=answer, where answer is yes or no. Do the interface need to be active or inactive at boot time.
  • BOOTPROTO=proto, where proto is one of the following :

    1. none - No boot-time protocol should be used.
    2. bootp - The bootp now pump protocol should be used.
    3. dhcp - The dhcp protocol should be used.
  • USERCTL=answer, where answer is one of the following:

    1. yes - Non-root users are allowed to control this device.
    2. no - Only the super-user root is allowed to control this device.  

      NM_CONTROLLED="no"/"yes" : Whether Network-Manager controlled