P.Pea
Posts: 20
Joined: Sat Apr 15, 2017 11:43 am

Re: Zero W - Followed Wordpress installation ~ Not working.

Sat Aug 24, 2019 8:03 pm

Andyroo wrote:
Sat Aug 24, 2019 5:38 pm
A quick read though shows two bits with the firewall settings
1) Done
2) 3306

Code: Select all


#The process of installing Raspian:

#The process of installing ufw gufw (To check everything is working)
sudo apt-get install ufw gufw
#(SSH)
sudo ufw allow 22
#(Shell)
sudo ufw allow 80
#(Encryption)
sudo ufw allow 443
#(Wordpress)
sudo ufw allow  3306 
#(avahi-daemon) (Apple)
sudo ufw allow 5353
#(Enable UFW)
sudo ufw allow ssh
sudo ufw default deny
sudo ufw enable
#sudo ufw disable
# Now manipulate at the bottom of /etc/ssh/sshd_config and add this
sudo nano /etc/ssh/sshd_config
# Insert: AllowUsers pi
# To make sure ssh is safe use your pc address as the only acccess to the RPi by doing this:
sudo nano /etc/network/interfaces
#Enter these details at the bottom:
iface eth0 inet static
address 192.168.1.*** Address of RPi
netmask 255.255.255.0
gateway 192.168.1.*** Address of router

#Then input
sudo ufw allow proto tcp from "your ip address" to any port 22
#Finally
service ssh restart

#Check Status
sudo ufw status verbose

#(MyMediaAlexa) (My Extras)
sudo ufw allow 52050
sudo ufw allow 52051


#Now the process of installing Wordpress via https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress
#1st The process of installing apache
sudo apt-get install apache2 -y
# Test the web server via: http://localhost or RPi's local ip address

#2nd The process of installing php
sudo apt-get install php -y
# To access these files we need to access cd /var/www/html/ folders
cd /var/www/html/

#(Testing)
#If using RPi GUI use leafpad if not use nano
#sudo leafpad index.php
sudo nano index.php

#Insert this and save:
#<?php echo "hello world"; ?>
#if needed
#sudo service apache2 restart 
#Then remove old html:
sudo rm index.html


#3rd The process of installing MySQL:
sudo apt install mariadb-server php-mysql -y
#Then:
sudo service apache2 restart


#4th The process of installing wordpress:
# access /var/www/html/
cd /var/www/html/
sudo rm*
#wget:
sudo wget http://wordpress.org/latest.tar.gz
#unwrap
sudo tar xzf latest.tar.gz
#Move
sudo mv wordpress/* .
#Remove old tarball
sudo rm -rf wordpress latest.tar.gz
#Change ownership to apache user
sudo chown -R www-data: .

#5th The process of installing wordpress database:
sudo mysql_secure_installation

#You will be asked Enter current password for root (enter for none): — press Enter.

#Type in Y and press Enter to Set root password?.

#Type in a password at the New password: prompt, and press Enter. Important: remember this root password, as you will need it later to set up WordPress.

#Type in Y to Remove anonymous users.

Type in Y to Disallow root login remotely.

#Type in Y to Remove test database and access to it.

#Type in Y to Reload privilege tables now.

#When complete, you will see the message All done! and Thanks for using MariaDB!.

#Create the WordPress database:
sudo mysql -uroot -p

#Insert these:
create database wordpress;
#If this cdhas been successful, you should see this:

#Query OK, 1 row affected (0.00 sec)

#Now grant database privileges to the root user. Note: you will need to enter your own password after IDENTIFIED BY.

GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'YOURPASSWORD';

#For the changes to take effect, you will need to flush the database privileges:
FLUSH PRIVILEGES;

#Now exit:
exit

#or Exit the MariaDB prompt with Ctrl + D.

#Now reastart service
sudo service apache2 restart

#Wordpress is now installed and you can proceed to your webpage 

*******************************************************************

#The next stage requires editing of the wp-config-sample.php to be later saved as wp-config.php. Make sure you are in /var/www/html/ so:
cd /var/www/html/
sudo nano wp-confi-sample.php

This the code on my php without keys: 
*Saved as wp-config.php*

*** and then continuing to finish...***

#[code]
#<?php
#/**
# * The base configuration for WordPress
# *
# * The wp-config.php creation script uses this file during the
# * installation. You don't have to use the web site, you can
# * copy this file to "wp-config.php" and fill in the values.
# *
# * This file contains the following configurations:
# *
# * * MySQL settings
# * * Secret keys
# * * Database table prefix
# * * ABSPATH
# *
# * @link https://codex.wordpress.org/Editing_wp-config.php
# *
# * @package WordPress
#*/
#
#// ** MySQL settings - You can get this info from your web host ** //
#/** The name of the database for WordPress */
#define( 'DB_NAME', 'wpdata' );
#
#/** MySQL database username */
#define( 'DB_USER', 'muppet' );
#
#/** MySQL database password */
#define( 'DB_PASSWORD', 'YadaYadaYada' );
#
#/** MySQL hostname */
#define( 'DB_HOST', 'localhost' );
#
#/** Database Charset to use in creating database tables. */
#define( 'DB_CHARSET', 'utf8' );
#
#/** The Database Collate type. Don't change this if in doubt. */
#define( 'DB_COLLATE', '' );
#
#/**#@+
# * Authentication Unique Keys and Salts.
# *
# * Change these to different unique phrases!
# * You can generate these using the {@link https://api.wordpress.org/#secret-key/1.1/salt/ WordP$
# * You can change these at any point in time to invalidate all #existing cookies. This will forc$
# *
# * @since 2.6.0
#*/
#define( 'AUTH_KEY',         'put your unique phrase here' );
#define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
#define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
#define( 'NONCE_KEY',        'put your unique phrase here' );
#define( 'AUTH_SALT',        'put your unique phrase here' );
#define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
#define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
#define( 'NONCE_SALT',       'put your unique phrase here' );

