Pages

Tuesday, December 29, 2020

Fedora 33 : Fixes and changes for wordpress - part 001.

If you have the latest version of WordPress installed, then you may encounter this error when trying to add a new page or post.
Publishing failed. The response is not a valid JSON response.
The problem is with how to edit posts.
One solution would be to install this plugin.
The process of installing the new WordPress or making changes does not allow you to add new plugins to the Plugins menu.
Download the Classic Editor plugin to unzip and then copy it to the plugins folder.
[root@desk mythcat]# cp -r -f /home/mythcat/classic-editor/ /usr/share/wordpress/wp-content/plugins/
Activate this plugin and now you can create and edit pages and posts in WordPress.

Friday, December 25, 2020

Fedora 33 : Use Visual Code on root account.

Sometimes creating or modifying files that have root permissions is required.
I use the following command to run Visual Code with these permissions:
sudo code --user-data-dir="~/.vscode-root"

Thursday, December 24, 2020

Fedora 33 : Install wordpress on Fedora distro.

For those who are celebrating the winter holidays with the Linux operating system, I have created this little tutorial...
The first step - update and upgrade the Fedora 33 Linux distro.
[root@desk mythcat]# dnf update
...
Nothing to do.
Complete!
[root@desk mythcat]# dnf upgrade
...
Nothing to do.
Complete!
Install all packages for WordPress package:
[root@desk mythcat]# dnf install @"Web Server" php-mysqlnd mariadb-server
Last metadata expiration check: 1:10:28 ago on Thu 24 Dec 2020 12:59:20 PM EET.
Package php-mysqlnd-7.4.13-1.fc33.x86_64 is already installed.
No match for group package "powerpc-utils"
No match for group package "lsvpd"
Dependencies resolved.
...
Complete!
Finds the packages providing for WordPress.
[root@desk mythcat]# dnf provides wordpress
Last metadata expiration check: 1:13:24 ago on Thu 24 Dec 2020 12:59:20 PM EET.
wordpress-5.5.1-1.fc33.noarch : Blog tool and publishing platform
Repo        : fedora
Matched from:
Provide    : wordpress = 5.5.1-1.fc33

wordpress-5.6-1.fc33.noarch : Blog tool and publishing platform
Repo        : updates
Matched from:
Provide    : wordpress = 5.6-1.fc33
Install WordPress with DNF tool:
[root@desk mythcat]# dnf install wordpress
...
  Verifying        : php-simplepie-1.5.4-3.fc33.noarch                      7/7 

Installed:
  libc-client-2007f-26.fc33.x86_64      php-IDNA_Convert-0.8.0-14.fc33.noarch   
  php-getid3-1:1.9.20-2.fc33.noarch     php-imap-7.4.13-1.fc33.x86_64           
  php-phpmailer6-6.1.8-1.fc33.noarch    php-simplepie-1.5.4-3.fc33.noarch       
  wordpress-5.6-1.fc33.noarch          

Complete!
Allow firewall in case it is running on your system.
[root@desk mythcat]# firewall-cmd --add-port=80/tcp --permanent
success
[root@desk mythcat]# firewall-cmd --reload
success
If SELinux is running, run the commands to allow database and sendmail:
[root@desk mythcat]# setsebool -P httpd_can_network_connect_db=1
[root@desk mythcat]# setsebool -P httpd_can_sendmail=1
Enable systemctl services for WordPress:
[root@desk mythcat]# systemctl start httpd
...
[root@desk mythcat]# systemctl enable httpd
...
[root@desk mythcat]# systemctl enable mariadb
...
[root@desk mythcat]# systemctl start mariadb
...
Set up the MySQL service for WordPress:
[root@desk mythcat]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
Create a database named mysite for WordPress:
[root@desk mythcat]# mysqladmin create mysite -u root -p 
Enter password: 
[root@desk mythcat]# mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 25
Server version: 10.4.17-MariaDB MariaDB Server

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)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysite             |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.000 sec)

