Category: WordPress

WordPress

WordPress

Download phpMyAdmin Code

Download the current version of WordPress code with:

user@freebsdsrv:~ $ fetch  https://wordpress.org/latest.tar.gz [enter]
latest.tar.gz                                           25 MB    9 MBps    03s
user@freebsdsrv:~ $

Extract the WordPress code

user@freebsdsrv:~ $ sudo tar zxvf latest.tar.gz  -C /usr/local/www/ [enter]
x wordpress/
x wordpress/xmlrpc.php
x wordpress/wp-blog-header.php
x wordpress/readme.html
...
x wordpress/wp-admin/options-reading.php
x wordpress/wp-trackback.php
x wordpress/wp-comments-post.php
user@freebsdsrv:~ $
user@freebsdsrv:~ $ ls -l /usr/local/www/wordpress [enter]
total 204
-rw-r--r--   1 nobody nogroup   405 Feb  6  2020 index.php
-rw-r--r--   1 nobody nogroup 19915 Jan  1  2024 license.txt
-rw-r--r--   1 nobody nogroup  7409 Jun 18  2024 readme.html
-rw-r--r--   1 nobody nogroup  7387 Feb 13  2024 wp-activate.php
drwxr-xr-x   9 nobody nogroup   102 Nov 21 15:07 wp-admin/
-rw-r--r--   1 nobody nogroup   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--   1 nobody nogroup  2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--   1 nobody nogroup  3336 Oct 15 17:24 wp-config-sample.php
drwxr-xr-x   4 nobody nogroup     5 Nov 21 15:07 wp-content/
-rw-r--r--   1 nobody nogroup  5617 Aug  2  2024 wp-cron.php
drwxr-xr-x  30 nobody nogroup   270 Nov 21 15:07 wp-includes/
-rw-r--r--   1 nobody nogroup  2502 Nov 26  2022 wp-links-opml.php
-rw-r--r--   1 nobody nogroup  3937 Mar 11  2024 wp-load.php
-rw-r--r--   1 nobody nogroup 51367 Sep 30 21:12 wp-login.php
-rw-r--r--   1 nobody nogroup  8543 Sep 19 00:37 wp-mail.php
-rw-r--r--   1 nobody nogroup 29032 Sep 30 19:08 wp-settings.php
-rw-r--r--   1 nobody nogroup 34385 Jun 19  2023 wp-signup.php
-rw-r--r--   1 nobody nogroup  5102 Oct 18 17:56 wp-trackback.php
-rw-r--r--   1 nobody nogroup  3246 Mar  2  2024 xmlrpc.php
user@freebsdsrv:~ $

Set file owner and group to www:www with:

user@freebsdsrv:~ $ sudo chown -R www:www /usr/local/www/wordpress ; ls -l /usr/local/www/wordpress [enter]
total 204
-rw-r--r--   1 www www   405 Feb  6  2020 index.php
-rw-r--r--   1 www www 19915 Jan  1  2024 license.txt
-rw-r--r--   1 www www  7409 Jun 18  2024 readme.html
-rw-r--r--   1 www www  7387 Feb 13  2024 wp-activate.php
drwxr-xr-x   9 www www   102 Nov 21 15:07 wp-admin/
-rw-r--r--   1 www www   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--   1 www www  2323 Jun 14  2023 wp-comments-post.php
-rw-r--r--   1 www www  3336 Oct 15 17:24 wp-config-sample.php
drwxr-xr-x   4 www www     5 Nov 21 15:07 wp-content/
-rw-r--r--   1 www www  5617 Aug  2  2024 wp-cron.php
drwxr-xr-x  30 www www   270 Nov 21 15:07 wp-includes/
-rw-r--r--   1 www www  2502 Nov 26  2022 wp-links-opml.php
-rw-r--r--   1 www www  3937 Mar 11  2024 wp-load.php
-rw-r--r--   1 www www 51367 Sep 30 21:12 wp-login.php
-rw-r--r--   1 www www  8543 Sep 19 00:37 wp-mail.php
-rw-r--r--   1 www www 29032 Sep 30 19:08 wp-settings.php
-rw-r--r--   1 www www 34385 Jun 19  2023 wp-signup.php
-rw-r--r--   1 www www  5102 Oct 18 17:56 wp-trackback.php
-rw-r--r--   1 www www  3246 Mar  2  2024 xmlrpc.php
user@freebsdsrv:~ $

