LayLow
(LayLow)
October 13, 2023, 2:08pm
1
NethServer Version: NS8B2
Hi,
I am trying to install Wordpress on a virtual host, so I have a virtual host sub.domain.com
I have installed NGINX and MariaDB. I created db, user and password with grants to the db via phpmyadmin.
I unzip Wordpress in the root of the virtual host and Wordpress
I adjusted wp-config.php to have the correct credentials
When accessing sub.domain.com I am greeted by Wordpress admin pages asking me for the db and credentials
I enter all the correct details and as the host âlocalhostâ
The Wordpress complains it can not establish a db connection. I double checked names and credentials, all ok
Is using âlocalhostâ as a hostname the correct thing to do in container world? Or did I Make another mistake? (most likely )
TIA
stephdl
(Stéphane de Labrusse)
October 13, 2023, 3:08pm
2
LayLow:
I enter all the correct details and as the host âlocalhostâ
welcome to the world of container, you cannot use localhost here, localhost is not good, a container is like another VM somewhere, use the IP and also please take into account that your user of mariadb cannot be be restricted to localhost, use ``
migrate web data and mariadb mysql database to ns8
https://www.comparitech.com/net-admin/sftp-commands-cheat-sheet/
how to create a user inside mariadb container, first on the node ssh to the userLinux
# connect to mariadb1 (module_id)
ssh mariadb1@localhost
# connect to the mysql container as root
podman exec -ti mariadb-app mysql
# create the database and grant user to all from any IP (external port is closed to 127.0.0.1)
MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS mydatabase;
MariaDB [(none)]> grant all privileges on mydatabase.* to username identified by 'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
add data to the database from a mysql dump
podman exec -i mariadb-app mysql < toto.sql
the example content of toto.mysql, like you can see the user is able to connect from any host, this is a mandatory because we connect from outside the container, but the tcp port random is restricted to localhost
CREATE DATABASE if not exists foo;
CREATE USER if not exists 'foo' IDENTIFIED BY "foo";
GRANT ALL PRIVILEGES ON foo.* TO 'foo';
FLUSH PRIVILEGES;
use foo;
CREATE TABLE IF NOT EXISTS pages (
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(30),
content TEXT,
INDEX(title)
) engine=InnoDB;
INSERT IGNORE INTO pages VALUES (1, 'Bienvenue', 'Bienvenue ');
then on the remote host running the web server send all local files by scp (login 9001 password 9001 for the first vhost you have created inside the ns8-webserver )
the default port is tcp 3092, think to enable the external access, the 9001 is the login of the first vhost
sftp -P 3092 9001@r1.rocky9.org
# move to you local web folder and cp everything to the vhost of NS8
lcd Téléchargements/wordpress-6.2.2-fr_FR/wordpress/
sftp> put -r *
4 Likes
stephdl
(Stéphane de Labrusse)
October 14, 2023, 10:10am
3
stephdl:
use the IP
Better to use the fqdn of the server and the random port
Sub.domain.com:20009
For instance
LayLow
(LayLow)
October 26, 2023, 3:00pm
4
I donât get it.
When I am going to the vhost, I see the before getting started page, telling I need all credentials of the db and user. I do
Then I enter all details and I get Ă©rror in your wp-config.php file, and if I creat the config file with correct credentials I get wp-config exists.
Looping hereâŠ
stephdl
(Stéphane de Labrusse)
October 26, 2023, 3:03pm
5
Take care about the mariadb user it must be able to connect from any host
Without the error that you can find in journald we cannot help you
LayLow
(LayLow)
October 26, 2023, 3:09pm
6
Thanks, dizzy about it. Will try again bit later
But first, do I, or do I not create manually the wp-config.php (copy from the sample and adjust)?
Hi @LayLow
Use PhpMyAdmin to make sure the db user has a % with his name so he can connect from anywhere.
Also, give him all the rights to the DB.
Michel-André
stephdl
(Stéphane de Labrusse)
October 26, 2023, 3:16pm
8
the webinstaller should write for you the config file, just a matter to be able to connect
I recall that creating manually the user and the database works better than with phpmyadmin, I do not recall what
maybe
grant all privileges on mydatabase.* to username identified by âpasswordâ;
is different
grant all privileges on mydatabase.* to username@%
identified by âpasswordâ;
LayLow
(LayLow)
October 26, 2023, 4:28pm
9
phpmyadmin does not like the @% part. This is a pain for such simple task.
stephdl
(Stéphane de Labrusse)
October 26, 2023, 4:31pm
10
Use the command line with my example
welcome to the world of container, you cannot use localhost here, localhost is not good, a container is like another VM somewhere, use the IP and also please take into account that your user of mariadb cannot be be restricted to localhost, use ``
migrate web data and mariadb mysql database to ns8
https://www.comparitech.com/net-admin/sftp-commands-cheat-sheet/
how to create a user inside mariadb container, first on the node ssh to the userLinux
# connect to mariadb1 (module_id)
ssh marâŠ
LayLow
(LayLow)
October 26, 2023, 4:36pm
11
Ok, Iâve tried many things, but now the install is satisfied (typo, command? who knows)
But now I get a http error (mixed content)
michelandre
(Michel-André)
October 26, 2023, 5:14pm
12
Salut @LayLow
https://ns8.debian.toto-dev.org/phpmyadmin/ .
.
âusagerwpbdâ@â%â <====== â%â
Michel-André
2 Likes
LayLow
(LayLow)
October 27, 2023, 7:34am
14
Is there a way to âsolveâ the infamous âMixed contentâ. issue with WP by means of htaccess, thus not via an extra WP module? Examples that I found on the net did not work for me yet, maybe because these examples are not âcontainerâ aware?
michelandre
(Michel-André)
October 27, 2023, 12:44pm
15
Salut @LayLow
What do you mean by âMixed contentâ ?
Michel-André
LayLow
(LayLow)
October 27, 2023, 9:17pm
16
https and http. scripts are called over http and will not load due to enforced https. It seems to be a common problem, but I do not want to solve it at application level but at webserver level.
michelandre
(Michel-André)
October 27, 2023, 10:30pm
17
Salut @LayLow ,
Replace https with http , but I do not know if that will do what you want.
How to change a WordPress URL step-by-step - IONOS CA .
Change WordPress site URL in the admin dashboard.
The most common and easiest way to change the WordPress URL is to enter it directly in the admin dashboard. To do this, navigate to âSettingsâ > âGeneralâ in the admin area . There you will find the input fields where you can change the WordPress site URL or the website URL.
Michel-André
LayLow
(LayLow)
October 28, 2023, 7:38am
18
Yes, that is the case and I did change it already by advise of @stephdl in an old thread (directly in db tables). But still the mixed content, scripts are pulled in via http and thus blocked. I am the only one? (Rocky Linux)
michelandre
(Michel-André)
October 28, 2023, 9:31am
19
Salut @LayLow
I run Debian-12.
Is the port 443 blocked by something ?
I remember commenting all the long keys in wp-config.php.
I do not know if it is related.
To allow the reading of all the .htaccess
files (AllowOverride ALL
), I am more familiar with Apache in NS-7 than with Nginx in NS8.
There is a directive in the conf
file to pass the header as is, with no change, from the requesting URL, but I cannot find it anymore . @mrmarkuz should remember and know how to use it with Nginx.
Michel-André
2 Likes
mrmarkuz
(Markus Neuberger)
October 28, 2023, 9:34am
20
I remember the mixed content issue in combination with reverse proxy. Iâm going to test it asapâŠ
3 Likes