Fixing WordPress error: Publishing failed.

On another wordpressinstallation i manage i began, after an update, to get the following error when i tried to publish a new page:

wordpress publishing failed. you are probably offline.

After some googleing i got the solution: the site address wasnt the one i configured, but apparently another one i configured for testing when i first installed that instance. i have no good idea why it reset, but the update failed and i had to reset it and ran it again. thats maybe the reason.

however….

the solution: after changing the site address to the correct value (the wordpress address was still correct) all worked.

Testing the DSGVO-conform embedding of a youtube-video (of myself)

As i plan to make more videos in the future, i want to test the dsgvo-conform embedding of my first youtube-video, as its not really relevant, yet.

I hate the dsgvo… Its good for privacy and all… But… i think its a little much… I have to add the picture for youtube manually…

I should look up another way to embed youtube or look up how expencive the fine would be… Maybe if the user agrees to the conditions at the start… We’ll see…

SSL on Apache2 (while using wordpress)

Sooo… I fixed it and i know what went wrong with ssl – and it was actually not that hard to fix.

To cut things short: If you are using wordpress and change the domain (or subdomain) in your vhosts, do it in the setting-menu of wordpress BEFORE. Else everything will break down and if you are trying to deploy ssl at the same time it will break down even more and you will get the most interesting error messages in your browser and much more other ambigious stuff…

But lets begin at the start.

As i am hosting some websites on my server with one ip, i have to use vhosts. If they are properly configured, its no problem – but my friend bought a new domain and wanted to migrate the wordpress-sites to the new domain and get https (so ssl encryption) for them for obvious reasons.