Create an Apache Include file to make wordpress available on the website with:

user@freebsdsrv:~ $ sudo ee /usr/local/etc/apache24/Includes/wordpress.conf [enter]

Add the following text;

Alias /wp/ "/usr/local/www/wordpress/"
<Directory "/usr/local/www/wordpress/">
    DirectoryIndex index.php
    Options None
    AllowOverride Limit
    # range of access allowed
    Require ip 127.0.0.1 192.168.1.0/24
</Directory>

N.B.: Access is only allowed from computers connected to the network 192.168.1.0/24, the same network as this FreeBSD server!

Restart Apache

Restart Apache for the changes to take effect:

user@freebsdsrv:~ $ sudo service apache24 restart [enter]
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 9059.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.
user@freebsdsrv:~ $

Create the WordPress MariaDB Database

Log in to the MariaDB console with:

user@freebsdsrv:~ $ sudo mysql -u root -p [enter]
Enter password: <-- DBpassWD [enter]
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 11.4.4-MariaDB FreeBSD Ports

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]>

Create a WordPress database with:

root@localhost [(none)]> create database wordpress; [enter]
Query OK, 1 row affected (0.000 sec)

root@localhost [(none)]>

Create a database user and password to manage the wordpress database with:

root@localhost [(none)]> grant all privileges on wordpress.* to 'wpdbadmin'@'localhost' identified by 'WPdbpassWd'; [enter]
Query OK, 0 rows affected (0.859 sec)

root@localhost [(none)]>

Flush privileges with:

root@localhost [(none)]> flush privileges; [enter]
Query OK, 0 rows affected (0.000 sec)

root@localhost [(none)]>

Exit the MariaDB console with:

root@localhost [(none)]> exit [enter]
Bye
user@freebsdsrv:~ $

Create file wp-config.php with:

user@freebsdsrv:~ $ sudo cp /usr/local/www/wordpress/wp-config-sample.php /usr/local/www/wordpress/wp-config.php [enter]
user@freebsdsrv:~ $

Generate unique phrases using the WordPress.org secret-key service at:
https://api.wordpress.org/secret-key/1.1/salt/

Edit file wp-config.php with:

user@freebsdsrv:~ $ sudo ee /usr/local/www/wordpress/wp-config.php [enter]

…and update settings as in this example:

<?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 website, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * Database settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
 *
 * @package WordPress
 */

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

/** Database username */
define( 'DB_USER', 'wpdbadmin' );

/** Database password */
define( 'DB_PASSWORD', 'WPdbpassWd' );

/** Database hostname */
define( 'DB_HOST', 'localhost:/var/run/mysql/mysql.sock' );

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

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

/** Download and install online files or updates without running FTP server. */
define('FS_METHOD', 'direct');

/**#@+
 * 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',         'O?wuw>h$O:[%S6Lo0M}FYMvH,)1i=Y,SK+cvD#-6g6%cb|0WGZqUvp59ar,XV4hU');
define('SECURE_AUTH_KEY',  ':0h a;/LJc--PaG-PnwT(!eoWV;-A#n%}$ UiDNKsj,@QqV=,}rQ&&A}rQ99_Qbu');
define('LOGGED_IN_KEY',    '-!Zx)z6;=if;ui }BPy-91=r5xgDJn+V8:B>`{+n$RM,dVEAk; YrAJk%GS=|;JF');
define('NONCE_KEY',        '77zgrS_oip)dcQM!;]JH*!S=7GzS^T+fH<mF548.q4^|ASDPIw|hwVcaVv{Hl^&%');
define('AUTH_SALT',        'UBt<2jMOL3e/^gzi=LX+$kzsC5||b],@;srO8Z0q612^rcyuK!Eft9)`g=@dSn G');
define('SECURE_AUTH_SALT', ':<<8<S@MVR!.}2?(o=,t@,@5}Uu+c(Xi0A`Cn[dxTMJgvLjeXTnrx`d5A)-xF1+V'); define('LOGGED_IN_SALT', '@E{7>+%(Bw#?3+q|vN)Z?mr?evIEo3I>+S<<AEBFSKCK:bWYk0My]OKVD-pp2i#g');
define('NONCE_SALT',       'y+OD9?eFIE$T/.:;%FZA.|C%T6ikt,H5K.I-!2cAn<^+p>.+3eDc7v,c+1LdlUyH');

/**#@-*/

