WordPress install

Step 1.  Create a database for the wordpress to live in.

(a) create a username for accessing this new database.

         # systemctl start mysql.service
        # mysql -u root -p
        mysql [none] >  CREATE USER ‘fred’@’localhost’ IDENTIFIED BY ‘new password’;

(b)  Create a database, calling it say, “WORDPRESS1”

        mysql [none] > CREATE DATABASE WORDPRESS1;

(c)  give rights to the user ‘fred” for this new database.

        mysql> GRANT ALL PRIVILEGES ON WORDPRESS1.* TO  ‘fred’@‘localhost’
                 -> IDENTIFIED BY ‘new password’;  
        mysql> FLUSH PRIVILEGES;
                     Query OK, 0 rows affected (0.01 sec)
       mysql> EXIT

Step 2.  Down load the latest wordpress source

        # cd /usr/local/src
        # wget https://wordpress.org/latest.tar.gz
        # gzip -d latest.tar.gz
        # tar xvf latest.tar

Step 3.  Optionally configue wordpress

tip: best to leave this step 3 out and allow wordpress to copy over and create this file at first startup.

#  cd /usr/local/src/wordpress
#  cp  wp-sample-config.php  wp-config.php
# vi  wp-config.php

         define('DB_NAME', 'WORDPRESS1');
         /** MySQL database username */
        define('DB_USER', 'fred');
        /** MySQL database password */
       define('DB_PASSWORD', 'new password');
       /** MySQL hostname */
      define('DB_HOST', 'localhost');

Step 4.  Edit the apache2 config file to create a path to where it will find wordpress:

This link is how to first install the web server.  Now to configure it to work with wordpress.

      #  mkdir /usr/local/bin/wordpress1
      #  cp -R  /usr/local/src/wordpress/*  /usr/local/bin/wordpress1
      #  chown -R apache  /usr/local/bin/wordpress1
      #  chgrp  -R apache /usr/local/bin/wordpress1
      #  vi  /usr/local/apache2/conf/httpd.conf    ( and edit in the following )

                DocumentRoot “/usr/local/bin/wordpress1”
                <Directory “/usr/local/bin/wordpress1”>
                       Options Indexes FollowSymLinks
                       AllowOverride None
                       Require all granted

Step 5.  Install the latest php source code.

(a)   install apxs  etc  ( so this php module can be compiled as a shared module )

     # apt-get install apache2-dev    ( installs apxs as /usr/bin/apxs )
     # apt-get install libxml2-dev    ( ditto )
     # apt-get install bison

(b) install php from source

note: best do not use apt-get as this package handler will also load another version of apache2 which will probably then conflict ( in our thinking at least ) with the already installed source code version.

     # cd /usr/local/src
     # wget http://us2.php.net/get/php-7.1.3.tar.gz/from/this/mirror
     # mv mirror php-7.1.3.tar.gz
     # gzip -d php-7.1.3.tar.gz
     # tar xvf php-7.1.3.tar
     # cd php-7.1.3
     #  ./configure --prefix=/usr/local/bin/php 
                       --with-zlib       ( needed for wordpress to work )     
     # make  ( takes a few minutes … on my old machine )

     Now need to create a destination directory for the “make install”:
     # mkdir /etc/apache2/mods-available
     # make install   
     Note: ignore any errors complaining about a missing "a2enmod" 
               as it is not needed this way, ie installing all modules in one place.

(c ) Configure apache to load the php module.

Firstly, find where the php’s “make install” installed the php module: 

               # find / -name libphp*.so -print

Having found the php module, copy this module to the apache2 shared modules.

# cp  /usr/lib/apache2/modules/libphp7.so  /usr/local/apache2/modules

Lastly, add to the apache2’s configuration, these two lines following,  ( ie /usr/local/apache2/conf/httpd.conf )

LoadModule php7_module modules/libphp7.so

and add this towards the the end of this httpd.conf file, some place

AddType application/x-httpd-php .php

