Blog

Restart a php8.1-fpm.service automatically after stopped on Nginx Ubuntu Server

In order to restart php8.1-fpm automatically after stopped on Nginx Ubuntu Server, you may add the following:

1. Edit php8.1-fpm.service using nano command or open file via ftp client

$ nano /lib/systemd/system/php8.1-fpm.service

2. Add the following 2 lines at the bottom of [Service]:

[Service]

Restart=on-failure

RestartSec=5s

3. Restart the servie with systemctl cmd:

$ sudo systemctl daemon-reload

4. Check php8.1-fpm.service status

$ sudo systemctl status php8.1-fpm.service

5. Restart the service to verify again

sudo systemctl status php8.1-fpm.service

then

check the status to confirm

$ sudo systemctl status php8.1-fpm.service


Now, the PHP service will restart automatically whenever stopped but I would advise to check the php8.1-fpm log ocassionally to make sure it's not failing often and the reason of stopping.

Published on: 19/08/2024, 4:21 AM

Disable directory (folder) browsing in apache server

Security reason, we shouldn't allowed directory (folder) access via browser, so, in order to disable directory (folder) browsing in apache server, please make some changes as follow:

1. Open apache2.conf under file path via ftp client

etc/apache2/apache2.conf

OR

using command:

$ nano /etc/apache2/apache2.conf

2. Search these keywords

Options Indexes FollowSymLinks

 

Continue reading

 


Published on: 22/03/2024, 8:23 AM

If you are having issue of download file as .bin format on your hybird Android webview app, you may add mimeType that you wanted on DownlaodManger.request as follow:

request.setMimeType(mimeType="audio/mpeg");

 

Here is a sample code for your ref:

webViewWeb.setDownloadListener(new DownloadListener()
        {
            @Override
             public void onDownloadStart(String url, String userAgent,String contentDisposition, String mimeType,long contentLength) {

 

Continue reading

 


Published on: 03/01/2022, 8:25 AM
How to create rounded corners Android Button

To create an Android button rounded corners, it's better to to create separate xml file just for button and save it to drawable folder and link it back to your layout xml file. 

In order to to change the corners of all sides of the button, we will only need one attribute in the button XML file.

 

This will apply all sides to 50% rounded corners.

android:radius="50dp"

To change one or two or three corners, you can add individual attributes as follows:-

 

Continue reading

 


Published on: 11/12/2021, 2:56 PM
Installing Let's Encrypt SSL Certificate on Nginx server running on Ubuntu OS

Let’s Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers.

In this tutorial, we'll be installing SSL Cert on Nginx server running on Ubuntu OS.

 

Step 1 — Installing Certbot

The first step to using Let’s Encrypt to obtain an SSL certificate is to install the Certbot software on your server.

Install Certbot and it’s Nginx plugin with the below apt install commad:

$ sudo apt install certbot python3-certbot-nginx

 

Continue reading

 


Published on: 01/12/2021, 11:55 AM

Are you having website migration or some changes on the website structure categories or slugs? Then you will definitely need to do redirection rules to match with your old urls to new urls.

If you are using a Nginx server and want to redirect your OLD URL to NEW URL, you may use the following rule to add it in the server directive of your domain config block. So, please open the your domain config file under this file path via ssh or ftp etc/nginx/sites-available/example.com

 

OLD URL

http://www.example.com/blog/mynewblogpost.html

 

Continue reading

 


Published on: 24/11/2021, 2:03 AM
How to create a segment of AMP stats on Google Analytics reports

How to create a segment of AMP stats on Google Analytics reports

By default, hits sent from analytics.js are reported as “web” and hits sent from AMP are reported as “amp” using the Data Source dimension.

Using the data source dimension, you can configure a dedicated View with the help of filters. This View will only include your AMP analytics data and filter out everything else. Another option is to create a new segment for the AMP users and use it to display both Web and AMP data under the same reports.

 

Continue reading

 


Published on: 20/11/2021, 3:55 PM
Check your Ubuntu Version from command line

How to add Google Analytics to AMP pages on WordPress

Accelerated Mobile Pages (AMP) is a platform used to build web pages for static content that renders fast. AMP includes an element that enables measurement of user interactions, and it has built-in support for Google Analytics.

If you don’t add Google Analytics tracking to your AMP pages, you will be missing key analytics data about your AMP driven traffic. Since you won’t be tracking hits for AMP pages, you’ll miss meaningful insights about your mobile users.

 

Continue reading

 


Published on: 20/11/2021, 3:24 PM
Check your Ubuntu Version from command line

Check your Ubuntu Version from command line

There are several commands that you can use to find out what version of Ubuntu you are running. The lsb_release utility displays LSB (Linux Standard Base) information about the Linux distribution.

Use the lsb_release -a command to display the Ubuntu version.

$ lsb_release -a

Then the following output will display and its showing Ubuntu version as 18.04

No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:    18.04

 

Continue reading

 


Published on: 19/11/2021, 4:38 AM

How to convert a date from yyyy-mm-dd to dd-mm-yyyy format to display in PHP

Use the strtotime() Function

You can first use the PHP strtotime() function to convert any textual datetime into Unix timestamp, then simply use the PHP date() function to convert this timestamp into the desired date format.

The following example will convert a pre-defined date from yyyy/mm/dd to dd/mm/yyyy format. Instead of the pre-defined date that's used in the example, you may replace the posted date variable ($post_date) that is stored in mysql database.

 

Continue reading

 


Published on: 18/06/2021, 9:06 AM