Wordpress on Freebsd - Installation and Configuration For Blog

A blog is a type of regularly updated website that provides insight into a particular topic. The word blog is a combination of the words "web" and "log". The beginning of the blog was just an online diary, a place where people could keep daily notes about daily events. Gradually, blogs have developed into an important website for individuals and corporations to share information and knowledge. Not only that, many of us can also make money from blogs.

In this article, we will try to discuss how to create a blog on the FreeBSD server. To make it easier for readers to learn how to create a blog on FreeBSD, the discussion of this blog will be divided into several sessions. Each session will guide you from the preparation stage until the blog can be published. In this first session, we will try to discuss how to create WordPress on a FreeBSD server.

WordPress is a popular content management system (CMS) and blogging platform that allows you to quickly set up a website. Thanks to plugin and template support, this CMS is highly customizable and allows you to debug site functionality according to developer requirements. WordPress supports a wide variety of sites, from simple blogs to full-blown ecommerce sites.


List of contents:
  • System specifications
  • Apache and PHP installation
  • Test Apache and PHP
  • MySQL Server installation
  • WordPress Installation
  • WordPress Configuration


1. System Specifications

OS: FreeBSD 13.2 Stable
CPU: Intel(R) Core(TM)2 Duo CPU  E8400  @ 3.00GHz
IP Address: 192.168.5.2
Hostname dan Domain: ns1.unixexplore.com
Web Server: Apache24
PHP: php82: 8.2.7
WordPress: 6.2.2,1
MySQL: mysql80-server
WordPress Database Name: wordpress
User name WordPress Database: bromo
WordPress Database Passwords: mahameru


2. Apache and PHP installation

Apache and PHP will be used as web servers, so that WordPress can run on a Web browser. This application installation is the initial installation before building WordPress. Below is the script to install Apache and PHP.

root@ns1:~ # pkg install apache24
root@ns1:~ # pkg install php82 mod_php82 php82-mysqli
root@ns1:~ # pkg install php82-gd php82-phar php82-ctype php82-filter php82-iconv php82-curl php82-mysqli php82-pdo php82-tokenizer php82-mbstring php82-session php82-simplexml php82-xml php82-zlib php82-zip php82-dom php82-pdo_mysql php82-ctype
So that the PHP mod can run on Apache, edit the /usr/local/etc/apache24/httpd.conf file. Place the script below at the very end of the httpd.conf file.

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

LoadModule php_module         libexec/apache24/libphp.so

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps


Create a php.ini file by copying the php.ini-production file to php.ini. The file is located in the /usr/local/etc directory.

root@ns1:~ # cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Create an SSL certificate.

root@ns1:~ # cd /etc/ssl
root@ns1:/etc/ssl # wget http://curl.haxx.se/ca/cacert.pem
The next step is to edit the /usr/local/etc/php.ini file, and activate the script below in the php.ini file.

extension=mysqli.soopenssl.cafile=/etc/ssl/cacert.pemcgi.fix_pathinfo=0

Then add this script to the top of the script in the php.ini file, place it right after the word [PHP] or at the bottom of the word [PHP].

listen.owner = www
listen.group = www
listen.mode = 0660

To test the PHP module, you need the info.php file. Create a new file with the name info.php and place it in the /usr/local/www/apache24/data folder. In the info.php file, enter the script as below.

root@ns1:~ # touch /usr/local/www/apache24/data/info.php
root@ns1:~ # ee /usr/local/www/apache24/data/info.php
<?php phpinfo(); ?>
The next step is to create a server name and Server IP Address in the httpd.conf file. Open the /usr/local/etc/apache24/httpd.conf file and look for the "Listen" and "ServerName" scripts then replace them with the scripts below.

Listen 192.168.5.2:80
ServerName www.unixexplore.com:80

Just deactivate the default "Listen 80" script, by adding the "#" sign at the beginning of the #Listen 80 script. After all the above configurations have been done, activate the Apache web server application by typing the following script in the /etc/rc.conf file.

root@ns1:~ # ee /etc/rc.conf
apache24_enable="YES"
So that the Apache application runs immediately, restart the Apache application.

root@ns1:~ # service apache24 restart


3. Test Apache and PHP