#/**#@-*/
#

Matched to wordpress front page access at the beginning

Okay above is everything that I have done... I still don't get a connection...
I'm sure I'm getting confused about users.
Thanks Andyroo
I'm a noob with learning difficulties so don't be so vague!
Better explanations yield results and I understand better which in turn saves you time and the rest that follow.

Andyroo

Re: Zero W - Followed Wordpress installation ~ Not working.

Sat Aug 24, 2019 8:47 pm

Bit baffled as the code is commented out (by use of #) and the MySQL user and database do not match - some are mine some are yours.

The user root exists in two places, a Linux user and an SQL user - you do not log in to the Pi as root (it’s abilities come from sudo) but you log in to MySQL as it’s root user.

The user pi is used to log on and does not need to be used for anything in the WordPress or MySQL work at all. It’s just to allow you to set the computer up.

The user used to connect to the database does not have to be a user that can sign on to the Pi - it only needs to be known to WordPress and MySQL

My instructions used the MySQL root user to create a new MySQL user and the changes to the php program tells WordPress how to connect to the database and who to connect as (the MySQL user).

Now you have opened the firewall port, try my instructions verbatim and see if that works.

If not I can set up a Buster box and run through the steps for you with a screen copy if that helps?

fbe
Posts: 526
Joined: Thu Aug 17, 2017 9:08 pm

Re: Zero W - Followed Wordpress installation ~ Not working.

Sun Aug 25, 2019 10:53 am

You need to create the database and database user that you want to use for Wordpress. E.g.

Code: Select all

[email protected]:/var/www $ sudo mysql -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 102
Server version: 10.3.15-MariaDB-1 Raspbian testing-staging

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 [(none)]> create database wordpress;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO 'muppet'@'localhost' IDENTIFIED BY 'YadaYadaYada';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit
Bye
[email protected]:/var/www $
If the database wordpress is already there, you dont need to create it again, just omit the CREATE DATABASE statement.
Then use the same values in wp-config.php

Code: Select all

...
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'muppet' );

/** MySQL database password */
define( 'DB_PASSWORD', 'YadaYadaYada' );
...
You should at least read https://wordpress.org/support/article/h ... wordpress/ before publishing your site.
Enter "http://<your ip-address>/wp-includes/" in your browser and figure out, how to suppress directory listings...

P.Pea
Posts: 20
Joined: Sat Apr 15, 2017 11:43 am

Re: Zero W - Followed Wordpress installation ~ Not working.

Sun Aug 25, 2019 12:07 pm

Here's a thought...
Should I have created a user in pi first then access that user then installed wordpress, then using that user to use wordpress webpage etc...
To me that may have been easier for aa noob...
I'm a noob with learning difficulties so don't be so vague!
Better explanations yield results and I understand better which in turn saves you time and the rest that follow.

P.Pea
Posts: 20
Joined: Sat Apr 15, 2017 11:43 am

Re: Zero W - Followed Wordpress installation ~ Not working.

Sun Aug 25, 2019 12:16 pm

P.Pea wrote:
Sun Aug 25, 2019 12:07 pm
Here's a thought...
Should I have created a user in pi first then access that user then installed wordpress, then using that user to use wordpress webpage etc...
To me that may have been easier for aa noob...
What's the best:
1/
Move wordpress associated with pi
or uninstall then re-install.
2/
Or just uninstall and access the new user and re-install.

How to completly remove wordpress please just in case.
I'll muddle on through though and I do appreciate your help andyroo / fbe / Dougie
I'm a noob with learning difficulties so don't be so vague!
Better explanations yield results and I understand better which in turn saves you time and the rest that follow.

fbe
Posts: 526
Joined: Thu Aug 17, 2017 9:08 pm

Re: Zero W - Followed Wordpress installation ~ Not working.

Sun Aug 25, 2019 5:54 pm

There are users in Linux. E.g. "pi" is a Linux user that you use to login to your desktop or via ssh. You dont't need to create a new Linux user for your Wordpress installation. Wordpress is running in a web server process. The user www-data is used for this process and this is OK. The file permissions as set in the tutorial that you followed work, but should be changed before you publish your site for security reasons.

There are users in MariaDB. It doesn't matter what database user created the database for your Wordpress installation and it doesn't matter what database user created the tables in your Wordpress database. In your first successfull attempt you used the database user [email protected] for that. This is no problem. But for the ongoing operation Wordpress should not login as [email protected] for two reasons:
  • The debian packagers preconfigured [email protected] with UNIX SOCKET authentication. I would recommend that you return to this configuration unless you are better than the debian packagers. This means the webserver can't login as [email protected] to MariaDB anymore.
  • [email protected] has too much privileges. Wordpress should login to the MariaDBe as a user, that has access only to the wordpress database.
There are users in your Wordpress CMS that can login to Wordpress in a browser and edit content. This is out of my scope. I don't use Wordpress.

If you can login to MariaDB as [email protected] with a password

Code: Select all

mysql -u root -p
enter the command

Code: Select all

alter user [email protected] identified with unix_socket;
quit
in mysql, to return to UNIX SOCKET authentication for [email protected] If you want to login as [email protected] later, just type

Code: Select all

sudo mysql

Andyroo

Re: Zero W - Followed Wordpress installation ~ Not working.

Sun Aug 25, 2019 8:01 pm

I've documented a WordPress build from scratch for you on Buster at https://www.raspberrypi.org/forums/view ... 1&t=249882

Its not secure or 100% the way I would do it but may get you started till you master WordPress / security.

Return to “Troubleshooting”