How to install WordPress on OpenRex (Apache + PHP + MySQL + WordPress)

I am using the filesystem from here: Using a downloaded filesystem (supports apt-get command) >

Content

Install common tools and libraries

sudo apt-get update
sudo apt-get install python2.7-dev
sudo apt-get install libxml2-dev
sudo apt-get install apt-src \
scons \
mingw32-runtime \
p7zip-full \
gawk \
gzip \
perl \
autoconf \
m4 \
automake \
libtool \
libncurses5-dev \
gettext \
gperf \
dejagnu \
expect \
tcl \
autogen \
flex \
flip \
bison \
tofrodos \
texinfo \
g++ \
gcc-multilib \
libgmp3-dev \
libmpfr-dev \
debhelper \
texlive \
texlive-extra-utils

Install Apache

I tried "sudo apt-get install apache2", but it did not install the apache correctly (I could not run "sudo service apache2 restart"), so I rather recompiled and reinstalled it.

Download the source code:
cd
mkdir tmp
cd tmp
wget http://tux.rainside.sk/apache//httpd/httpd-2.2.31.tar.bz2
tar -xvf httpd-2.2.31.tar.bz2
cd httpd-2.2.31
Compile and install apache:
./configure --prefix=/usr/local/apache2
make
make install
Set "ServerName". Open "/usr/local/apache2/conf/httpd.conf"
nano /usr/local/apache2/conf/httpd.conf
Search for "ServerName" and put there this:
ServerName localhost:80

Start apache automatically after reboot

Create "/etc/init.d/apache2"
sudo nano /etc/init.d/apache2
Add this into the file:
#!/bin/sh
case "$1" in
start)
echo "Starting Apache ..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl start
;;
stop)
echo "Stopping Apache ..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl stop
;;
graceful)
echo "Restarting Apache gracefully..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl graceful
;;
restart)
echo "Restarting Apache ..."
# Change the location to your specific location
/usr/local/apache2/bin/apachectl restart
;;
*)
echo "Usage: '$0' {start|stop|restart|graceful}"
exit 64
;;
esac
exit 0
Edit permissions:
sudo chmod u+x /etc/init.d/apache2
Run this to enable the automatic start after reboot:
sudo update–rc.d apache2 defaults #possibly try without sudo
Start the server:
sudo service apache2 start
*Note: The other command you may need:
/usr/local/apache2/bin/apachectl start #original path
sudo service apache2 stop
sudo service apache2 start
sudo service apache2 restart

Try if your webserver works