/**
 * 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!
 *
 * At the installation time, database tables are created with the specified prefix.
 * Changing this value after WordPress is installed will make your site think
 * it has not been installed.
 *
 * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
 */
$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 documentation.
 *
 * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */

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

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

Run the WordPress Famous 5-minute install

In your browser go to https://192.168.1.50/wordpress/readme.html.

Click the link wp-admin/install.php and follow the instruction on the screen.

WordPress with PHP v. 7.0

WordPress with PHP v. 7.0

Description

WordPress is a state-of-the-art semantic personal publishing platform with a focus on aesthetics, web standards, and usability.

More simply, WordPress is what you use when you want to work with your blogging software, not fight it.

WWW: http://wordpress.org/.

Requirements

The following applications must be installed, configured and running before installation of WordPress:

  1. Apache HTTP Server
  2. PHP (v. 7.0)
  3. MySQL DB Server
  4. GNUwget

Preparation for Installation

Start PuTTY on a Windows PC, Terminal on a Mac or similar terminal application on a Linux PC.

In this example Terminal on a Mac is used.

Open a remote SSH session to the server with:

Mac:~ user$ ssh user@192.168.1.4 [enter]
N.B.: Replace user@192.168.1.4 with User ID and IP Address on Your server!
[user@server ~]$

Enable superuser privileges with:

[user@server ~]$ sudo -s [enter]
Password: <-- passwd [enter]
[root@server /usr/home/user]#

N.B.: Enter user password, not the root password!

Warning!

N.B.: Do NOT install WordPress from port if the PHP version installed is > 5.6!

Verify version of PHP installed with:

[root@server /usr/home/user]# php -v <enter>
PHP 7.0.15 (cli) (built: Jan 24 2017 01:18:59) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15, Copyright (c) 1999-2017, by Zend Technologies
[root@server /usr/home/user]#

In this example PHP version 7.0 is installed. Due to this WordPress will be downloaded from the WordPress site.

Download

Download the latest version of WordPress with:

[root@server /usr/home/user]# wget https://wordpress.org/latest.tar.gz <enter>
--2017-02-22 18:26:38--  https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 66.155.40.249, 66.155.40.250
Connecting to wordpress.org (wordpress.org)|66.155.40.249|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7997959 (7,6M) [application/octet-stream]
Saving to: ‘latest.tar.gz’

latest.tar.gz       100%[===================>]   7,63M  1,74MB/s    in 6,0s    

2017-02-22 18:26:45 (1,27 MB/s) - ‘latest.tar.gz’ saved [7997959/7997959]

[root@server /usr/home/user]#

Installation

Extract file latest.tar.gz to /usr/local/www/ with:

[root@server /usr/home/user]# tar -xzvf latest.tar.gz  -C /usr/local/www <enter>
x wordpress/
x wordpress/wp-settings.php
x wordpress/wp-cron.php
x wordpress/wp-comments-post.php
x wordpress/wp-activate.php
x wordpress/wp-admin/
.
.
x wordpress/wp-includes/comment.php
x wordpress/wp-includes/class-wp-text-diff-renderer-table.php
x wordpress/wp-config-sample.php
[root@server /usr/home/user]#

Delete file latest.tar.gz with:

[root@server /usr/home/user]# rm latest.tar.gz <enter>
[root@server /usr/home/user]#

N.B.: Only not installed required PHP shared extension will be installed with the following command!

Install shared PHP extension required by phpMyAdmin with:

[root@server /usr/home/user]# pkg install curl php70-curl libnghttp2 php70-gd php70-hash php70-xml php70-tokenizer php70-mysqli php70-zip php70-ftp php70-zlib <enter>
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 4 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	curl: 7.52.1_1
	php70-curl: 7.0.15
	libnghttp2: 1.18.0
	php70-ftp: 7.0.15

Number of packages to be installed: 4

The process will require 4 MiB more space.
1 MiB to be downloaded.