Step 6.  Add the extra modules and php libraries needed for wordpress.

(a)  install the extra php libraries.

    # apt-get install php5-cli
    # apt-get install php5-dev
    # apt-get install php5-fpm
    # apt-get install php5-cgi
    # apt-get install php5-mysql
    # apt-get install php5-xmlrpc
    # apt-get install php5-curl
    # apt-get install php5-pear
    # apt-get install php5-imap
    # apt-get install php5-mcrypt
    # apt-get install php5-pspell

(b)  Load the shared modules needed for wordpress ( in /usr/local/apache2/conf/httpd.conf )

     LoadModule authn_file_module modules/mod_authn_file.so
     LoadModule authn_core_module modules/mod_authn_core.so
     LoadModule authz_host_module modules/mod_authz_host.so
     LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
     LoadModule authz_core_module modules/mod_authz_core.so
     LoadModule access_compat_module modules/mod_access_compat.so
     LoadModule auth_basic_module modules/mod_auth_basic.so
     LoadModule reqtimeout_module modules/mod_reqtimeout.so
     LoadModule mime_module modules/mod_mime.so
     LoadModule log_config_module modules/mod_log_config.so
     LoadModule log_debug_module modules/mod_log_debug.so
     LoadModule env_module modules/mod_env.so
     LoadModule headers_module modules/mod_headers.so
     LoadModule setenvif_module modules/mod_setenvif.so
     LoadModule version_module modules/mod_version.so
     LoadModule unixd_module modules/mod_unixd.so
     LoadModule status_module modules/mod_status.so
     LoadModule autoindex_module modules/mod_autoindex.so
     LoadModule info_module modules/mod_info.so
     LoadModule dir_module modules/mod_dir.so
     LoadModule alias_module modules/mod_alias.so
     LoadModule negotiation_module modules/mod_negotiation.so
     LoadModule expires_module modules/mod_expires.so
     LoadModule rewrite_module modules/mod_rewrite.so
     LoadModule php7_module modules/libphp7.so

(c ) Restart apache.

     # systemctl  reload apache

Step 7.  Then run the wordpress install script in a browser.

     For example ( if your server is ):

We can install some web site statistics, explained here.

Extra Steps here, ….if needed.

Possible problems and solutions:

Problem 1. Missing apache modules

Warning: Cannot modify header information – headers already sent by (output started at /usr/local/wordpress1/wp-admin/install.php:40) in /usr/local/wordpress1/wp-load.php on line 64

Solved by rechecking the module list above with what modules apache has: apachectl -M.

Problem 2. File permissions.

Check  “/usr/local/bin/wordpress1” ( ie the directory where wordpress is installed ) and make sure it is read/writable by apache, and all its sub directories.

Problem 3. Install fails, but works on a re-try. 

Happens sometimes on a new install when the wordpress config file had not been copied over by the install process on the first try.

Problem 4. Nothing changes.

Browser sometimes needs to be restarted with an empty cache.

Problem 5.  Nothing works.

If the config file is correct, perhaps there are missing some php libraries or apache modules.


      or even just


Problem 6.  Initial set up fails.

The local host name may be different to “localhost” or “”.  Perhaps or something else from the /etc/hosts file.

Problem 7.  Fatal errors.  

for example: 
Fatal error: Uncaught Error: Call to undefined function gzinflate() in /usr/local/src/wordpress/wp-includes/class-requests.php:947
Stack trace: #0 /usr/local/src/wordpress/wp-includes/class-requests.php(886): Requests::compatible_gzinflate('\x95\x8F\xC1\n\xC20\x10D\xFF%gIl\x15Q...')
#1 /usr/local/src/wordpress/wp-includes/class-requests.php(835): Requests::compatible_gzinflate('\x1F\x8B\x08\x00\x00\x00\x00\x00\x00\x03\x95\x8F\xC1\n\xC2...')
#2 /usr/local/src/wordpress/wp-includes/class-requests.php(675): Requests::decompress('\x1F\x8B\x08\x00\x00\x00\x00\x00\x00\x03\x95\x8F\xC1\n\xC2...')
#3 /usr/local/src/wordpress/wp-includes/class-requests.php(383): Requests::parse_response(Array, 'http://api.word...', Array, Array, Array)
#4 /usr/local/src/wordpress/wp-includes/class-http.php(366): Requests::request('http://api.word...', Array, Array, 'POST', Array)
#5 /usr/local/src/wordpress/wp-includes/class-http.php(575): WP_Http->request('http://api.word...', Array)
#6 /usr/local/src/wordpress/wp-includes/http.php(187): WP_Http-> in /usr/local/src/wordpress/wp-includes/class-requests.php on line 947