I used LetsEncrypt (https://wiki.debian.org/LetsEncrypt) because its free and relatively easy (very easy, to be honest). I know there were some fuckups in the past with it, but lets be plain: All i want is, that the little icon in your browser shows a green lock (or whatever symbol is used in your browser). Thats it. Its okay for me that the security isnt perfect, because i only care about the fact that the user isnt getting a “this site might be insecure” message or even worse, that the browser decides to not show the site at all. I probably have to apologize for my long sentences at this point – but i am german and as a german i can tell you: these sentences arent long at all… 😉

Back to topic: I use Letsencrypt and the certbot (“sudo apt install certbot” on debian) for getting my green lock in the browser.

The first thing to note:

For every domain there should be a certificate. (Subdomains excluded, obviously.)

Do not use the same certificate for different Domains!

The next thing to note:

Configure your vhosts (and webserver) beforehand – certbot needs all the sites you want to certify to be reachable.

If thats done, you can create your certificate with certbot:

sudo certbot --apache -d yourdomain.xyz -d www.yourdomain.xyz

All Subdomains should be in there (remember: www is a subdomain).

If you get another subdomain, you can expand the currently used certificate by ADDING the new subdomain to your certbot-line. Be careful to have all your existing domains in the line.

(You will then get prompted if you want to expand the certificate – thats what you want, then)

Anyway – You probably will get prompted if you want certbot change settings of your webserver. I dont recommend it, because it broke stuff – at least for me.

After you have run certbot, your vhosts will have gotten updated, as well.

If you encounter a problem, check your vhosts and if you chane something there, remember to reload or restart the server.

Here is my (slightly modified) conf for this site.

<VirtualHost *:80>
        ServerAdmin me@me.best
        ServerName diemo.best
        ServerAlias www.diemo.best
        DocumentRoot /var/www/mylocation
        <Directory /var/www/mylocation>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
        LogLevel warn
       CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.diemo.best [OR]
RewriteCond %{SERVER_NAME} =diemo.best
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin me@me.best
        ServerName diemo.best
        ServerAlias www.diemo.best
        DocumentRoot /var/www/mylocation
        <Directory /var/www/mylocation>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/diemo.best/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/diemo.best/privkey.pem
</VirtualHost>

Notice: Lines 34,35 and 36 were added by certbot – you should have the rest ready when you run certbot. (You’ll probably get an ssl-error but thats okay.)

Congratulations! You should now have working ssl.

P.S.: The certificates have to be updated every 90 days. Maybe i will write a post about that later.

Testing CodeMirror Blocks

I just wanted to test the plugin “CodeMirror” in WordPress…

Testing CodeMirror Blocks (Plugin for WordPress);
string = "interesting";
int = 3;
double = 3.14159265;

Okay - As I only want to test the design this should be enough.

Changing the maximum Upload-Filesize in WordPress

A friend of mine (and myself) wanted to upload some files – mainly images… and the maximum filesize was 2MB. Thats a bummer…

So i went to https://www.wpbeginner.com/wp-tutorials/how-to-increase-the-maximum-file-upload-size-in-wordpress/ to change the upload-size.

Foreshadowing: Nothing worked.

The trick was to edit the global php.ini, not to create a local one. At least the tutorial got me to get the right idea – thanks!

The global php.ini is (for me at least) in /etc/php/7.3/apache2/php.ini.

It is logical to change (at least) the version-number if you are reading this in the future.

Another hint for finding the location of your php.ini is typing php --ini in your terminal.

In your ini you can search for “upload” and get to the right section called “File Uploads”.

There you change “n” to your desired value: upload_max_filesize = nM ; n ε ℕ

In my case i changed it to 64M and got… 8M as maximum. I guess in my theme there is some other max-value in place that is at 8MB. As 8 MB is plenty at the moment, i dont care, and i will tackle the problem when either i need to be able to upload bigger files or my friend complains again…

HowTo make your local WordPress update localy (and be able to install plugins etc.)

So… I think i dont really need another disclaimer… the two in the posts before should be enough, and i plan to put them in the sidebar, beneath the blogposts, so i dont have to write them everytime… will do that soon.

As the name already suggested this post is about making wordpress update locally, not via ftp or ftps (thats whats suggested in nearly every installation).

To do that, you need to put the following line into your wp-config.php:

define('FS_METHOD','direct');

Thats it.

Just restart your webserver and you should be able to update.

If you still have problems its because wordpress is not allowed to modify the files in your wordpress-directory. Youll have to change the permissions to allow it.

sudo chmod -R 777 /var/www/$yourwordpressfolder

Thats btw not secure at all, because you just gave every user on your server permission to do anything with those files.

As i am lazy it is up to you to determine the right user to give the permissions to.

Generally 770 should also work, btw, but whatever…

HowTo setup vhosts for multiple Instances of WordPress

Disclaimer (again):

I am just writing what I did, you should decide for yourself if it is a good idea to copy it. I am not responsible for any damages or wasted time from following these instructions.

I am still motivated to write something here, so i write the second part of the HowTo, before i get too lazy again.

If you read the last entry, you will have a second wordpress-instance that is done setting up – at least from the server point of view…

To make it work, you probably need to configure virtualhosts in apache.

Therefore you need to edit some conf-files. Enter the directory with

cd /etc/apache2/sites-available/

At least there should be a file called 000-default.conf. In it is defined what a “user with a webbrowser” will be shown when $yourdomain.$yourtld is entered.

To be honest: I really dont care whats in it…. The following conf is copied from diemo.best and changed for you:

<VirtualHost *:80>
        ServerAdmin diemo@luisental.org
        ServerName diemo.best
        ServerAlias diemo.best
        DocumentRoot /var/www/diemo_best/wordpress
        <Directory /var/www/diemo_best/wordpress>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Relevant lines: ServerName, ServerAlias, DocumentRoot and <Directory.

You need to change these to your needs. For example if the domain you own is “paul.com” and you want to show the wordpress-site on “wordpress.paul.com”, your servername and serveralias should be “wordpress.paul.com”.

The DocumentRoot and Directory should point to your wordpress-directory (see last post).

If you have another instance of wp running on your server, then this would probably have the following effect:

People who enter “paul.com” would see the other instance. Only people who enter “wordpress.paul.com” – and people that are directed there by a search-engine, obviously – will see the new wordpress-instance. Every other subdomain will get redirected to “paul.com” and to your other instance.

If you want to change the default behaviour… well… you have to change the 000-default.conf.

It is most likely longer than my example above, but you will be able to identify the relevant parts to change it to your liking.

Now all you have to do is to restart apache and go to your new site in your browser.

Have fun!

A relevant addition:

Dont forget to create a DNS-Record for your sub- or second domain that points to your server. Doing that will make it possible to work – keep in mind that it needs to propagate through the dns-system. That will take a while. If you are like me youll have a nice break now, because everything is done except the DNS-Record, which takes about 30 minutes up to several hours. Take that break, you have earned it. 😉

HowTo setup multiple Instances of WordPress

Before the first things:

Disclaimer: I am just writing what I did, you should decide for yourself if it is a good idea to copy it. I am not responsible for any damages or wasted time from following these instructions.

First things first: I am lazy, so I just write everying lowercase, except the beginning (sometimes). Just that you know… 😉 Another thing: This Post probably looks like shit… I can write raw html (no problem) but i have no idea how to use wordpress. Im writing it just in a textbox and i am not sure if i could simply use markdown and because i already want to be done with this post i wont try right now…

So… after having to create a new instance of wordpress on my server again after a week of not having to do it (and forgetting everything that i did) i decided that i could use this instance of wp to write it down – at least for me or for my friends who are interested. fortunately i already wrote the process down in a chat, because a friend asked me (about 20 minutes after i finished installing a second instance of wordpress myself) how to do it – which was fortunate at that time as well as now for me.

After the long introduction i will begin straight away:

My (maybe relevant) setup:

  • a debian-system and apache2 as webserver
  • multiple (sub)domains with a records to the same ip and a virtualhost setup on that server

My goal(s):

  • having multiple (in theory infinite) instances of wordpress running in parallel WITHOUT that wordpress-network-stuff
    • why not? -> because i didnt like the tutorials for that (that usually means they didnt work for me)
  • every wordpress instance should have its own (sub)domain (obviously)
  • i want to use the same mysql username and password BUT a different database, because im lazy
    • the idea is: if my super-safe random password for the mysql-user gets hacked i will be fucked anyway (because they would probably have hacked something else to get to that point) and i want to be able to install a shitload of instances without having to remember a mysql username and pw for everyone

You have to think a little bit by yourself: Just copying the following lines WILL NOT WORK!

You have to think a little bit by yourself: Just copying the following lines WILL NOT WORK!

You have to think a little bit by yourself: Just copying the following lines WILL NOT WORK!

What to do:

(The following commands are for your terminal on the server to which you should be connected)

Things with a “$”-symbol in front are variables that you probably should change.

MySQL-Stuff

sudo mysql -u$yourusername -p$yourpassword -h$hostofyourdatabase (probably localhost)
create database $yourdatabasename;
GRANT ALL ON $yourdatabasename.* TO 'wordpress_user'@'localhost' IDENTIFIED BY '$yourpassword';
FLUSH PRIVILEGES;
quit

Now you should have a new database for the wordpress_user that you are already using with the password that you are already using.

WordPress-Stuff

  • Go into your webserver-folder (probably /var/www)
  • make a new folder with a good name (if possible), i will call it “wpfolder”
    • find a better name for it than me
  • enter your $wpfolder
    • make sure you have write-permissions in your wpfolder
  • wget https://wordpress.org/latest.zip (Link maybe broken)
  • 7z x latest.zip

Now you should have a folder called “wordpress” in $wpfolder.

The next thing you should do is to edit the wp-config.php. As i said before: I am lazy so i copied it from my other wp-instance:

  • sudo cp /var/www/$myotherwordpressfolder/wordpress/wp-config.php /var/www/$wpfolder/wordpress/

You have to edit the following line:
define( 'DB_NAME', 'wordpress_db' );

  • Change ‘wordpress_db’ to ‘$yourdatabasename’

As you use the user and password of the other instance you dont have to change anything there…

Thats it, basically… To get it running one has to configure a vhost and restart apache – I will probably explain that in another post.