The time has come for us to test the Apache and PHP applications. First, we test the Apache application. Open the Yandex browser, Chrome, Firefox or according to your taste. In the web browser, type the FreeBSD server IP, namely http://192.168.5.2. When the words "It works!" This means the Apache24 web server is running normally.

Continue with the PHP module test, still in the web browser type the FreeBSD server IP Address, namely http://192.168.5.2/info.php.


4. MySQL Server installation

Another application required by WordPress is MySQL Server. This application is used to log in to the Dashboard and save the WordPress data base. Enter the following script to install MySQL Server.

root@ns1:~ # pkg install mysql80-client
root@ns1:~ # pkg install mysql80-server
Wait until the installation process is complete, after that delete the files in the /var/db/mysql directory.

root@ns1:~ # rm -rf /var/db/mysql/
Provide the user and group name "mysql" in the /usr/local/etc/mysql folder.

root@ns1:~ # chown -R mysql:mysql /usr/local/etc/mysql
Activate MySQL Server at Start Up rc.d, by typing mysql_enable="YES" in the /etc/rc.conf file.

root@router2:~ # ee /etc/rc.conf
mysql_enable="YES"
Next, run the Mysql Server application.

root@ns1:~ # service mysql-server restart
After the computer returns to normal, create a MySQL Server root password.

root@ns1:~ # mysql_secure_installation
Note down and don't forget the MySQL Server password that you created, later this password will be used to enter the MySQL server. Now we test the password that was created earlier, if the password is not wrong, continue by creating a "Wordpress" database.

root@ns1:~ # mysql -u root -p
Enter password: masukkan password mysql yang anda buat diatas
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.32 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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)]> exit script exit untuk keluar dari mysql server
Bye
root@ns1:~ #


5. WordPress Installation and Configuration

The quickest and easiest way to install WordPress on a FreeBSD System is to install the pkg package from the FreeBSD repository. The script below is for installing WordPress.

root@ns1:~ # pkg install wordpress
Before we can run WordPress via a web server, WordPress needs to be configured so that it can connect to the previously created database. Go to the folder where WordPress is stored, namely /usr/local/www/wordpress, then copy the wp-config-sample.php file to wp-config.php.

root@ns1:~ # cd /usr/local/www/wordpress
root@ns1:/usr/local/www/wordpress # cp wp-config-sample.php wp-config.php
The script above will create a new file called wp-config.php, edit the file. What you have to pay attention to when editing this file is the script DB_NAME DB_USER DB_PASSWORD. To fill in the script, it is taken from the MySql Server database. Now we open and edit the file "/usr/local/www/wordpress/wp-config.php".

<?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:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/documentation/article/editing-wp-config-php/
*
* @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', 'bromo' );

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

/** Database hostname */
/**define( 'DB_HOST', 'localhost' );*/
define( 'ns1', '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 documentation.
*
* @link https://wordpress.org/documentation/article/debugging-in-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';



root@ns1:~ # mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 Source distribution

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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 database wordpress;
root@localhost [(none)]> CREATE USER bromo@localhost IDENTIFIED BY 'mahameru';
root@localhost [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO bromo@localhost;
root@localhost [(none)]> FLUSH PRIVILEGES;
oot@localhost [(none)]> exit
Bye
root@ns1:~ #
Because by default Apache24's DocumentRoot is in the /usr/local/www/apache24/data folder, move the /usr/local/www/wordpress folder to the /usr/local/www/apache24/data folder.

root@ns1:~ # cd /usr/local/www
root@ns1:/usr/local/www # cp -rf wordpress/* /usr/local/www/apache24/data/
After everything is configured correctly and nothing has been missed, now it's time to open the WordPress blog. If there are no errors or omissions in the configuration, WordPress should be able to be opened. In the Yandex or Chrome Web Browser, type http://192.168.5.2/index.php.






If it looks like the image above, your WordPress has been successfully opened. Please click the "Continue" button, then a menu will appear to enter your username and password, fill in the appropriate WordPress database username and password, namely user bromo password semeru.

When typing http://192.168.5.2/index.php in the Web Browser a PHP error occurs, reinstall the PHP application as in discussion 2. Usually in the Modzilla Firefx browser when you type http://192.168.5.2/index.php and enter , Firefox will redirect to https. It is recommended to use Yandex browser or Google Chrome.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post