Upgrading PHP Version on Ubuntu 14.04

Once it was necessary to upgrade the version of PHP 5.5.9 to 5.6 on Ubuntu Server 14.04 LTS, the usual update of the system components did not help:

sudo apt-get update
sudo apt-get upgrade

You can try to upgrade the system to 16.04 or higher as I described in the article Updating Ubuntu 14.04 to 16.04. Together with the system will be updated and PHP.

If the system update fails, you can add a third-party source with PHP:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

And install the correct version from it, for example PHP 5.6:

sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml

Since there are several installed versions, disable the old version and activate the installed one:

sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart

Similarly, you can install PHP 7.2:

sudo apt-get install php7.2
sudo a2dismod php5.6
sudo a2enmod php7.2
sudo service apache2 restart

Or PHP 7.0:

sudo apt-get install php7.0
sudo a2dismod php7.2
sudo a2enmod php7.0
sudo service apache2 restart

Install Apache JMeter in Ubuntu

Apache JMeter — load testing tool.

For Apache JMeter you need to install Java, see my article – Installing Java on Linux.

For an example I’ll install Apache JMeter in Ubuntu Desktop 18.04.

After Java is installed, copy the link to the archive with the latest version of Apache JMeter from the official site http://jmeter.apache.org/download_jmeter.cgi and download it:

wget http://apache.volia.net//jmeter/binaries/apache-jmeter-4.0.tgz

Extract the archive:

tar -xf apache-jmeter-4.0.tgz

Run:

cd apache-jmeter-4.0/bin/
./jmeter

After the startup, a message was displayed that you can create tests in the Apache JMeter graphical mode, and you can execute them only from the terminal, for example:

jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]

By the way, Apache JMeter in Windows is run through the jmeter.bat file.

Installing Magento on Ubuntu

On the test, I install Magento in Ubuntu Server 16.04 & PHP 7.

First, update the system and install the necessary components:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 php mysql-server mysql-client openssl libcurl3 php-curl php-gd php-mcrypt php-xml php-intl php-zip php-mbstring php-soap php-mysql php-cli php-json libapache2-mod-php php-xsl composer

Open the PHP configuration file in a text editor:

sudo nano /etc/php/7.0/apache2/php.ini

And install or make sure that memory_limit is at least 512M:

memory_limit = 512M

Activate the necessary modules:

sudo a2enmod rewrite
sudo phpenmod mcrypt

In the apache2 configuration, add the site or edit the standard:

sudo nano /etc/apache2/sites-enabled/000-default.conf

Add the following parameters inside the VirtualHost tags:

<Directory /var/www/html/magento_test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

Restart apache2 to apply the changes:

sudo service apache2 restart

Connect to the MySQL server, create the database and the user:

mysql -u root -p
CREATE DATABASE magento;
CREATE USER magento@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON magento.* TO magento@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit

Download the archive with the latest version of Magento and unpack it:

cd /tmp/
wget https://github.com/magento/magento2/archive/2.2.3.tar.gz
tar xzvf 2.2.3.tar.gz

Move the files to the web server directory:

sudo mv magento2-2.2.3 /var/www/html/magento_test

Execute the command:

cd /var/www/html/magento_test
sudo composer install

Install on the files of the right, the owner and the group under which the web server is running:

cd /var/www/html/magento_test
sudo find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \;
sudo find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \;
sudo chmod u+x bin/magento
sudo chown -R www-data:www-data /var/www/html/magento_test/

Open the browser http://SERVER/magento_test and continue the installation process by following the instructions, remember the login/password and “Magento Admin Address”, as it will open the admin panel.

After installation, let’s see where php is located to correctly specify the path in cron jobs (usually it’s in /usr/bin/php):

which php

Open crontab:

sudo crontab -u www-data -e

And add the tasks:

* * * * * /usr/bin/php /var/www/html/magento_test/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/html/magento_test/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/html/magento_test/update/cron.php >> /var/www/html/magento_test/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento_test/bin/magento setup:cron:run >> /var/www/html/magento_test/var/log/setup.cron.log

This completes the installation of Magento.

See also:
Solving the “Autoload error” when installing Magento
Using and configuring CRON

Solving the “Autoload error” when installing Magento

Once installed Magento in Ubuntu and noticed in the browser the following error:

Autoload error

There were also pieces of code, depending on the open page.

In my case, the error occurred because of the uninstalled libapache2-mod-php, installed it with the command:

sudo apt-get install libapache2-mod-php

After that the error did not appear and I continued the installation of Magento.

Updating phpBB 3.1.x to phpBB 3.2.x

On the test, I will update the phpBB 3.1.9 forum to the version of phpBB 3.2.2.

System requirements phpBB 3.2 if necessary, you can see here https://www.phpbb.com/support/docs/en/3.2/ug/

Be sure to make a backup copy of the database and forum files.

I recommend that you perform an update on the test virtual server, running a copy of the forum from the backups, because in my case there were errors and it took them a while to fix them, and then you can update them to the main one in a similar way quickly.

We proceed to update, download the archive with the new version of phpBB 3.2.x and unpack it:

wget https://www.phpbb.com/files/release/phpBB-3.2.2.zip
unzip phpBB-3.2.2.zip

In the unpacked forum data, delete the file config.php and these directories: files/, images/, store/.

In the phpBB data, what’s on the web server will be deleted except for the ext/, files/, images/, store/ and config.php file.

Move the remaining downloaded data to the directory with the forum data, agree to overwrite the file in the ext/ directory.

If the rights to files and owner change, for example, you can specify them as follows:

