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 Nginx*
Install Nginx web server.
[INPUT]1 pkg install nginx
Enable the nginx service.
[INPUT]1 sysrc nginx_enable=”YES”
Run the nginx service.
[INPUT]1 service nginx start
Browse *http://serverIP* to check if the Nginx web server is running properly.
-Configure Server Block-
Next, configure the Nginx server block for the *musaamin.my.id* domain.
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 block server configuration files.
[INPUT]1 mkdir -p /usr/local/etc/nginx/vhosts
Create a server block configuration file.
[INPUT]1 nano /usr/local/etc/nginx/vhosts/musaamin.my.id.conf
Fill in the server block configuration file.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13 server { listen 80; server_name musaamin.my.id www.musaamin.my.id; root /var/www/musaamin.my.id; index index.html; location / { try_files $uri $uri/ =404; } access_log /var/log/nginx/musaamin.my.id_access.log; error_log /var/log/nginx/musaamin.my.id_error.log; }
Open the Nginx configuration file.
[INPUT]1 nano /usr/local/etc/nginx/nginx.conf
Add the configuration below before closing http.
[INPUT]1 2 3 4 http { … include /usr/local/etc/nginx/vhosts/*.conf; }
Check for configuration errors.
[INPUT]1 nginx -t
If there is no mistake.
[INPUT]1 2 nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Restart the nginx service.
[INPUT]1 service nginx restart
Browse *http://musaamin.my.id*.
*Install PHP*
Install PHP 7.4 and its extensions.
[INPUT]1 pkg install php74 php74-mysqli php74-mbstring php74-pecl-mcrypt php74-zlib php74-curl php74-opcache php74-xml php74-xmlrpc php74-gd php74-json php74-zip
Open the PHP-FPM configuration file.
[INPUT]1 nano /usr/local/etc/php-fpm.d/www.conf
Activate and adjust the following configurations.
[INPUT]1 2 3 4 listen = /var/run/php74.sock listen.owner = www listen.group = www listen.mode = 0660
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
Open the php.ini file.
[INPUT]1 nano /usr/local/etc/php.ini
Options activated and changed.
[INPUT]1 cgi.fix_pathinfo=
Enable and run the php-fpm service.
[INPUT]1 2 sysrc php_fpm_enable=”YES” service php-fpm start
Configure the server block to read PHP scripts.
[INPUT]1 nano /usr/local/etc/nginx/vhosts/musaamin.my.id.conf
Change the configuration to be like below.
[INPUT]1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 server { listen 80; server_name musaamin.my.id www.musaamin.my.id; root /var/www/musaamin.my.id; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_pass unix:/var/run/php74.sock; fastcgi_index index.php; fastcgi_param DOCUMENT_ROOT $realpath_root; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; } access_log /var/log/nginx/musaamin.my.id_access.log; error_log /var/log/nginx/musaamin.my.id_error.log; }
Nginx configuration test.
[INPUT]1 nginx -t
Restart the nginx service
[INPUT]1 service nginx 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*
Install Let’s Encrypt certbot for Nginx.
[INPUT]1 pkg install py37-certbot-nginx
Request SSL for the musaamin.my.id domain.
[INPUT]1 certbot –nginx -d musaamin.my.id -d www.musaamin.my.id
If successful, certbot changes the server block configuration file.
[INPUT]1 nano /usr/local/etc/nginx/vhosts/musaamin.my.id.conf
Isinya.
[INPUT]1 2 3 4 5 6 7 … listen 443 ssl; # managed by Certbot ssl_certificate /usr/local/etc/letsencrypt/live/musaamin.my.id/fullchain.pem; # managed by Certbot ssl_certificate_key /usr/local/etc/letsencrypt/live/musaamin.my.id/privkey.pem; # managed by Certbot include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot …
Browse *https://musaamin.my.id*.
*Install MariaDB*
Install MariaDB database.
[INPUT]1 pkg install mariadb105-server mariadb105-client
Enable 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 to 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.
Cek *https://musaamin.my.id* and login to the dashboard.
/Free credit $100 for new account at Vultr. Register now/
Good luck ð