Technical Recipes

Tricks in installation of WordPress

There are instructions on how to install WordPress in 5 minutes. Often time, it applies to have it installed on the shared hosting site with minimum control except the content you need to publish.
 
This blog is mainly for the developers who will set up the WordPress environment on dedicated servers. There are detailed instruction on how to set up PHP on and Windows(?) and Linux(?) with Apache and MySQL.
 
Here are something you need to know on Windows or Linux platforms:
 
1 Missing MSVCP110.dll

   In order to install WordPress, you must have PHP installed on your system.
   In order to install PHP, you must have Visual C++ Redistributable on Windows.
   In order to make PHP working, you need to install the specific version of Visual C++ redistribution.
 
   The trick is: even if you have a x64 Windows OS, you have to install the x86 version of the Visual C++. Only the expert knows: "X86 is the one to go for since the Hive is compiled for x86 platform." This trick can make many people stuck for a while. Some people suggested to copy the msvcp110.dll from System32 to the current directory. Others may suggested you uninstall all the Visual C++ previous versions and reboot then re-install it in a right sequence. Don't follow all the possible solutions until you find the right answer.
 
2 Missing php5apache.dll
 
   If you install PHP with Apache, you must be careful about choosing the right .dll with different versions of Apache web server. On Windows, Apache comes with the thread-safe version, so you must download the thread safe package.
 
   The trick is: even if you download the latest thread-safe version VC11 of PHP package, it may not work either, because it only include php5apache2_4.dll which supports Apache 2.4. In order to support Apache 2.2, you must download the VC9 thread safe package which includes php5apache2_2.dll.
 
3 Cannot connect to the database
 
    If you carefully configure the database parameters in the wp-config.php file, this should not be a problem. However, things could be different on Linux. A lot of people encountered failure to connect to database even if the database server is up and running and can be accessed by MySQL client.
 
    In some hosting site, using IP address instead of "localhost" may resolve the problem. But if you have your dedicated server environment and have multiple static IP addresses associated with the host, IP address will not work either. The trick is: even if you have the loopback interface's localhost entry in the /etc/hosts file, WordPress does not resolve the 'localhost' to '127.0.0.1', so you must specify '127.0.0.1' in the 'DB_HOST' field instead of 'localhost'. If you have a custom port for your database, you need to add the port after the DB_HOST as '127.0.0.1:3000'.
 
4 Cannot compile PHP on Linux
 
    After you download the PHP source code and run './configure', it will complain about them missing file 'xml2-config' which stops you from compiling. The trick is the PHP distribution comes with libxml2, but not 'libxml2-devel'. so people suggested to download 'libxml2-devel' which helps to resolve the compilation issue.
 
5 Thread-safe version of PHP on Linux
 
    There is thread-safe version binary PHP distribution on Windows available for download. But after we compile PHP on Linux, it does not support thread-safe mode of Apache. So the trick is to start Apache in single mode using either the default HTTPD service or:
 
    # sudo httpd -f /home/blog/httpd/conf/httpd-blog.conf -k start/stop/restart
 
instead of the multi-threaded mode:
 
    # sudo httpd-worker -f /home/blog/httpd/conf/httpd-blog.conf -k start/stop/restart