sudo chown -R www-data:www-data /var/www/forum/

If the database of the forum is large, then you can execute the command in the root directory of the forum:

php ./bin/phpbbcli.php db:migrate --safe-mode

Open the forum address in the browser by adding /install/app.php/update or /install/database_update.php at the end, select the “Update” tab, select “Update database only”, start the update process and wait for the completion.

After the successful update, delete the install directory:

rm install

See also my articles:
Solution of error “A module already exists” and “The installer detected a timeout” when updating phpBB
Import and export MySQL databases
Updating phpBB 3.1.8 to phpBB 3.1.9
Updating phpBB 3.0.x to phpBB 3.1.x
Other about phpBB

Solution of error “A module already exists” and “The installer detected a timeout” when updating phpBB

I updated phpBB 3.1.9 once to phpBB version 3.2.2 and noticed the following error:

The installer detected a timeout
The installer has detected a timeout, you may try to refresh the page, which may lead to data corruption. We suggest that you either increase your timeout settings or try to use the CLI.

Cleaned the table “phpbb_migrations” in the forum database:

TRUNCATE TABLE phpbb_migrations;

And again launched the update, but got another error:

A module already exists: UCP_AUTH_LINK_MANAGE

The standard Profile module was naturally installed, it could be disabled, but not deleted.
Therefore, I found it in the “phpbb_modules” table and deleted it, thus causing the update script to think that it is not installed:

SELECT * FROM `phpbb_modules` WHERE `module_langname` LIKE 'UCP_AUTH_LINK_MANAGE';

After continuing the update noticed another error:

A module already exists: ACP_CONTACT_SETTINGS

The Contact module was not even installed, after that I also found it in the table and deleted it, and also found and deleted “UCP_AUTH_LINK_MANAGE” once again, because the update script restored it:

SELECT * FROM `phpbb_modules` WHERE `module_langname` LIKE 'ACP_CONTACT_SETTINGS';
SELECT * FROM `phpbb_modules` WHERE `module_langname` LIKE 'UCP_AUTH_LINK_MANAGE';

After removing the modules from the “phpbb_modules” table, I cleared the “phpbb_migrations” table:

TRUNCATE TABLE phpbb_migrations;

I launched the phpBB update and it was successful.

See also:
Updating phpBB 3.0.x to phpBB 3.1.x

Troubleshooting PHP Warning “Permission denied /var/cpanel/php/sessions/ea-php56/”

Once I updated EasyApache 3 to EasyApache 4 in cPanel and noticed in the PHP logs the following:

[29-Mar-2018 15:54:45 UTC] PHP Warning:  Unknown: open(/var/cpanel/php/sessions/ea-php56/sess_3d96o7nnlnnr473p8619vqkdm1, O_RDWR) failed: Permission denied (13) in Unknown on line 0
[29-Mar-2018 15:54:45 UTC] PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/cpanel/php/sessions/ea-php56) in Unknown on line 0

The warning occurs because PHP can not write session files to a directory to which it does not have access rights.
I looked at the rights of this directory, the group and owner was root, and it was also allowed to write and execute for everyone, except reading.

To resolve this warning, you can open full access for everyone:

chmod 777 /var/cpanel/php/sessions/ea-php56

Or open a PHP configuration, for example in the nano editor:

nano /opt/cpanel/ea-php56/root/etc/php.ini

To find:

session.save_path = "/var/cpanel/php/sessions/ea-php56"

And change to:

session.save_path = "/tmp"

That used to be on the old EasyApache3 in the PHP configuration /usr/local/lib/php.ini.

After that, the warning did not appear.

See also:
Migration from EasyApache 3 to EasyApache 4

How to remove “Proudly powered by WordPress”

To remove the inscription «Proudly powered by WordPress», which is usually displayed at the bottom of each page, you need to edit the footer.php file of the active theme (for example, if the twentyfifteen theme is active, then /wp-content/themes/twentyfifteen/footer.php).

Namely, clear the content between the following tags:

<div class="site-info">
...clear what's here...
</div><!-- .site-info -->

Also noticed that if you use Jetpack with infinite scrolling, then it adds its footer, to open it you will open the file /wp-content/plugins/jetpack/modules/infinite-scroll/infinity.php and delete the line:

<?php echo $credits; ?>

The AMP plug-in’s footer is here – /wp-content/plugins/amp/templates/footer.php.

After updating the theme or Jetpack may have to repeat.

Done.

Installing and Using HTTrack on Linux

HTTrack — an offline browser that allows you to download Web sites to your local computer.

Switch to the root user:
su

The installation command in Ubuntu/Debian:

apt-get install httrack

The installation command in CentOS:

yum install httrack

Create a separate directory and go into it so that when downloading the files are not scattered around the current one:

mkdir sitename
cd sitename

Let’s start downloading the site:

httrack sitename.com

If the operating system is Linux with a graphical interface, then you can install WebHTTrack which has a graphical interface:

apt-get install webhttrack

How to change a WordPress theme through MySQL

To change the WordPress theme via MySQL, first see what theme is specified at the moment, for this, execute the SQL query via phpMyAdmin or MySQL client:

SELECT * FROM wp_options
WHERE option_name = 'template'
OR option_name = 'stylesheet'
OR option_name = 'current_theme';

Next, see what themes are in the /wp-content/themes/ directory.

For example, to change to the standard Twenty Fifteen theme, let’s execute three SQL queries:

UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'twentyfifteen' WHERE option_name = 'stylesheet';
UPDATE wp_options SET option_value = 'Twenty Fifteen' WHERE option_name = 'current_theme';