Monday 31 March 2014

Fixing slow performance of sending mail from PHP via Sendmail

Source: http://www.alphadevx.com/a/372-Fixing-slow-performance-of-sending-mail-from-PHP-via-Sendmail


Recently I have had two separate test servers that were very slow sending out emails from PHP scripts via the mail() function, where PHP was configured to use a local Sendmail binary to send the emails. The scripts were hanging for roughly one minute while waiting for Sendmail to work, which was severely impacting testing efforts.
When I run a test call to mail() and tail the maillog file, I see the following entries:
 1 
 2 
 3 
 4 
 5 
$ tail -f /var/log/maillog
Sep 13 11:30:27 myserver sendmail[29118]: My unqualified host name (myserver) unknown; sleeping for retry
Sep 13 11:31:27 myserver sendmail[29118]: unable to qualify my own domain name (myserver) -- using short name
Sep 13 11:31:27 myserver sendmail[29118]: My unqualified host name (myserver) unknown; sleeping for retry
Sep 13 11:31:35 myserver sendmail[29135]: My unqualified host name (myserver) unknown; sleeping for retry
So it seems that this is a local domain name resolution issue. The trick here is to ensure that you have an entry in your /etc/hosts file for your unqualified hostname, that is the short version returned by the hostname command, which points to the local loop-back IP rather than it's external IP like so:
 1 
127.0.0.1               localhost localhost.localdomain myserver
You need to also ensure that this is the only line in that file for the 127.0.0.1 loop-back IP, as Sendmail will only look at a single line.

Friday 28 March 2014

Subversion: reset user password

./htpasswd -m /path/to/your_svn_auth_file username_to_reset

Wednesday 5 March 2014

Notes on setting up Web server for php mysql development on centos

Setup LAMP on Centos for dev:
- Install Centos
- configure networking
- update system
- disable selinux
- restart system
- configure hostname for dsn resolution at webserver and dev host
- install Apache (httpd)
- configure Apache to use hostname
- install php
- restart Apache
- setup web server document folder
- code sample info.php file to test the configuration and run to verify the current setup
- install mysql and setup securely r(i.e: run mysql_secure_installation)

How do I get PHP remote debugging working under Komodo?

Question:

How do I get PHP remote debugging working under Komodo?
Answer:

There are a couple of things you need to make sure of in order to get PHP remote debugging working:

1. xdebug must be configured correctly. The php.ini that your web server is using should contain statements like this:

; xdebug config for Linux and Mac OS X
zend_extension=/usr/share/php5/debug/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=foo.bar.com
xdebug.remote_port=9000
xdebug.idekey=kyla

Note in particular that remote_host needs to be the hostname or ip address of the machine Komodo is running on, and remote_port needs to be the same as the remote port Komodo is using. You can check this by creating a script like this:



...and looking at the xdebug section in the output page.

2. Komodo must be configured correctly. At

Preferences / Debugger / Proxy

...set the field 'Listen for debug connections on port' to 9000 as above. Close the preferences and make sure that

Debug / Listen for remote debugger

...has a checkmark beside it.

3. You need to explicitly initiate a debugger session by adding the XDEBUG_SESSION_START get variable to the url in your browser:

http://baz.bar.com/script.php?XDEBUG_SESSION_START=1

If everything is correct, Komodo should pop-up a dialog inidicating that a remote application has requested a debugging session. If you click on 'OK', Komodo will step in to the first line of code in that script.

If this is still not working, some things to check are:

- can you ping the machine Komodo is running on form your web server?
- is the machine Komodo is on running some sort of software firewall that might be blocking the debugger requests?