This “fatal error” was a missing zlib library ( see above php install ).

Problem 8.  Login page or dashboard not showing.

A simple solution is to change apache’s default web page to index.php and also for the wp-admin sub directory ( ie edit the apache config file ).

      <Directory “/usr/local/bin/wordpress1”>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
            DirectoryIndex  index.php

     <Directory “/usr/local/bin/wordpress1/wp-admin”>
           DirectoryIndex  index.php

Problem 9.  unknown mysql users.

The debian install process or others, may install extra users and passwords into the mysql database.  As I do not know these passwords in our database, I have no control over what that user account may be used for.  So in the interests of implementing best security, I delete them …. and wordpress still works, albeit the wordpress upgrades must now be done manually, but better still, when and how I choose.

     # mysql -u root -p
     MariaDB [none]> use User;
     MariaDB [mysql]> select Host, User from user;
     MariaDB [mysql]> drop user ‘debian-sys-maint’@’localhost’;
     MariaDB [mysql]> select Host, User from user;
     MariaDB [mysql]> exit

Problem 10.  Wordpess does not work at top dir levels, such as “/usr/local”.

This is a file permission problem.  The practical solution ( maintaing /usr/local secure settings ) is to install wordpress at a lover directory level, like /usr/local/bin/wordpress or even just /usr/local/src/wordpress.

Problem 11.  Insufficient memory and thrashing.

WordPress needs a separate process for each user occurring at the same time, so on a busy site, need to have many apache processors running at the same time ( ie, can not multi thread ).

To know how much memory each apache process is running,  try this “ps” command.

# ps -ylC httpd | \
     awk '$8!="RSS" {x += $8;y += 1; print y, "\t", $8 } \
     END {print "Total httpd ram inuse (MB): "x/1024; \
     print "Average processor Size (MB): "x/(y*1024);}'

The number of processors can then be limited in the apache config file: MaxSpareServers, MaxRequestWorks.  Apache is good with memory management though, and ListenBacklogs for example, will create a nice long waiting queue for requests before starting a new memory expensive process ( with a default of 511 ). 

Of course, one can always upgrade the amount of memory on the system, especially easy with one-click on a service such as linode.com.  Nice to know that is always an option for sudden usage spikes.

Problem 12.  WordPress cron jobs running nearly all the time.

Looking through the log files will show many wordpress cron jobs running all through the day, every time someone visits the site. To keep the machine from being too busy with these wordpress crons checking for updates,they can be disabled ( with no real damage ) by adding code to the wp-config.php file.  While there, may as well also get rid of checking for all updates.

define('DISABLE_WP_CRON', 'true' );

Unfortunately, this did not work for very long, as code keeps changing I suppose.  So in the end, using plugins to stop cron jobs checking ( that stay uptodate with workpress changes to the config file ), they work.

Problem 13.  New WordPress site not showing in google.

Assuming the browser’s cache has been cleared, this is probably because the previous owner of this newly acquired ip address was banned by the search engine for unknown but justifiable reasons.  Even large search and fast search engines have a cache.  Checking your site in another search engine, such as bing.com, can confirm this.  The solution, unfortunately, is to wait a month or two and the problem will go away.  This type of solution is unusual as it generally does not work very well for other computer type problems.


© 2017, James Harry Burton. All rights reserved.