Pages

Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

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.

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/ 

Tuesday, January 14, 2020

Fedora 31 : Install Yii framework.

Today I will show you how to install the Yii framework:
Yii is a fast, secure, and efficient PHP framework. Flexible yet pragmatic. Works right out of the box. Has reasonable defaults.
First, let's install the PHP , see the official webpage.
Fedora for PHP development.
[mythcat@desk ~]$ sudo dnf install php-cli
...
Is this ok [y/N]: y
Downloading Packages:
(1/2): php-common-7.3.13-1.fc31.x86_64.rpm      794 kB/s | 760 kB     00:00    
(2/2): php-cli-7.3.13-1.fc31.x86_64.rpm         2.2 MB/s | 2.8 MB     00:01    
--------------------------------------------------------------------------------
Total                                           1.6 MB/s | 3.5 MB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : php-common-7.3.13-1.fc31.x86_64                        1/2 
  Installing       : php-cli-7.3.13-1.fc31.x86_64                           2/2 
  Running scriptlet: php-cli-7.3.13-1.fc31.x86_64                           2/2 
  Verifying        : php-cli-7.3.13-1.fc31.x86_64                           1/2 
  Verifying        : php-common-7.3.13-1.fc31.x86_64                        2/2 

Installed:
  php-cli-7.3.13-1.fc31.x86_64          php-common-7.3.13-1.fc31.x86_64         

Complete!
Install these packages: PHPUnit for unit tests or Composer.
[mythcat@desk ~]$ sudo dnf install phpunit composer
...
Complete!
Install mysqli extension:
[mythcat@desk ~]$ sudo dnf install php-mysqli
...
Installed:
  php-mysqlnd-7.3.13-1.fc31.x86_64                                              

Complete!
You can start the server:
[mythcat@desk ~]$ sudo php --server localhost:8080 --docroot  .
PHP 7.3.13 Development Server started at Tue Jan 14 21:58:19 2020
Listening on http://localhost:8080
Document root is /home/mythcat
Press Ctrl-C to quit.
[Tue Jan 14 21:58:40 2020] [::1]:32988 [404]: / - No such file or directory
[Tue Jan 14 21:58:40 2020] [::1]:32990 [404]: / - No such file or directory
[Tue Jan 14 21:58:42 2020] [::1]:33014 [404]: /favicon.ico - No such file or directory
[Tue Jan 14 21:59:48 2020] [::1]:33080 [404]: / - No such file or directory
...
The composer command has these arguments:
[mythcat@desk ~]$ composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.9.1 2019-11-01 17:20:17

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output,
 2 for more verbose output and 3 for debug

Available commands:
  about                Shows the short information about Composer.
  archive              Creates an archive of this composer package.
  browse               Opens the package's repository URL or homepage in your browser.
  check-platform-reqs  Check that platform requirements are satisfied.
  clear-cache          Clears composer's internal package cache.
  clearcache           Clears composer's internal package cache.
  config               Sets config options.
  create-project       Creates new project from a package into given directory.
  depends              Shows which packages cause the given package to be installed.
  diagnose             Diagnoses the system to identify common errors.
  dump-autoload        Dumps the autoloader.
  dumpautoload         Dumps the autoloader.
  exec                 Executes a vendored binary/script.
  global               Allows running commands in the global composer dir ($COMPOSER_HOME).
  help                 Displays help for a command
  home                 Opens the package's repository URL or homepage in your browser.
  i                    Installs the project dependencies from the composer.lock file if present,
 or falls back on the composer.json.
  info                 Shows information about packages.
  init                 Creates a basic composer.json file in current directory.
  install              Installs the project dependencies from the composer.lock file if present,
 or falls back on the composer.json.
  licenses             Shows information about licenses of dependencies.
  list                 Lists commands
  outdated             Shows a list of installed packages that have updates available, including
 their latest version.
  prohibits            Shows which packages prevent the given package from being installed.
  remove               Removes a package from the require or require-dev.
  require              Adds required packages to your composer.json and installs them.
  run                  Runs the scripts defined in composer.json.
  run-script           Runs the scripts defined in composer.json.
  search               Searches for packages.
  show                 Shows information about packages.
  status               Shows a list of locally modified packages, for packages installed from source.
  suggests             Shows package suggestions.
  u                    Upgrades your dependencies to the latest version according to composer.json,
 and updates the composer.lock file.
  update               Upgrades your dependencies to the latest version according to composer.json,
 and updates the composer.lock file.
  upgrade              Upgrades your dependencies to the latest version according to composer.json,
 and updates the composer.lock file.
  validate             Validates a composer.json and composer.lock.
  why                  Shows which packages cause the given package to be installed.
  why-not              Shows which packages prevent the given package from being installed.
Let's install the Yii framework:
[mythcat@desk ~]$ composer create-project --prefer-dist yiisoft/yii2-app-basic basic

Installing yiisoft/yii2-app-basic (2.0.31)
  - Installing yiisoft/yii2-app-basic (2.0.31): Downloading (100%)         
