I wanted to add to my local mirror site a site that had been built using Wordpress. These are the steps I took to get there.
My starting point was a running Apache web server setup as described here. As I write this it is running Tiny Core 8.2.1 and Apache 2.4.
This setup has persistent /home directories to hold the (potentially) large amount of fairly static data served by the web sites. The /opt directory is also persistent and I store configuration file is /opt/conf.
It uses Apache's Virtual Server setup to hold the multiple web sites and I use the hosts file on my Windows 10 machine (from which I test) to map the shorthand names (such as 'ptowers' and 'rose') to the IP address of the server.
In a similar manner to described here I added a new user to the system - let's call her rose. To keep in line with my development approach I also:
Next I created a directory for the website (/home/rose/public_html) and copied a simple "it works" web page to it for an initial test.
tc@mirror:~$ mkdir /home/rose/public_html tc@mirror:~$ cp /usr/local/apache2/htdocs/index.html /home/rose/public_html tc@mirror:~$
The next step is to create an entry in the Apache virtual hosts configuration file to make the web site active. I just copied over one of the existing entries with suitable adjustments.
<VirtualHost *:80> DocumentRoot "/home/rose/public_html" ServerName rb_rose ErrorLog "/var/log/rose-error_log" ScriptAlias "/cgi-bin/" "/home/rose/public_html/cgi-bin" <Directory /home/rose/public_html> Options -Indexes +FollowSymLinks DirectoryIndex index.php index.html Require all granted </Directory> </VirtualHost>
Note: Remember my web server is a private one. In a public facing web server there are additional security related directives you might like to add such as restricting the IP addresses that can connect to the wp-admin directory. (For example see here.)
Restart the server:
tc@mirror:~$ sudo apachectl -k restart tc@mirror:~$
Point a browser at the web site and check that it is there. In my case it should appear at http://rose/
Wordpress is written in php and stores all of its web site data in a database. So we need to add these from the the Tiny Core repository. What's currently there as I write this is MariaDB (a fork of MySQL) and php7-mod. The former is v10.0.17 (updated 2015/04/06) and the latter v7.1.12 (updated 2017/12/02).
Depending how you're connected to your system you can either use the App Browser, command line App Browser (tce-ab) or the tce-load command. In the example below I've used tce-load to install php7-mod.tcz.
tc@mirror:~$ tce-load -wi php7-mod.tcz php7-mod.tcz.dep OK libxml2.tcz.dep OK Downloading: php7-ext.tcz Connecting to repo.tinycorelinux.net (188.8.131.52:80) php7-ext.tcz 100% |**************************************| 2528k 0:00:00 ETA php7-ext.tcz: OK Downloading: liblzma.tcz Connecting to repo.tinycorelinux.net (184.108.40.206:80) liblzma.tcz 100% |**************************************| 73728 0:00:00 ETA liblzma.tcz: OK Downloading: libxml2.tcz Connecting to repo.tinycorelinux.net (220.127.116.11:80) libxml2.tcz 100% |**************************************| 664k 0:00:00 ETA libxml2.tcz: OK Downloading: php7-mod.tcz Connecting to repo.tinycorelinux.net (18.104.22.168:80) php7-mod.tcz 100% |**************************************| 1904k 0:00:00 ETA php7-mod.tcz: OK tc@mirror:~$
Repeat this to install mariadb.tcz and mariadb-client.tcz.
In sorting out various problems I had along the way I also found it useful to install the command line version of php (php7-cli.tcz). With it in place the command php -i provides a wealth of information about the installation and let me track down things like misnamed directories.
We get Wordpress from the Wordpress site as a zip file and then unzip it into the document root for rose.
tc@mirror:/tmp$ wget -O latest.zip https://wordpress.org/latest.zip Connecting to wordpress.org (22.214.171.124:443) latest.zip 100% |**************************************| 10162k 0:00:00 ETA tc@mirror:/tmp$ su rose Password: rose@mirror:/tmp$ cd /home/rose/public_html/ rose@mirror:~/public_html$ unzip /tmp/latest.zip rose@mirror:~/public_html$
This unzips into a directory called wordpress which adds an unnecessary directory to the path. I suggest you move things up one level:
rose@mirror:~/public_html$ mv wordpress/* . rose@mirror:~/public_html$ rmdir wordpress
I spent a little while getting this sorted out. Some of the issues I encountered may (or may not) have been sorted out in subsequent releases of the extension.
php uses a .ini file which needs to be in place. We start by copying the example provided to /opt/conf where we keeping all the conf/ini files.
tc@mirror:~$ cp /usr/local/etc/php7/php.ini-sample /opt/conf
In my case there was an error in the ini file. Around line 544 I had to change the path to the extension directory to read:
Next we need to make it appear in the right place so we add a line in bootlocal.sh to create a symbolic link to it:
ln -s /opt/conf/php.ini /usr/local/etc/php7/php.ini
Next we need to edit the main Apache conf file to add the necessary support for php. Also one other thing that Wordpress requires is mod_rewrite. So around line 195 we need to uncomment mod_rewrite and add mod_php7:
LoadModule rewrite_module modules/mod_rewrite.so LoadModule php7_module modules/mod_php7.so
Finally we need to add the handler for PHP scripts. This can either go in the main conf file or could be added to the entry for the web site in the virtual hosts file. I took the latter approach and added into the rose entry:
AddHandler php7-script .php
As mentioned earlier, Wordpress stores all of its data in a database and we have installed MariaDB for this. It just now needs configuring. As the database will be holding potentially large amounts of data we'll add it to our persistent storage. Although in this instance it is being used by a single web site it could actually be being used by several websites, so let's put the database in /opt/mysql rather than in a user's directory.
Create the directory:
tc@mirror:~$ mkdir /opt/mysql
Next we copy the data directory from the (read-only) extension to our persistent storage. (The -L in the cp command ensures we copy the symbolic link targets rather than the symbolic links themselves).
tc@mirror:~$ cp -Lr /usr/local/mysql/data /opt/mysql/
If we look at what we've copied over we find a number of (largish) log files. Left alone they occupy about 100MB. We'll delete them now and later configure the system so that the files are a lot smaller.
tc@mirror:~$ cd /opt/mysql/data tc@mirror:/opt/mysql/data$ ls -l total 110624 -rw-r----- 1 tc staff 16384 Dec 18 13:49 aria_log.00000001 -rw-r----- 1 tc staff 52 Dec 18 13:49 aria_log_control -rw-r----- 1 tc staff 50331648 Dec 18 13:49 ib_logfile0 -rw-r----- 1 tc staff 50331648 Dec 18 13:49 ib_logfile1 -rw-r----- 1 tc staff 12582912 Dec 18 13:49 ibdata1 drwx------ 2 tc staff 4096 Dec 18 13:49 mysql/ drwx------ 2 tc staff 4096 Dec 18 13:49 performance_schema/ drwxr-xr-x 2 tc staff 4096 Dec 18 13:49 test/ tc@mirror:/opt/mysql/data$ rm -rf /opt/mysql/data/ib* tc@mirror:/opt/mysql/data$
Copy the config file to /opt/conf where we're keeping our specific configuration files:
tc@mirror:~$ cp /usr/local/share/mariadb/my.cnf /opt/conf/
Edit the my.cnf file to reduce the log file size down to 5MB. (Uncomment line 72)
Finally add the following to bootlocal.sh to set up the correct paths, and then start the database daemon:
# Setup and start MariaDB (mysql) rm -rf /usr/local/mysql/data ln -s /opt/mysql/data /usr/local/mysql/data ln -sf /opt/conf/my.cnf /usr/local/share/mariadb/my.cnf sudo -u tc /usr/local/mysql/bin/mysqld_safe 2>&1 > /dev/null &
One final thing. Later I found, when trying to get Wordpress to work, I was getting a lot of "PHP Startup: Unable to load dynamic library...." messages in Apache's log file. This was because the mysql library had not been loaded. We have to explicitly get it loaded by adding an entry to the file /etc/ld.so.conf.
In keeping with my approach to configuration files I copied the file to /opt/conf and added the line: /usr/local/mysql/lib to it. I also added the three lines:
rm -f /etc/ld.so.conf ln -s /opt/conf/ld.so.conf /etc/ld.so.conf ldconfig
The last line is necessary as it looks like ldconfig has already been run by the time that bootlocal.sh is run so we have to run it again.
At this stage reboot and then use ps to confirm that everything that should be running is running. If you've been following this guide to the letter you should see:
Finally we're just about there. The final step is to create a mysql database and user. In the example below I've created a database called rose_db with a user rose with a password of rose_pwd
tc@mirror:~$ mysql -u root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 10.0.17-MariaDB Source distribution Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE rose_db; Query OK, 1 row affected (0.02 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON rose_db.* TO "rose"@"localhost" IDENTIFIED BY "rose_pwd"; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> exit Bye tc@mirror:~$
Hopefully all is as it should be.
Fire up your browser and point it at: http://rose/readme.html should bring up the readme file and show the browser is working.
Next point the browser at http://rose/wp-admin/install.php to get the example web site up.
NB: At this point you'll either have to give group write permissions to the public_html directory or manually create the wp-config.php file with the suggested contents.
Any comments? email me. Last update January 2018