NS8 & WordPress

Hi all,

I am trying to install WordPress on NS8.

I installed MariaDB and NGINX.

I created a simple “Hello World” index.html.
All is working.
After this test, I removed index.html.

I login to MariaDB and created the DB and granted all priviledges to the user_DB and his password.
All looked ok.
In PhpMyAdmin, I can see the DB, the user, etc…

I donloaded WordPress zip file and extracted it in the directory /home/webserver1/.local/share/containers/storage/volumes/websites/_data/9001

The index.html I uploaded with SFTPgo had the user:group => 624288:624288.
I changed user:group with:
# chown -R 624288:624288 *

In MariaDB, I used the command:
MariaDB [(none)]> SHOW GLOBAL VARIABLES LIKE 'PORT';
and it displayed 3306.

At the top of PhpMyAdmin, it is showing:
Server 127.0.0.1:3306

I went to the proper URL and the WordPress installation offered the DB connection page.
I gave the right DB name, user, and password.

For the address of the DB, I tried: localhost, 127.0.0.1, localhost:3306, 127.0.0.1:3306,

From MariDB Instances: External mariadb TCP port : 20011
Then I tried: localhost:20011, 127.0.0.1:20011

Always the installation displayed: “Cannot connect to DB…

Any suggestion ?

Michel-André

1 Like

myserver.domain.com:20011

???

127.0.0.1 is the reference of the webserver container but you need to connect to the fqdn of the server on port 20011

Salut Stéphane,

To access the WordPress installation page, I use:
http://toto-dev.org/index.php.

I put: toto-dev.org:20011

Same problem, " Erreur lors de la connexion à la base de données"

I noticed that I have to specify index.php if not, I receive " 403 Forbidden"
I might have another problem ???

Michel-André

Fqdn of the server not the fqdn of the virtualhost

In your server the fqdn must get a A dns entry

Test it by

dig any myserr.domain.com

root@ns8:~# dig any toto-dev.org

; <<>> DiG 9.16.42-Debian <<>> any toto-dev.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60997
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;toto-dev.org.            IN      ANY

;; ANSWER SECTION:
toto-dev.org.     0       IN      A       192.168.1.110

;; Query time: 0 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sat Jul 22 16:06:05 EDT 2023
;; MSG SIZE  rcvd: 52

root@ns8:~#

toto-dev.org:20011

Same problem

I put back the index.html and I just have to specify: toto-dev.org and it shows “Hello world”



I remember looking at some NGINX conf file that it uses only index.html or index.htm and only at the end of the file there is an if satement about PHP.

cat /home/webserver1/.config/templates/vhost-nginx.conf

...
index  index.html index.htm;
...
{% if PhpVersion %}
    location ~ \.php$ {
        root   /usr/share/nginx/html/{{WebRoot}};
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:{{port}};
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  /app/{{WebRoot}}$fastcgi_script_name;
    }
{% endif %}

But no mention of it in:
/home/webserver1/.local/share/containers/storage/overlay/b7989815ffac3163bdb7d90c54d8ecc1491baddd411ac70fb6af5c063538a90e/diff/etc/nginx/nginx.conf

Michel-André

By the way, toto-dev.org is a “Virtual host” created inside webserver1 (Create a virtual host).

Michel-André

Blind shot

The user you created with permissions to the database can connect outside of localhost, use %

With containers you must assume that localhost it’s only them and you try to connect from another container

Else check journald to catch errors during connection

journalctl -t mariadb1 -f

Adjust mariadb1 to the module_ID of ns8-mariadb you installed

Salut Stéphane,

I have entries from:
# journalctl -t mariadb1 -f
only when I use on the WordPress installation page:
toto-dev.org:20011

jui 22 21:21:16 ns8.debian.toto-dev.org mariadb1[2388]: 2023-07-23 1:21:16 226 [Warning] Access denied for user 'usager_WPBD'@'10.0.2.100' (using password: YES)

toto-dev.org is the virtual host domain I created with NGINX
ns8.debian.toto-dev.org is the FQDN of the host server.

I do not know where 10.0.2.100 is from.

Michel-André

The problem is with the connection.

I can connect to the DB

root@ns8:~# mysql -u michelandre -h 127.0.0.1 -P 20011 -p WPBD
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 229
Server version: 10.11.3-MariaDB-1:10.11.3+maria~ubu2204 mariadb.org binary distribution

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

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

MariaDB [WPBD]>

But the user cannot:

root@ns8:~# mysql -u usager_WPBD -h 127.0.0.1 -P 20011 -p WPBD
Enter password:
ERROR 1045 (28000): Access denied for user 'usager_WPBD'@'10.0.2.100' (using password: YES)
root@ns8:~#

Michel-André

EDIT:
Tomorrow I will make the user a cluster-admin and see what will happen.

When you created the database you created a user that is not allowed to connect from the ip 10.0.2.100. Since the port 20011 is not allowed externally it safe to allow to connect this user from any IP, use %

Salut Stéphane,

Thank you for your recurrent support.

