Articles in the PHP Category
Apache, PHP »
I ran across this error today after noticing a file_get_contents was not working. This was on a page that had been working fine for about a year.
“php_network_getaddresses: getaddrinfo failed: Name or service not known”
This issue is typically caused by the Apache/PHP host unable to contact the DNS server.
The first thing to check is to see if you can ping the remote host using console.
- If no, then your primary name server on /etc/resolv.conf (Debian) is not working. Find a working DNS and restart Apache.
- If yes, then Apache is still connecting to the broken DNS server. You should try restarting Apache …
Fedora, Linux, nginx, PHP, wordpress »
Interested in installing nginx on a Fedora system? The configuration with nginx is more complicated than Apache since it requires the setup of the nginx server and a separate daemon for running PHP. I prefer creating the daemon from scratch rather than going with the fpm route in Fedora 14 since there isn’t official support for it. I’d certainly install the fpm package once its available in Fedora.
Why switch to nginx?
If you have a site with heavy CPU and memory load in Apache, then nginx is a great choice. I recently made the switch to nginx and have noticed a reduction in CPU and memory usage. Nginx loads static content very fast and efficiently.
Here’s a graph of my nginx server load test. Courtesy of LoadImpact‘s free load testing service.

The user load time on my server is minimally impacted with 50 clients viewing the site simultaneously.
PHP, wordpress »
Looking for some good plugins for your WordPress blog? Here’s a list of the top 5 essential WordPress plugins that I’ve found. These 5 plugins will help with reducing spam on your blog, improving security, adding mobile device support, blog statistics, and improving search engine visibility with your site.
1. Akismet. This is the first line of defense for spam on your blog. Its available in the base install of WordPress. All you need to do is to sign-up for the Akismet API key (free) and enter it into your WordPress configuration. It also helps the community when you tag a comment as spam.
2. Login lockdown. This prevents your blog from getting hit by sites trying to run dictionary or brute force attacks on your WordPress logins. You can configure the maximum login retries, retry time in minutes, and lockout length. Highly recommended.
PHP, wordpress »
Importing large RSS files in WordPress has its share of bugs and problems. A major cause is due to the latest configuration changes with PHP 5.2. Regular expressions are now capped at 100KB in PHP. WordPress uses the PHP function preg_match_all() to parse out the RSS entries.
If you import a post greater than 100KB, the import function to fail completely.
If you don’t have access to change the PHP server settings, simply edit the RSS file and remove the large RSS posts from the file.
If you have access to a server:
To import large RSS posts into WordPress, you will need to change the php.ini configuration on your …
PHP »
The best way to parse out the port number from a URL (e.g. http://example.com:8080) is to use regular expressions. The PHP function parse_url() will not return port numbers that are specified in the URL. However, I’ve found parse_url() to be useful for retrieving the host name from a long string.