MariaDB [(none)]> grant all privileges on mysite.* to testadmin@localhost identified by 'TESTtest!';
Query OK, 0 rows affected (0.019 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit;
Bye
Set WordPress default configuration file named wp-config.php:
[root@desk mythcat]# vim /etc/wordpress/wp-config.php
This source code show you to set wp-config.php for localhost install:
define( 'DB_NAME', 'mysite' );

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

/** MySQL database password */
define( 'DB_PASSWORD', 'TESTtest!' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
Restart the httpd service:
[root@desk mythcat]# systemctl restart httpd
Open URL to set WordPress to set the last steps of this install process:
http://localhost/wordpress/ 

Thursday, December 17, 2020

Fedora 33 : Sigil software.

Sigil is a ePub editor for Linux and omes with powerful features like UTF-16, EPUB 2 spec, and limited EPUB 3 support.
The complete control over directly editing EPUB syntax in Code View and Table of Contents generator with multi-level heading support and metadata editor.
The user interface translated into many languages and spell checking and many plugins available.
These command will show you how can search and install this software:
[root@desk mythcat]# dnf search Sigil
Last metadata expiration check: 0:54:58 ago on Wed 16 Dec 2020 11:01:54 PM EET.
======================== Name & Summary Matched: Sigil =========================
FlightCrew-sigil-plugin.x86_64 : Sigil FlightCrew epub validator plugin
sigil-doc.noarch : Documentation for Sigil ebook editor
============================= Name Matched: Sigil ==============================
sigil.x86_64 : WYSIWYG ebook editor
[root@desk mythcat]# dnf install sigil.x86_64 
Last metadata expiration check: 0:55:32 ago on Wed 16 Dec 2020 11:01:54 PM EET.
Dependencies resolved.
================================================================================
 Package                     Arch       Version               Repository   Size
================================================================================
Installing:
 sigil                       x86_64     0.9.14-7.fc33         fedora      3.5 M
Installing dependencies:
 minizip                     x86_64     2.10.2-1.fc33         updates     112 k
 python3-cssselect           noarch     0.9.2-16.fc33         fedora       38 k
 python3-cssutils            noarch     1.0.2-9.fc33          fedora      270 k
 python3-regex               x86_64     2020.11.13-1.fc33     updates     345 k
 zipios++                    x86_64     0.1.5.9-25.fc33       fedora       78 k
Installing weak dependencies:
 FlightCrew-sigil-plugin     x86_64     0.9.1-21.fc33         fedora      336 k

Transaction Summary
================================================================================
Install  7 Packages

Total download size: 4.7 M
Installed size: 20 M
Is this ok [y/N]: y
...
  Running scriptlet: sigil-0.9.14-7.fc33.x86_64                             7/7 
  Verifying        : minizip-2.10.2-1.fc33.x86_64                           1/7 
  Verifying        : python3-regex-2020.11.13-1.fc33.x86_64                 2/7 
  Verifying        : FlightCrew-sigil-plugin-0.9.1-21.fc33.x86_64           3/7 
  Verifying        : python3-cssselect-0.9.2-16.fc33.noarch                 4/7 
  Verifying        : python3-cssutils-1.0.2-9.fc33.noarch                   5/7 
  Verifying        : sigil-0.9.14-7.fc33.x86_64                             6/7 
  Verifying        : zipios++-0.1.5.9-25.fc33.x86_64                        7/7 

Installed:
  FlightCrew-sigil-plugin-0.9.1-21.fc33.x86_64                                  
  minizip-2.10.2-1.fc33.x86_64                                                  
  python3-cssselect-0.9.2-16.fc33.noarch                                        
  python3-cssutils-1.0.2-9.fc33.noarch                                          
  python3-regex-2020.11.13-1.fc33.x86_64                                        
  sigil-0.9.14-7.fc33.x86_64                                                    
  zipios++-0.1.5.9-25.fc33.x86_64                                               

Complete!

Thursday, December 3, 2020

Fedora 33 : Create a simple AvaloniaUI window.

This tutorial is about Avalonia UI.
Avalonia is a cross-platform XAML-based UI framework providing a flexible styling system and supporting a wide range of Operating Systems such as Windows via .NET Framework and .NET Core, Linux via Xorg, macOS.
I install avalonia dotnet templates from here:
[mythcat@desk CSharpProjects]$ git clone https://github.com/AvaloniaUI/avalonia-dotnet-templates --recursive
Cloning into 'avalonia-dotnet-templates'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 379 (delta 14), reused 19 (delta 7), pack-reused 342
Receiving objects: 100% (379/379), 147.23 KiB | 881.00 KiB/s, done.
Resolving deltas: 100% (202/202), done.
[mythcat@desk CSharpProjects]$ ls
aspnetapp  avalonia-dotnet-templates  HelloWorld  myapp001  MyGame001  Todo
[mythcat@desk CSharpProjects]$ dotnet new --install avalonia-dotnet-templates 
...
Create a default window example with AvaloniaUI:
[mythcat@desk CSharpProjects]$ dotnet new avalonia.app -o MyAppAvalonia
The template "Avalonia .NET Core App" was created successfully.
[mythcat@desk CSharpProjects]$ cd MyAppAvalonia/
[mythcat@desk MyAppAvalonia]$ dotnet add package Avalonia
...
[mythcat@desk MyAppAvalonia]$ dotnet add package Avalonia.Desktop
...
[mythcat@desk MyAppAvalonia]$ ls
App.xaml  App.xaml.cs  MainWindow.xaml  MainWindow.xaml.cs  MyAppAvalonia.csproj  nuget.config  Program.cs
Publish this example:
[mythcat@desk MyAppAvalonia]$ dotnet publish --configuration Release --runtime fedora.33-x64 --self-contained false
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 3.86 sec for /home/mythcat/CSharpProjects/MyAppAvalonia/MyAppAvalonia.csproj.
MyAppAvalonia -> /home/mythcat/CSharpProjects/MyAppAvalonia/bin/Release/netcoreapp3.0/fedora.33-x64/MyAppAvalonia.dll
MyAppAvalonia -> /home/mythcat/CSharpProjects/MyAppAvalonia/bin/Release/netcoreapp3.0/fedora.33-x64/publish/
The last step is the run:
[mythcat@desk MyAppAvalonia]$ dotnet /home/mythcat/CSharpProjects/MyAppAvalonia/bin/Release/netcoreapp3.0/
fedora.33-x64/publish/MyAppAvalonia.dll 
This will open a window build with AvaloniaUI.

Monday, November 30, 2020

Fedora 33 : Build and publish with .NET Core SDK .

In this tutorial I will show you how can use .NET Core SDK to build and run a simple MyGame001 application from the last tutorial.
Let's go to the project and get some infos:
[mythcat@desk ~]$ cd CSharpProjects/
[mythcat@desk CSharpProjects]$ cd MyGame001/
[mythcat@desk MyGame001]$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.109
 Commit:    32ced2d411

Runtime Environment:
 OS Name:     fedora
 OS Version:  33
 OS Platform: Linux
 RID:         fedora.33-x64
 Base Path:   /usr/lib64/dotnet/sdk/3.1.109/

Host (useful for support):
  Version: 3.1.9
  Commit:  774fc3d6a9

.NET Core SDKs installed:
  3.1.109 [/usr/lib64/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.9 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.9 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
The next command will create MyGame001.dll.
[mythcat@desk MyGame001]$ dotnet publish --configuration Release --runtime fedora.33-x64 --self-contained false
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 50.58 ms for /home/mythcat/CSharpProjects/MyGame001/MyGame001.csproj.
  MyGame001 -> /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/MyGame001.dll
  MyGame001 -> /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/publish/
Now you can run it with dotnet command:
[mythcat@desk MyGame001]$ dotnet /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/MyGame001.dll
You can simply run it like an Linux application:
[mythcat@desk MyGame001]$ /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/publish/MyGame001 

Sunday, November 29, 2020

Fedora 33 : Testing xdotool linux tool .

Xdotool is a free and open source command line tool for simulating mouse clicks and keystrokes.
You can create beautiful scrips and tools with this command.
The help for this command is this:
[mythcat@desk ~]$ xdotool -help
Let's see some examples:
This simulate a keystroke for key c:
m[mythcat@desk ~]$ xdotool key c
c[mythcat@desk ~]$ c
The next command will simulate a key press for key c:
[mythcat@desk ~]$ xdotool keydown c
c[mythcat@desk ~]$ cccccccccccccccccccccccccccccccccccccccccccccccccccc^C
[mythcat@desk ~]$ ^C
The next command will simulate a key release for key c:
[mythcat@desk ~]$ xdotool keyup c
Use the enter key:
[mythcat@desk ~]$ xdotool key KP_Enter

[mythcat@desk ~]$
The next command will open a new tab in terminal:
[mythcat@desk ~]$ xdotool key shift+ctrl+t
This command simulate a right click at current location of pointer
xdotool click 3
The reference is: 1 – Left click, 2 – Middle click, 3 – Right click, 4 – Scroll wheel up, 5 – Scroll wheel down.
The next command get ID of terminal window currently in focus and then minimize it:
[mythcat@desk ~]$ xdotool getactivewindow windowminimize
This command lists all open windows:
[mythcat@desk ~]$ xdotool search --name ""
I get the open window with name New Tab - Google Chrome, with this command:
[mythcat@desk ~]$ xdotool search --name "New Tab -"
18874375
This command get the pid of the active window:
[mythcat@desk ~]$ xdotool getactivewindow getwindowpid
3538
The pid is from lxterminal tool:
[mythcat@desk ~]$ ps aux | grep 3538
mythcat     3538  0.3  0.4 601468 42500 ?        Sl   11:42   0:05 lxterminal
mythcat     5713  0.0  0.0 221432   780 pts/1    S+   12:07   0:00 grep 3538
The active window can be move with:
[mythcat@desk ~]$ xdotool getactivewindow windowmove 0 0
The next command get the current mouse coordinates:
[mythcat@desk ~]$ xdotool getmouselocation --shell
X=521
Y=339
SCREEN=0
WINDOW=16780805
These coordinates can be parsed:
[mythcat@desk ~]$ xdotool getmouselocation 2>/dev/null | cut -d\  -f1,2 -
x:0 y:0
[mythcat@desk ~]$ xdotool getmouselocation 2>/dev/null | sed 's/ sc.*//; s/.://g; s/ /x/'
0x0
Open inkscape and select Layer for this window Always on top:
[mythcat@desk ~]$ inkscape 
Start xdotool with focus on mouse and click on rectangle and draw area and follow the output:
[mythcat@desk ~]$ xdotool search --name "inkscape" behave %@ focus getmouselocation
x:25 y:239 screen:0 window:16786173
x:25 y:239 screen:0 window:16786173
x:340 y:378 screen:0 window:16786173
x:340 y:378 screen:0 window:16786173
x:332 y:358 screen:0 window:16786173
x:332 y:358 screen:0 window:16786173
x:518 y:643 screen:0 window:16786173
x:518 y:643 screen:0 window:16786173
x:723 y:466 screen:0 window:16780805
I create a bash script named inkscape_xdotool.sh and I add these commands:
#! /bin/sh
sleep 1
inkscape > /dev/null 2>&1 &
sleep 3
my_app=xdotool search --sync --name 'inkscape'
xdotool windowactivate $my_app
xdotool mousemove 0 0
xdotool mousemove 25 239
xdotool click 1
xdotool mousemove 332 358 mousedown 1 mousemove 518 643
xdotool mouseup 1
sleep 1
exit
I run the script:
[mythcat@desk ~]$ ./inkscape_xdotool.sh 
The script run well.
The output is an rectangle in inkscape with the default black color.