How to install WordPress with Apache on FreeBSD

In this FreeBSD tutorial, we will learn how to install WordPress using an Apache web server with SSL from Let’s Encrypt for HTTPS.

*Install Apache*

Install Apache web server.

[INPUT]

1 pkg install apache24

Enable apache24 service.

[INPUT]

1 sysrc apache24_enable=”YES”

Run the apache24 service.

[INPUT]

1 service apache24 start

Browse *http://serverIP* to test if the Apache web server is running properly.

-Configure VirtualHost-

Next, configure the virtual host for the domain *musaamin.my.id*.

Create a folder for the document root.

[INPUT]

1 2 mkdir -p /var/www/musaamin.my.id echo “hello world” > /var/www/musaamin.my.id/index.html

Create a folder to store virtual host configuration files.

[INPUT]

1 mkdir /usr/local/etc/apache24/vhosts

Create a folder for Apache logs.

[INPUT]

1 mkdir /var/log/apache

Create a virtual host configuration file.

[INPUT]

1 nano /usr/local/etc/apache24/vhosts/musaamin.my.id.conf

Fill in the virtual hosts configuration file.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13     DocumentRoot /var/www/musaamin.my.id     ServerName musaamin.my.id     ServerAlias www.musaamin.my.id     ErrorLog /var/log/apache/musaamin.my.id_error.log     CustomLog  /var/log/apache/musaamin.my.id_access.log common              Order allow,deny         Allow from all         Require all granted         AllowOverride All     

Open the Apache configuration file.

[INPUT]

1 nano /usr/local/etc/apache24/httpd.conf

Enable the *ServerName* option and enter the server IP address.

[INPUT]

1 ServerName 207.148.123.152

Add include vhosts at the bottom of the line.

[INPUT]

1 Include etc/apache24/vhosts/*.conf

Check for configuration errors.

[INPUT]

1 apachectl -t

If there is no mistake.

[INPUT]

1 Syntax OK

Restart the Apache service.

[INPUT]

1 service apache24 restart

Browse *http://musaamin.my.id*.

*Install PHP*

Install PHP 7.4 and its extensions.

[INPUT]

1 pkg install php74 mod_php74 php74-mysqli php74-mbstring php74-pecl-mcrypt php74-zlib php74-curl php74-opcache php74-xml php74-xmlrpc php74-gd php74-json php74-zip

Create a configuration file to connect Apache with PHP.

[INPUT]

1 nano /usr/local/etc/apache24/Includes/php.conf

Fill in the php.conf file.

[INPUT]

1 2 3 4 5 6 7 8 9 DirectoryIndex index.php index.html SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source

Create a *php.ini* file

[INPUT]

1 2 cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini-production.default ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Restart the Apache service.

[INPUT]

1 service apache24 restart

Create the *info.php* file.

[INPUT]

1 echo “” > /var/www/musaamin.my.id/info.php

Browse *http://musaamin.my.id/info.php*

*Install SSL Let’s Encrypt*

Open the Apache configuration file.

[INPUT]

1 nano /usr/local/etc/apache24/httpd.conf

Enable SSL module and rewrite.

[INPUT]

1 2 LoadModule ssl_module libexec/apache24/mod_ssl.so LoadModule rewrite_module libexec/apache24/mod_rewrite.so

Restart the Apache service.

[INPUT]

1 service apache24 restart

Install certbot Let’s Encrypt.

[INPUT]

1 pkg install py37-certbot-apache

Request SSL for the musaamin.my.id domain.

[INPUT]

1 certbot –apache -d musaamin.my.id -d www.musaamin.my.id

If successful, certbot changes the virtual host configuration file musaamin.my.id.conf.

[INPUT]

1 nano /usr/local/etc/apache24/vhosts/musaamin.my.id.conf

The contents of the virtual hosts file.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17     DocumentRoot /var/www/musaamin.my.id     ServerName musaamin.my.id     ServerAlias www.musaamin.my.id     ErrorLog /var/log/apache/musaamin.my.id_error.log     CustomLog  /var/log/apache/musaamin.my.id_access.log common              Order allow,deny         Allow from all         Require all granted         AllowOverride All      RewriteEngine on RewriteCond %{SERVER_NAME} =musaamin.my.id [OR] RewriteCond %{SERVER_NAME} =www.musaamin.my.id RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Certbot also creates new file.

[INPUT]

1 nano /usr/local/etc/apache24/vhosts/musaamin.my.id-le-ssl.conf

The contents of the virtual hosts file.

[INPUT]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19     DocumentRoot /var/www/musaamin.my.id     ServerName musaamin.my.id     ServerAlias www.musaamin.my.id     ErrorLog /var/log/apache/musaamin.my.id_error.log     CustomLog  /var/log/apache/musaamin.my.id_access.log common              Order allow,deny         Allow from all         Require all granted         AllowOverride All        Include /usr/local/etc/letsencrypt/options-ssl-apache.conf SSLCertificateFile /usr/local/etc/letsencrypt/live/musaamin.my.id/fullchain.pem SSLCertificateKeyFile /usr/local/etc/letsencrypt/live/musaamin.my.id/privkey.pem

Browse *https://musaamin.my.id*.

*Install MariaDB*

Install MariaDB database.

[INPUT]

1 pkg install mariadb105-server mariadb105-client

Activate and run the MariaDB service.

[INPUT]

1 2 sysrc mysql_enable=”YES” service mysql-server start

Secure MariaDB installation.

[INPUT]

1 mysql_secure_installation

Answer the question.

[INPUT]

1 2 3 4 5 6 7 Enter current password for root (enter for none): ENTER Switch to unix_socket authentication [Y/n] y Change the root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y

Login MariaDB

[INPUT]

1 mysql

Create a database for WordPress.

[INPUT]

1 2 3 4 5 CREATE DATABASE musaamin; CREATE USER ‘musaamin’@localhost IDENTIFIED BY ‘rahasia’; GRANT ALL PRIVILEGES ON musaamin.* TO ‘musaamin’@’localhost’; FLUSH PRIVILEGES; exit

*Install WordPress*

Download the latest WordPress.

[INPUT]

1 wget https://wordpress.org/latest.tar.gz -O wordpress.tar.gz

Extract wordpress.tar.gz

[INPUT]

1 tar xzvf wordpress.tar.gz

Copy the contents of the wordpress folder to the document root.

[INPUT]

1 cp -Rfv wordpress/* /var/www/musaamin.my.id

Change ownership.

[INPUT]

1 chown -R www:www /var/www/musaamin.my.id

Delete the index.html and info.php files created earlier.

[INPUT]

1 2 rm -f /var/www/musaamin.my.id/info.php rm -f /var/www/musaamin.my.id/index.html

Browse *https://musaamin.my.id* to install WordPress.

· Continue · Let’s go! · Enter the database name, username, and password that was created in MariaDB. For *Database Host = 127.0.0.1*. Submit · Run the installation · Enter the site title, username, password and email. Install WordPress.

WordPress has finished installing.

Browse *https://musaamin.my.id* and login to the dashboard.

/Free credit $100 for new account at Vultr. Register now/

Good luck 🙂

Leave a Reply

Your email address will not be published.