leaving xampp

For many years I used xampp (for Linux: Lampp), because of its simplicity, unlike the “native” Linux apache/php/mysql apps, wich seemed to me very difficult to configure.

The pro of xampp is its simplicity (with few mouse clicks you can do all to install and configure your local php/mysql sever). But the con is that your xampp apps don’t are updated regularly, and there can raise conflicts with Linux “native” mysql.

Therefore I decided to learn how to configure “native” (system-rooted, so to say) apache/php/mysql apps. I chose to install mariadb and not mysql.

And in these last weeks I managed to configure the server, with the following steps:

  • sudo apt install -y apache2
  • sudo apt install -y php
  • sudo apt install mariadb*
  • sudo mysql_secure_installation
  • sudo mysql -u root -p (and within >mysql shell
    • use mysql
    • GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' WITH GRANT OPTION;
    • SHOW GRANTS FOR 'root'@localhost; //to check if it is all right
    • FLUSH PRIVILEGES;
    • exit;
  • sudo systemctl enable mariadb.service

How to switch a php variable according to the server address

I managed to switch my websites links (containing a php variable: $root) according to the server address. If they are in localhost the variable begins with: http://localhost , if they are on remote the variable is the remote address.

The php code is quite simple:

if ($_SERVER['SERVER_NAME'] == "localhost")
{$root_yourwebsiteA = "http://localhost/your path/yourwebsiteA/";
 $root_yourwebsiteB = "http://localhost/your path/yourwebsiteB/";
 $root_yourwebsiteC = "http://localhost/your path/yourwebsiteC/";
}
else 
{$root_yourwebsiteA = "http://remote path/yourwebsiteA/";
 $root_yourwebsiteB = "http://remote path/yourwebsiteB/";
 $root_yourwebsiteC = "http://remote path/yourwebsiteC/";
}

update wordpress in localhost

First of all backup your database follwing these insctructions.

  1. Get the latest WordPress zip (or tar.gz) file.
  2. Unpack the zip file that you downloaded.
  3. Deactivate plugins.
  4. Delete the old wp-includes and wp-admin directories on your web host (through your FTPor shell access).
  5. Using FTP or your shell access, upload the new wp-includes and wp-admin directories to your web host, in place of the previously deleted directories.
  6. Upload the individual files from the new wp-content folder to your existing wp-content folder, overwriting existing files. Do NOT delete your existing wp-content folder. Do NOT delete any files or folders in your existing wp-content directory (except for the one being overwritten by new files).
  7. Upload all new loose files from the root directory of the new version to your existing WordPress root directory.

NOTE – you should replace all the old WordPress files with the new ones in the wp-includes and wp-admin directories and sub-directories, and in the root directory (such as index.phpwp-login.php and so on). Don’t worry – your wp-config.php will be safe.

Be careful when you come to copying the wp-content directory. You should make sure that you only copy the files from inside this directory, rather than replacing your entire wp-content directory. This is where your themes and plugins live, so you will want to keep them. If you have customized the default or classic themes without renaming them, make sure not to overwrite those files, otherwise you will lose your changes. (Though you might want to compare them for new features or fixes..)

Lastly you should take a look at the wp-config-sample.php file, to see if any new settings have been introduced that you might want to add to your own wp-config.php.

More details here.

How avoid https problems in localhost

Since a solution to force browsers toward a secured connection (with https and not http) is using an .htaccess file in the root folder, you can avoid many problems with https in localhost with this code, which you can put into the .htaccess, before the last row:

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]{3}$

So your .htacces file should contain these rows

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^[^.]+.[^.]{3}$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

This way you will have, with the same file, in local an http connection, and in remore an https connection.

https in localhost

Ho provato in molti modi a creare dei certificati in local: sia Chrome sia Firefox li rifiutano.
Allora ho deciso di dire ai browser di accettare una eccezione alla sicurezza per quanto concerne localhost.
In linux però, con xampp, bisogna modificare anche il file /opt/lampp/etc/extra/httpd-ssl.conf indicandogli dove si trova localhost e poi riavviare il server, altrimenti dà un errore di permessi o di oggetto non trovato.

localhost: connessione non riuscita e altro

Non si tratta di permessi, né di files di configurazione. Ho risolto reinstallando lampp (o meglio istallandone una nuova versione).
Da notare che bisogna salvare l’installer di lampp (se si ha linux) su una partizione linux, altruimenti non parte.

Tabella corrotta, secondo l’ultima versione di MariaDB: si veda http://stackoverflow.com/questions/26871926/mariadb-mysql-database-table-corrupt-cant-repair.
In particolare funziona il “REPAIR TABLE myTable USE_FRM;”