Proceed with this action? [y/N]: y <enter>
Fetching curl-7.52.1_1.txz: 100%    1 MiB   1.1MB/s    00:01    
Fetching php70-curl-7.0.15.txz: 100%   26 KiB  26.8kB/s    00:01    
Fetching libnghttp2-1.18.0.txz: 100%  104 KiB 106.4kB/s    00:01    
Fetching php70-ftp-7.0.15.txz: 100%   22 KiB  22.4kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/4] Installing libnghttp2-1.18.0...
[1/4] Extracting libnghttp2-1.18.0: 100%
[2/4] Installing curl-7.52.1_1...
[2/4] Extracting curl-7.52.1_1: 100%
[3/4] Installing php70-curl-7.0.15...
[3/4] Extracting php70-curl-7.0.15: 100%
[4/4] Installing php70-ftp-7.0.15...
[4/4] Extracting php70-ftp-7.0.15: 100%
Message from php70-curl-7.0.15:
****************************************************************************

The following line has been added to your /usr/local/etc/php/ext-20-curl.ini
configuration file to automatically load the installed extension:

extension=curl.so

****************************************************************************
Message from php70-ftp-7.0.15:
****************************************************************************

The following line has been added to your /usr/local/etc/php/ext-20-ftp.ini
configuration file to automatically load the installed extension:

extension=ftp.so

****************************************************************************
[root@server /usr/home/user]#

Configuration

Change file owner and group recursively for /usr/local/www/wordpress with:

[root@server /usr/home/user]# chown -R www:www /usr/local/www/wordpress <enter>
[root@server /usr/home/user]#

Change file modes recursively for /usr/local/www/wordpress with:

[root@server /usr/home/user]# chmod -R 755 /usr/local/www/wordpress <enter>
[root@server /usr/home/user]#

Enable the Apache rewrite_module with:

[root@server /usr/home/user]# perl -pi -e 's/#LoadModule rewrite_module/LoadModule rewrite_module/g' /usr/local/etc/apache24/httpd.conf <enter>
[root@server /usr/home/user]#

To make wordpress available on the web site:

[root@server /usr/home/user]# ee /usr/local/etc/apache24/Includes/wordpress.conf <enter>

Add the following lines;

Alias /wp/ "/usr/local/www/wordpress/"
<Directory "/usr/local/www/wordpress/">
  AllowOverride All
  Require all granted
</Directory>

…the restart the apache24 service with:

[root@server /usr/home/user]# service apache24 restart <enter>
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 12555.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.
[root@server /usr/home/user]#

Prepare MySQL Database

WordPress uses a relational database, such as MySQL, to manage and store site and user information.

Login to the MySQL database with:

[root@server /usr/home/user]# mysql -u root -p <enter>
Enter password: <-- password <enter>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 422
Server version: 5.7.17-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost [(none)]>

Create a MySQL wordpress database with:

root@localhost [(none)]> CREATE DATABASE wordpress; &enter>
Query OK, 1 row affected (0,02 sec)

root@localhost [(none)]>

Create a MySQL user account wpadmin that WordPress will use to interact with the wordpress database with:

root@localhost [(none)]> CREATE USER wpadmin@localhost IDENTIFIED BY 'password'; &enter>
Query OK, 0 rows affected (0,44 sec)

root@localhost [(none)]>

 

Grant the WordPress wpadmin user full access to the wordpress database with:

 

root@localhost [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO wpadmin@localhost; &enter> Query OK, 0 rows affected (0,44 sec) root@localhost [(none)]>

Before this privileges change will go into effect, we must flush the privileges with:

root@localhost [(none)]> FLUSH PRIVILEGES; &enter>
Query OK, 0 rows affected (0,43 sec)

root@localhost [(none)]>

Exit the MySQL prompt with:

root@localhost [(none)]> exit &enter>
Bye
[root@server /usr/home/user]#

Make a copy of the WordPress sample configuration file with:

[root@server /usr/home/user]# cp /usr/local/www/wordpress/wp-config-sample.php /usr/local/www/wordpress/wp-config.php <enter>
[root@server /usr/home/user]#

Start editing file /usr/local/www/wordpress/wp-config.php with:

[root@server /usr/home/user]# ee /usr/local/www/wordpress/wp-config.php <enter>

…and update DB_NAME, DB_USER and DB_PASSWORD as in this example:

<?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', 'wpadmin');

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

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

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

/** 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',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

/**#@-*/

/**
 * 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');
?>

Authentication Unique Keys and Salts

You can generate the unique keys at: https://api.wordpress.org/secret-key/1.1/salt/

Run WordPress Installation Script

Start your browser and got to http://www.example.net/wp/ and complete the installation of WordPress.