Solved WordPress on a jail giving me an error

Hello, i've trying to get wordpress to run on FreeBSD 12.2-RELEASE and I'm getting this error on my web browser:

2021-01-09_12.52.49PM.png


Here's what I've done:

mkdir -p /jail/webserver/

bsdinstall jail /jail/webserver
(Installed the base system plus lib32)

Edited my host rc.conf and added:
Code:
jail_enable="YES"
jail_list="webserver"

Created /etc/jail.conf with these lines:
Code:
$jail_path="/jail";
path="$jail_path/$name";
mount.devfs;
exec.clean;
ip4=inherit;
ip6=inherit;
exec.start="sh /etc/rc";
exec.stop="sh /etc/rc.shutdown";

webserver {}
I started the jail:
service jail start webserver

Ran jls and I got this:
Code:
JID  IP Address      Hostname                      Path
  1                                                                /jail/webserver

Installed apache24:
Code:
pkg -j webserver install apache24
sysrc -j webserver apache24_enable="YES"
jexec webserver service apache24 start

Then I tested it by entering my host IP address and confirmed that it was working, the page said that "It Works".

Installed mariadb:
Code:
pkg -j webserver install mariadb105-server
sysrc -j webserver mysql_enable="YES"
jexec webserver service mysql-server start
Checked if mysql was running:
jexec webserver service mysql-server status
Got this message: mysql is running as pid 1097.

Code:
jexec webserver mysql_secure_installation # Set up my root pass

jexec webserver mysql -u root -p
Created a db called mysitedb and a user 'idude' and granted all the privileges.
Code:
CREATE DATABASE mysitedb;
CREATE USER idude@localhost IDENTIFIED BY 'mypass';
GRANT ALL PRIVILEGES ON mysitedb.* TO 'idude'@'localhost';

Rechecked everything by running:
Code:
SHOW DATABASES;
SELECT user FROM mysql.user;

Everything was created

Installed PHP74:
Code:
pkg -j webserver install -y php74 php74-mysqli mod_php74
jexec webserver cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
sysrc -j webserver php_fpm_enable="YES"
jexec webserver service php-fpm start
jexec webserver service php-fpm status
# To check if it's running and got this:
# php_fpm is running as pid 965.

Configured apache to use php module:
jexec webserver ee /usr/local/etc/apache24/modules.d/001_mod-php.conf
With this content:
Code:
<IfModule dir_module>
  DirectoryIndex index.php index.html
  <FilesMatch "\.php$">
    SetHandler application/x-httpd-php
  </FilesMatch>
  <FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
  </FilesMatch>
</IfModule>
Created a test php file:
jexec webserver ee /usr/local/www/apache24/data/info.php
#Added this code:
Code:
<?php phpinfo(); ?>
Tested on my web browser by entering:
10.0.2.15/info.php
Once again it worked.

Downloaded wordpress:
Code:
jexec webserver cd /tmp
jexec webserver fetch http://wordpress.org/latest.tar.gz
jexec webserver tar xvf latest.tar.gz
jexec webserver mv wordpress mysite #Renamed wordpress to the name of mysite
jexec webserver mv -v mysite /usr/local/www/apache24/data/
jexec webserver chown -R www:www /usr/local/www/apache24/data/

What am I missing here
 
Last edited by a moderator:
Decided to install all the PHP74 modules which solved the problem but a new one came up but that's for another thread.
 
Why don't you install wordpress with pkg? Most, if not all, of the dependencies will be automatically installed.
 
I wasn't aware there was pkg for wordpress! Every tutorial I read about installing it they show it manually. I will look at it later on, perhaps I'll create a new jail for it. Right now I'm able to get to the page to enter the name of the db but fails to connect to database.
 
You have the same with the port system, by the way.

Database (and database php connector) is the very type of dependencies that pkg may not install to let you the choice about the database you prefer (if the software is able to work with several databases).

Code:
sudo pkg install -n wordpress
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 13 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        ImageMagick6-nox11: 6.9.11.6_2,1
        fftw3: 3.3.9
        gsfonts: 8.11_8
        liblqr-1: 0.4.2
        libraqm: 0.6.0
        libraw: 0.20.2
        libwmf-nox11: 0.2.12
        php74-curl: 7.4.13_2
        php74-exif: 7.4.13_2
        php74-fileinfo: 7.4.13_2
        php74-ftp: 7.4.13_2
        php74-pecl-imagick: 3.4.4_2
        wordpress: 5.5.3,1

Number of packages to be installed: 13
(I have already many php74 extensions including php74-mysqli).

Dependencies are listed here: www/wordpress
 
I just tried that was, I get the same problem and had the install the other extensions but I still can't connect to mysql. When I get to the page to enter the name of my database, username and password, I get an error.

2021-01-11_02.27.35AM.png
 
I've tried that before also but you shouldn't have to do that because if WordPress can’t find the wp-config.php file, it will take you to wp-admin/setup-config.php in your wordpress/wp-admin directory where you get to enter all that info.

I have a feeling it's the way I've configured /etc/jail.conf on the host. I can't use iocage on this machine because it's using UFS and iocage works only on ZFS. So I created a virtual machine running ZFS for testing iocage and I was able to create a jail running wordpress without any problems. I figured that iocage uses its own configuration files because I can't find any jail.conf files to look at the configuration.

I used this command to initially configure my jail:

iocage create --name "mysite" -r 12.2-RELEASE ip4_addr="vnet0|10.0.2.20/24" defaultrouter="10.0.2.2" boot="on" host_hostname="mysite" vnet="on"

following an iocage tutorial

I'm thinking that I'm declaring an interface vnet0 and assigning it to the IP of 10.0.2.20.
I'm also turning on vnet and specifying a default router. Tried to do that on my jail.conf, I haven't found a way of doing this configuration on my jail.conf file.
 
Last edited by a moderator:
Finally, I was able to get in. I went into mysql and got the port number which was 3306:

show variables where variable_name = 'port';

Then on Wordpress setup page entered for localhost:
127.0.0.1:3306

I wasn't able to get in as a regular user though, I signed in as root.
 
Just something that caught my eye and not related to any of the issues you're having.
Code:
sysrc -j webserver php_fpm_enable="YES" 
jexec webserver service php-fpm start 
jexec webserver service php-fpm status
You either use PHP-FPM or mod_php, not both. As the rest of your configuration seems to be based on mod_php you can stop the php-fpm service, you don't need it, you're not using it.
 
As for the issue, it's here:
Code:
CREATE USER idude@localhost IDENTIFIED BY 'mypass';
Your jail has no localhost, at least not the jail.conf you created in post #1. The key difference is that iocage creates a VNET jail whereas your configuration uses a "plain" jail. A VNET jail has it's own network stack, a plain jail does not.

You can get this working on a "plain" jail if you use the IP address of the jail instead of 'localhost' everywhere. In the database user configuration, including the grant, and in your wordpress configuration's database settings.
 
Just something that caught my eye and not related to any of the issues you're having.

You either use PHP-FPM or mod_php, not both. As the rest of your configuration seems to be based on mod_php you can stop the php-fpm service, you don't need it, you're not using it.
I will remove it later on, do you need to enable this extension in rc.conf also like php-fpm?
 
I will remove it later on, do you need to enable this extension in rc.conf also like php-fpm?
No, it's loaded from httpd.conf, the line is automatically added when you install www/mod_php74:
Code:
LoadModule php7_module        libexec/apache24/libphp7.so
 
Back
Top