Find and replace text in all files in subdirectories

To search for and replace a text in all files in all subdirectories of the current directory:

  • find ./ -type f -exec sed -i -e 's/old-text/new-text/g' {} \;
Advertisements

Mail log says – connect to example.com / Connection timed out

In your /var/mail/mail.log you see repeating records containing the same text:
(connect to example.com[93.184.216.34]:25: Connection timed out)

This means that your system has an outgoing e-mail addressed to a mail account at the example domain, and it is stuck in the outgoing message queue.

It will remain there forever and be re-processed over and over again, unless you manually remove it.

Use the following command to see what the stuck (deferred) emails are:

  • postqueue -p

If you want to see what’s inside the email, do this, replacing the ID, A65961B8BDB, with the actual ID of the message you are interested in:

  • postcat -vq A65961B8BDB

And then, if you still want to get rid of it, just delete it:

  • postsuper -d A65961B8BDB

References: [1],[2]


SEO URLs in OpenCart v3

To change the cryptic computer generated URLs to something more meaningful in OpenCart version 3 running on Nginx.

1) In the back office go and toggle:

  • System -> Settings -> Your Store -> [edit] -> Server -> Use SEO URLs -> Yes

2) Edit the relevant configuration file in the directory /etc/nginx/sites-enabled and add:

location / {
try_files $uri @opencart;
}

location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}

location ~* (\.(tpl|ini))$ {
deny all;
}


PrestaShop: The geolocation database is unavailable.

If you seemingly follow the PrestaShop instructions “In order to use Geolocation, please download this file and extract it (using Winrar or Gzip) into the /app/Resources/geoip/ directory.” and still you get an error message saying “The geolocation database is unavailable.”, you probably misread the instructions.

You are supposed to extract the compressed file under its own name into a directory called “/app/Resources/geoip/” and not “/app/Resources/geoip/directory“.


PrestaShop 404 Not Found

Running PrestaShop you may experience error “404 Not Found” when attempting to connect to the back office.

If running nginx, add the following to your site’s configuration file in sites_enabled:

location /<YOUR_ADMIN_FOLDER>/ {
   if (!-e $request_filename) {
      rewrite ^/.*$ /<YOUR_ADMIN_FOLDER>/index.php last;
      }
   }

Where <YOUR_ADMIN_FOLDER> is your admin directory in Prestashop’s installation path, looking something like “admin563hdsk25”.

If you already see in the configuration file something like this, check if the <YOUR_ADMIN_FOLDER> parameter matches the actual path, as it may be simple leftover from another case.


Apache ignores .htaccess file

If your Apache2 server straight ignores .htaccess files as if they would not be there at all, see if the particular site configuration file has the “AllowOverride All” statement within it’s “Directory” section.

Add the statement and restart/reload the Apache2 server.


Enable SSL for Apache

If you are configuring SSL site with your Apache2 server and everything seems fine, but the server is  stubbornly refusing HTTPS connections, you may have overlooked enabling the SSL module.

Enable SSL with Apache2:

  • sudo a2enmod ssl