Check what is the IP address of your OpenRex, run:
root@ubuntu-imx6:/usr/local/apache2/htdocs# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0d:15:00:dc:ed
          inet addr:192.168.0.39  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20d:15ff:fe00:dced/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11705 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10807 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:12306971 (12.3 MB)  TX bytes:1443867 (1.4 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:12 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:656 (656.0 B)  TX bytes:656 (656.0 B)

root@ubuntu-imx6:/usr/local/apache2/htdocs#
You can see, the IP address of my OpenRex is 192.168.0.39. Go to your PC or Linux host machine, open Internet browser and go to url: "http://192.168.0.39". You should see a page with:
It works!
Perfect, it works. All the apache files are located at: "/usr/local/apache2/", this means, the website pages are located inside "/usr/local/apache2/htdocs/". If you like, you can try to change the current page. Run "nano" to edit the "index.html" file:
nano /usr/local/apache2/htdocs/index.html
You can edit it like:
<html><body><h1>It works! Perfect!</h1></body></html>
Refresh the OpenRex website and you should see:
It works! Perfect!

Install MySQL

To install MySQL run:
sudo apt-get install mysql-server
During the installation set the admin password. I used "fedevel". Test if MySQL is running:
root@ubuntu-imx6:~/tmp/php-5.6.19# sudo netstat -tap | grep mysql
tcp        0      0 127.0.0.1:mysql         *:*                     LISTEN      21100/mysqld
root@ubuntu-imx6:~/tmp/php-5.6.19#
*Note: If the server is not running correctly, you can type the following command to start it:
sudo service mysql restart
*Note: In case you would like to change MySQL default config, the file is located here:
nano /etc/mysql/my.cnf

Install PHP

Download the source code:
cd ~/tmp
wget http://php.net/get/php-5.6.19.tar.bz2/from/this/mirror
mv mirror php-5.6.19.tar.bz2
tar -xvf php-5.6.19.tar.bz2
cd php-5.6.19
Configure, compile and run PHP test:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
make test
*Note: Some tests may fail. It looks like the tests what failed on my installation are CLI related. At this moment I may not need CLI, so I am not going to investigate what exactly the problem is, but I may do so later. After the test finishes, press "s" to save the report. The test report will be located at: /root/tmp/php-5.6.19/php_test_results_20160325_0856.txt

Install PHP:
make install
cp php.ini-development /usr/local/lib/php.ini
Just in case you need to change php config, the "php.ini" file is be located at: /usr/local/lib/php.ini

Update webserwer config

Open webserver config file:
nano /usr/local/apache2/conf/httpd.conf
Search for "php5_module" and be sure it is enabled. You should see something like:
LoadModule php5_module modules/libphp5.so
Search for "FilesMatch" and add following to enable "php" file handling:
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>
Search for DirectoryIndex and tell wordpress handle index.php automatically:
DirectoryIndex index.php index.phtml index.html index.htm
Restart the webserver:
sudo service apache2 restart

Test PHP

Create phpinfo.php file
nano /usr/local/apache2/htdocs/phpinfo.php
Put this inside:
<?php
   phpinfo();
?>
Go to your OpenRex website and use following link: "http://192.168.0.39/phpinfo.php" (don't foget to use your OpenRex IP address). You should see PHP info page.

Install WordPress

Before we start installing wordpress, we will create MySQL wordpress user:
mysql -u root -p
#enter the root password which you used during MySQL installation. I used 'fedevel'
Create database for our OpenRex wordpress:
create database wordpress;
Create user for our OpenRex wordpress. Name of our user will be "wordpress" and password is "fedevel" (choose your own name/password):
create user 'wordpress'@'localhost' identified by 'fedevel';
Grant wordpress user privileges to use wordpress database:
grant all on wordpress.* to 'wordpress'@'localhost' identified by 'fedevel';
quit;
Now download the wordpress files:
cd ~/tmp
wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
Make backup of your current web directory:
mkdir ~/tmp/webbackup
mv /usr/local/apache2/htdocs/* ~/tmp/webbackup/
Copy wordpress files to your webserver directory:
cp -prv ~/tmp/wordpress/* /usr/local/apache2/htdocs/

WordPress web installer

Go on OpenRex website (open Internet browser and write there OpenRex IP address). In my case it is: http://192.168.0.39/ and you should see something like: "Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding..."

Step 1: Setup MySQL
Database Name: wordpress
User Name: wordpress //use the user which you created in the steps above
Password: fedevel //use the password which you assigned to the user
Database Host: localhost
Table Prefix: wp_
Step 2: wp-config.php
In this step you will see a message like: "Sorry, but I can’t write the wp-config.php file. You can create the wp-config.php manually and paste the following text into it.". Create "/usr/local/apache2/htdocs/wp-config.php":
nano /usr/local/apache2/htdocs/wp-config.php
and copy there content from the box in your installation. It may look like this:
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpress');

/** MySQL database password */
define('DB_PASSWORD', 'fedevel');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'F5k,gn[K14j,|wi:+{13;.1C;shnAz}|7y9^kgbj(6NHXN08@y6`vRug3H~,))ct');
define('SECURE_AUTH_KEY',  '<uYD@tZ=Ux18SZS3+0f@20O,wSegsz|<j|U>b%K|80b^Sz7)u[@5{HmWUqt/oc!t');
define('LOGGED_IN_KEY',    '0$b3sov2BQPPO6$S,=4zROwyttUy&dG(PMVEStXP04U]{9IwOxHE+}8KzlSYVop[');
define('NONCE_KEY',        'H4|Z+Vqg-F+ogK60gGU2!N]CLa`|<1MVusE5g:lgI:^)`uUfG3ho#?KUqoh92RLx');
define('AUTH_SALT',        'OCMVZ6(P/R3QSko?Z3vU&0+Eq@irqzYLRXSdH_:C6rl2l37J[=>v.NOK+Q&G9=*O');
define('SECURE_AUTH_SALT', 'Z`n[NU4z5MBRpC=b-)bm2ai8Y$3T-~N[ZKIab8pDfBG@Bg-Y xo`QKrs6Q]Vb;eh');
define('LOGGED_IN_SALT',   'n?+!( 0m,TaT5,]K/ zjfE|_Le%UZL-(NY(%3}s+aSFR*BOmJ[N@ jBm~TyUJc#U');
define('NONCE_SALT',       ' L%.#p$V)^0eSO b(Hl nYxRY$owA@xchkji(hetfIUv-iUDT=v`m%Fmf;ve?zoX');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
	define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
Step 3: Run the install
Click on the button "Run the install"

Step 4: Setup basic page info
Site Title: RexFace //or what you like
Username: fedevel //or what you like
Password: fedevel //or what you like
Your Email: username@example.com //put here your email, your OpenRex wordpress will send you important info e.g. password reset
Search Engine Visibility: Check this, you may not want google to search through your OpenRex web (or if you want, you can uncheck it :)
Step 5: Press "Install WordPress"
Just press the button "Install WordPress"

Step 6: Login
Press "Login" button and login to your RexFace website running on your OpenRex

IMPORTANT! If IP address of your board may change, you need to edit your theme 'functions.php' and you may need to install Search & Replace plugin. In our case:
nano /usr/local/apache2/htdocs/wp-content/themes/twentysixteen/functions.php
Add following lines immediately after 'php?':
update_option( 'siteurl', 'http://'.$_SERVER['SERVER_ADDR']);
update_option( 'home', 'http://'.$_SERVER['SERVER_ADDR']);
It will look like this:
<?php
update_option( 'siteurl', 'http://'.$_SERVER['SERVER_ADDR']);
update_option( 'home', 'http://'.$_SERVER['SERVER_ADDR']);
/**
 * Twenty Sixteen functions and definitions
*Note: This is needed, as when you move the server to a different IP, all the internal website links would be still pointing to the old IP address. Even after the changing function.php some things may not work e.g. pictures. Temporary, but working solution, is to use Search & Replace wordpress plugin to update all the records in your database to the new IP.

TADA! :) You have a wordpress running on your OpenRex board. The website is available at: "http://192.168.0.39/" and the admin interface is at: "http://192.168.0.39/wp-admin/" (use the IP of your OpenRex board)