Wordpress management

NIX web page setup

This are instructions to setup the generic NIX web page template.

Input files

The web page is contained in three files:

Apache setup

The apache configuration files (on linux) go under /etc/apache2/. There is a directory called site-available. Copy the configuration file into that directory.

You should know what your server will be called. This is called the site domain and can be arranged via your department or purchased from registrar such as GoDaddy or similar. This name will feature a lot in continuation and we will call it siteUrl. In the provided documents, the siteUrl is , in addition to generic nixWebTemplate also set to rembrandt1.fmf.uni-lj.si as that was the stagging siteUrl. siteUrl is composed of the server name, in our case serverName=rembrandt1 and a domain, fmf.uni-lj.si.

Back to apache setup. Copy nixWebTemplate_sites-enabled.conf to /etc/apache2/sites-available and rename it to your nixWebTemplate.conf:

cd /etc/apache2/sites-available
cp /path/to/nixWebTemplate_sites-enabled.conf .
mv nixWebTemplate_sites-enabled.conf nixWebTemplate.conf
sed 's/rembrandt1.fmf.uni-lj.si/siteUrl/' nixWebTemplate.conf
a2ensite nixWebTemplate
/etc/init.d/apache2 reload

Line with sed replaces replaces occurences of rembrandt1.fmf.uni-lj.si with siteUrl, then a2ensite enables the site (although nothing is there yet), which is followed by a reload of the apache web server.

Database setup

Most of the web page is stored in a MySQL database, WordPress prefers the Maria-DB, which the following lines comply with. The whole page is stored as a single database within MySQL, with the name of the database determined at insertion. I recommend using a new database, the name nixWebTemplate is a suggestion, but can be changed. This is the same name that will be used in wp-config.php later on.

Commands will be run in MySQL command language. Usually, running as root will give you root access to the database. Sometimes databases have an independent root credentials. Check with server maintainer to get the credentials.

The following commands create a database for the page and assign a fresh wordpress user:

$shell> mysql
#starts a MySQL server
[MySQL] SHOW DATABASES;
#outputs a list of databases, if nixWebTemplate is there, drop it or use an alternative name
[MySQL] DROP DATABASE nixWebTemplate;
[MySQL] CREATE DATABASE nixWebTemplate;
CREATE USER 'nixManager'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON nixWebTemplate.* TO 'nixManager'@'localhost';
[MySQL] quit;

Assuming nixWebTemplate as a target database name, if such database exists, you should either use an alternative name or delete it, as the line DROP shows. Then CREATE the database. It is a matter of insulation to create a dedicated user nixManager that Wordpress will use to access the database. This will prevent Wordpress to use anything but the created database, protecting other sites and other mysql databases. The password will be replicated in the wp-config.php file.

Once database is created, copy sql dump to database:

$shell> mysql nixWebTemplate < nixWebTemplate.sql

Since the database contains the whole page, some adaptaions are needed, all commands are run within mysql:

USE nixWebTemplate;
UPDATE wp_options SET option_value='http://siteUrl' WHERE option_name='siteurl';
UPDATE wp_options SET option_value='http://siteUrl' WHERE option_name='home';
#change password
UPDATE wp_users SET user_pass=MD5('secretPassword') WHERE ID='1';

siteUrl example is rembrandt1.fmf.uni-lj.si. The password change may be desired. This is the password that will allow web management of the page. User with ID=1 is called nixManager. See below for adding user syntax.

Directory setup

This is the last piece of the puzzle. The unzipped folder should go under /var/www/nixWebTemplate on linux:

su root@server
cd /var/www
unzip -x nixWebTemplate.zip

To get the site up, access to the database should be granted to Wordpress by modifying wp-config.php:

define( 'DB_NAME', 'nixWebTemplate' );
define( 'DB_USER', 'nixManager' );
define( 'DB_PASSWORD', 'password' );

The last password is the one used in CREATE USER SQL command.

Now fire up a browser, point it to https://siteUrl/wp-admin, punch nixManager as user and password set as secretPassword and you should be able to manage a NIX template site.

Notes

This are notes collected during composition of the instructions above. They are kept for reference. Tne nomenclature might be off, consider yourself warned.

MySQL

This is the protocol to set the NIX webpage on a local server. In continuation, the target domain name is rembrandt1.fmf.uni-lj.si, the database name rembrandt1 and the generic user nixManager. Alternative names can be used by dilligently replacing references to the above with desired names.

Dump database. In our case, the database is called rembrandt:

mysqldump rembrandt > mysql_rembrandt_20200619.sql

Create new database, ie. rembrandt1:

CREATE DATABASE rembrandt1;

If needed, databases are deleted via:

DROP DATABASE rembrandt1;

Copy content of rembrandt to rembrandt1:

mysql rembrandt1 < mysql_rembrandt_20200619.sql

Copy rembrandt directory structure to rembrandt1:

cd /var/www
rm -rf rembrandt1
cp -rp rembrandt rembrandt1

Copy a whole mysql WP database (if needed, not part of the standard run):

mysql>create database rembrandt1;
#shell>mysqldump rembrandt | mysql rembrandt1

Clean up the database: - remove all but a single user - set its nickname to generic name, like nixManager - make user 1 an administrator (both update and insert version provided for completness) - remove all users - add a generic nixManager - make sure site points to the local site - create a user that will access database in the name of wp

DELETE FROM wp_usermeta WHERE user_id>1;
UPDATE wp_usermeta SET meta_value="nixManager" WHERE meta_key="nickname";
INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, "1", "wp_capabilities", 'a:1:{s:13:"administrator";s:1:"1";}');
UPDATE wp_usermeta SET meta_value='a:1:{s:13:"administrator";s:1:"1";}' WHERE meta_key="wp_capabilities";
INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, '1', 'wp_user_level', '10');
UPDATE wp_usermeta SET meta_value='10' WHERE meta_key="wp_user_level";
delete from wp_users;
INSERT INTO wp_users (ID,user_login,user_pass,user_nicename,user_email,user_status,display_name) VALUES ('1','nixManager',MD5('password'),'nixManager','labkey@fmf.uni-lj.si',0,'nixManager');
UPDATE wp_options SET option_value='http://rembrandt1.fmf.uni-lj.si' WHERE option_name='siteurl';
UPDATE wp_options SET option_value='http://rembrandt1.fmf.uni-lj.si' WHERE option_name='home';
CREATE USER 'nixManager'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON rembrandt1.* TO 'nixManager'@'localhost';

Update /var/www/rembrandt1/wp-config.php, make sure the fields are set to:

define( 'DB_NAME', 'rembrandt1' );
define( 'DB_USER', 'nixManager' );
define( 'DB_PASSWORD', 'password' );

links

social