The only dumb question is the one not asked. (Dixit: Andy)
So where do I put that % ?

I made the user usagerwpbd cluster-admin and domain-admin. In phpmyadmin, I gave him all the rights. => Then he was able to. connect.
The installation of WordPress was able to complete.

The WordPress login page is displayed and I enter the user/password for the admin of WordPress then 403. The certificate is not good (see below).
image

I tried to change “user:group” webserver1:webserver1 or 9001:9001 or 624288:624288 to no avail.

Also:
Where this certificate comes from ??? Left over ???

The Let’s Encrypt certificate I uploaded includes all of the names needed. At least, it is used by the cluster-admin and looks good.

This NS8 is quite something !

Michel-André

Salut @stephdl

I restored the prvious snapshot and started all ove again with the connection you mentioned => toto-dev.org:20011.

The installation of WordPress went OK except, when connecting, I still received the same error: 403 Forbdden.

In wp-config.php, I commented all the lines of WordPress keys.

// ** define( 'AUTH_KEY',         'OB>E3ef8)jC:,XF3D[=~Cp:ej])i2wU_aT|ZFYf#dBL,`4HzIa1hV4Ql*sn2,yAn' );
// ** define( 'SECURE_AUTH_KEY',  'H{i8N**;7dMA MF+7oohNim@k>g@%EJP3.N{ayB[`Jc%]yvD)M~,.SapG)i FNP7' );
// ** define( 'LOGGED_IN_KEY',    '@l#<o4aKM{i^mUGVDGA1HUa(!1[xPy=Q-<q9YrS+Wqyf`KP1OIjhP!t/Rt6dyYnh' );
// ** define( 'NONCE_KEY',        '}EVHps}zx*I[~RxbFaoCoiu%DQlH([[!Z?x2lF*0^du.Rg2~!,a/{,CyaO)X!%$Q' );
// ** define( 'AUTH_SALT',        '$ubeH1db$ RiZ>,=:y$.P-JL^3UfUKd<IK8~4<bqv)uhLvS^(RMO-%PnU_+q#G{x' );
// ** define( 'SECURE_AUTH_SALT', 'eVx8&ouFYZwor7&wkBMOG}o]2U.# ybCIty*`zIA:#CDDP2S<II?LN2 ~V,6CZ%Q' );
// ** define( 'LOGGED_IN_SALT',   '.Di6@@BEymW6E $o>SFVy*BKhIKinI^cT Th;CP*`#x5uTMjWT1M0<#-*R#Qg-6!' );
// ** define( 'NONCE_SALT',       '7]b!/4 V@4?K-/VZvg4R_&7o;:iS +:CpNCuM4J*a!Urp+2H?#pv8xv5m_Zad6wI' );

I nenamed wp-activate.php to wp-activate.php_original.

For directory: /home/webserver1/.local/share/containers/storage/volumes/websites/_data/9001
# chown -R webserver1:webserver1 *

I still received the same error: 403 Forbidden.

In total desperation I rebooted the server.

Then, without hope, I tried to login to WordPress.

And voilà!

image Total Victory, raise the banner of victory.

Thank you so much for your help and you can continue that “work in progres” (your holiday).

Michel-André

If you dont want to fail the permission, you could try sftpgo or a sftp connection directly to scp the files of wordpress

Could you test please

Salut @stephdl

Small mistake.

The user:group have to be:

chown -R 624288:633288 /home/webserver1/.local/share/containers/storage/volumes/websites/_data/9001

Without that, the update of WordPress is asking ftp credentials.


I also added index.php to the file: /home/webserver1/.config/templates/vhost-nginx.conf

    location / {
        root   /usr/share/nginx/html/{{WebRoot}};
        index  index.html index.htm index.php;
        autoindex {{Indexes}};

I tried that at the beginning for index.html and the user:group was 624288:633288 which is the proper user:group. Note that those are 2 different numbers which I didn’t notice at the beginning.

Please, continue enjoying your holyday… :slight_smile:

Michel-André

1 Like

I think I have a cuple of hours on webserver when I will be back

1 Like

For now !!!

3 Likes

Hi all,

When I try to modify a page in WordPress and saving it, I receive:

Updating failed. The response is not a valid JSON response.

What is wrong or missing ?

Michel-André

Hi all,

I installed and configured Advanced Editor Tools and now the message is no more there.

If I create a new page, Publish and clic View page, I get:

# 404 Not Found

---
nginx/1.24.0

If I make it the default page then it is displayed OK.

If I put back another page ad the default, then back to the editor, Update and I clic View page, it is displayed OK.

Is there something wrong with NGINX as in WordPress, the pages are stored in the DB ?

Michel-André

EDIT
I tried with many new pages and always the same problem: 404 Not found.

For sure, there is an error in the NGINX configuration somewhere.

EDIT-2

After a reboot, I am only able to display default page but I can change it to another page and the other page is displayed. Impossible to display the old default one or any other one, They all give 404 Not Found.

Definitely an NGINX error.