In working with WordPress, I have run across a few problems where the manual appeared to be assuming the administrator to have information that is not obvious from the documentation. I give you this so that you can learn from my past mistakes without having to repeat them.
There are a few different configuration files that the user should be aware of. Since the software packages may be downloaded from different sources, the configuration files are not always consistent.
- httpd.conf (/etc/apache2/httpd.conf on my system) This is the configuration file for the Apache web server. Since WordPress requires PHP, the line reading LoadModule php5_module must be uncommented. (Remove the hash sign at the start of the line.) If the line is commented, the PHP files are sent to the browser instead of being processed by the PHP module.
- php.ini (/etc/php.ini) This is the configuration for the PHP module for the Apache web server. When working with UNIX/Linux systems, the parameters pdf_mysql.default_socket, mysql.default_socket, and mysqli.default_socket must match the value in the my.cnf file. On at least some versions, this appears to be /var/mysql/mysql.sock. On my system, I edited these values to read /tmp/mysql.sock. Uncomment the lines in the configuration file that you wish to use. (Remove the hash mark at the start of the line.) If the values don’t match, this will result in errors declaring that a database connection can’t be made.
- my.cnf (/etc/my.cnf on my system) This is the configuration file for the MySQL database software. You can use this file to specify the UNIX/Linux file to be used for socket communications. On my system, the default is SOCKET=/tmp/mysql.sock, but it seems some releases may have different values. The important thing to remember is that in UNIX systems, this value must agree with the socket file in the PHP configuration file. Uncomment the lines in the configuration file that you wish to use. (Remove the hash mark at the start of the line.) If the values don’t match, this will result in errors declaring that a database connection can’t be made.
Some of the plugins, such as BuddyPress, require you to allow mod_rewrite. (See http://askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache and https://buddypress.org/support/topic/cannot-sign-up/). This requires two changes to httpd.conf.
- Uncomment the line that reads #LoadModule rewrite_module libexec/apache2/mod_rewrite.so.
- Look for the section that reads <Directory /xxx> where /xxx is the directory containing the files for your web server. If there is a statement here that reads AllowOverride None, change it to AllowOverride FileInfo. If there are already other attributes there, add FileInfo to the list.
Since WordPress makes changes to the files in the Documents directory of your web server, you must ensure that PHP uses the account that owns the files. For UNIX/LINUX systems, the account information is given by the parameters User and Group in httpd.conf. The UNIX command chown can be used to change the ownership of all of the files for the WordPress site recursively. (My system uses _www as the account name.)
The Wrong Way
I have seen the following on some forums, but they seem to show a lack of understanding of the underlying situation.
- Some people have gotten around the problem with the socket file name by using 127.0.0.1 in the URL rather than localhost. This causes the system to use TCP/IP instead of UNIX sockets for communication with the database. Although this works, there are some advantages to using sockets.
- Some people have handled the file ownership problem by setting the file permissions on the files to read, write, and execute globally. This is a big security problem.
The section entitled mod_rewrite was added 18-February-2017.