Created project in basic
Loading composer repositories with package information
Updating dependencies (including require-dev)
...
Writing lock file
Generating autoload files
> yii\composer\Installer::postCreateProject
chmod('runtime', 0777)...done.
chmod('web/assets', 0777)...done.
chmod('yii', 0755)...done.
> yii\composer\Installer::postInstall 
Let's run it:
[mythcat@desk ~]$ cd basic/
[mythcat@desk basic]$ ./yii serve
Server started on http://localhost:8080/
Document root is "/home/mythcat/basic/web"
Quit the server with CTRL-C or COMMAND-C.
[Tue Jan 14 22:20:22 2020] [::1]:34072 [200]: /
[Tue Jan 14 22:20:22 2020] [::1]:34074 [200]: /assets/dd70c73/css/bootstrap.css
[Tue Jan 14 22:20:22 2020] [::1]:34076 [200]: /css/site.css
[Tue Jan 14 22:20:22 2020] [::1]:34078 [200]: /assets/afa8d426/jquery.js
[Tue Jan 14 22:20:22 2020] [::1]:34080 [200]: /assets/3235fb02/yii.js
[Tue Jan 14 22:20:22 2020] [::1]:34082 [200]: /assets/dd70c73/js/bootstrap.js
[Tue Jan 14 22:20:23 2020] [::1]:34084 [200]: /index.php?r=debug%2Fdefault%2Ftoolbar&tag=5e1e228626c18 

Tuesday, August 20, 2019

Fedora 30 : Install the last version of PHP.

I try to install the last version of PHP version 7.4.0beta2 with Fedora 30 distro the LXQt environment.
I have not used this programming language for a few years and it is a good issue to remember it.
I download teh archive from the official website and I run these commands:
[mythcat@desk ~]$ cd php/
[mythcat@desk php]$ tar -xf php-7.4.0beta2.tar.xz 
[mythcat@desk php]$ cd php-7.4.0beta2/
[mythcat@desk php-7.4.0beta2]$ ./configure --prefix=$HOME/local
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... no
checking for gcc... no
configure: error: in `/home/mythcat/php/php-7.4.0beta2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[mythcat@desk php-7.4.0beta2]$ vi config
[mythcat@desk php-7.4.0beta2]$ vi config
config.log    config.nice   configure     configure.ac  
[mythcat@desk php-7.4.0beta2]$ vi config.log 
Let's try to install all requests for compiler:
[root@desk home]# dnf groupinstall "Development Tools"
Let's see if these settings working well:
[root@desk home]# dnf groupinstall "Development Tools"
Waiting for process with pid 4373 to finish.
[root@desk home]# kill  -9 4373
[root@desk home]# dnf groupinstall "Development Tools"
...
Complete!
[root@desk home]# dnf install libxml2-devel.x86_64
...
Installed:
  libxml2-devel-2.9.9-2.fc30.x86_64                          xz-devel-5.2.4-5.fc30.x86_64
The last dnf command come with this output:
checking for sqlite3 > 3.7.4... no
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

Package 'sqlite3', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix. 
Let's test it with an old version of sqlite:
[root@desk home]# dnf install sqlite-devel.x86_64 
...
Installed:
  sqlite-devel-3.26.0-6.fc30.x86_64 
And is working well:
[mythcat@desk php-7.4.0beta2]$ ./configure --prefix=$HOME/local
...
config.status: executing default commands

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[mythcat@desk php-7.4.0beta2]$ make 
... 

Build complete.
Don't forget to run 'make test'.
[mythcat@desk php-7.4.0beta2]$ make install
...
[mythcat@desk php-7.4.0beta2]$ make test
...
FAILED TEST SUMMARY
---------------------------------------------------------------------
php://fd wrapper: invalid file descriptor [ext/standard/tests/file/php_fd_wrapper_04.phpt]
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: s
sh: autoconf: command not found
Please send /home/mythcat/php/php-7.4.0beta2/php_test_results_20190819_2038.txt to qa-reports@lists.php.net 
manually, thank you.
make: *** [Makefile:201: test] Error 1
[mythcat@desk php-7.4.0beta2]$ export PATH=$HOME/local/bin:$PATH
[mythcat@desk php-7.4.0beta2]$ . ~/.bash_profile
[mythcat@desk php-7.4.0beta2]$ which php
~/local/bin/php
[mythcat@desk php-7.4.0beta2]$ php -v
PHP 7.4.0beta2 (cli) (built: Aug 19 2019 23:31:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
Let's test it:
[mythcat@desk php-7.4.0beta2]$ php -i | grep 'API'
Server API => Command Line Interface
PHP API => 20190529
Zend Extension Build => API320190529,NTS
PHP Extension Build => API20190529,NTS
DOM/XML API Version => 20031129
Phar API version => 1.1.1
[mythcat@desk php-7.4.0beta2]$ echo '' > infophp.php
[mythcat@desk php-7.4.0beta2]$ php -f infophp.php 
phpinfo()
PHP Version => 7.4.0beta2

System => Linux desk 5.2.8-200.fc30.x86_64 #1 SMP Sat Aug 10 13:21:39 UTC 2019 x86_64
Build Date => Aug 19 2019 23:26:58
Configure Command =>  './configure'  '--prefix=/home/mythcat/local'
Server API => Command Line Interface
Virtual Directory Support => disabled
...
Use interactive mode and hit Ctr+D keys to run it:
[mythcat@desk php-7.4.0beta2]$ php -a
Interactive mode enabled


hello, world1636562552
I can see the compiled modules:
[mythcat@desk php-7.4.0beta2]$ php -m 
[PHP Modules]
Core
ctype
date
dom
fileinfo
filter
hash
iconv
json
libxml
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]