Posts

Understanding File Permissions

 

There are two parts to the file control mechanism: “Classes” and “Permissions.” Classes determines who can access the file, while the Permissions determines what the user can do with that file.

There are three Classes: Owner, Group, and Others.

The Owner is usually the creator of the file or folder. In Linux, any files or folders that you create in your Home directory are usually owned by you unless you specifically change the ownership.


The Group contains a group of users who share the same permissions and user privilege.


Others means the general public.

 
 
 

As for permissions, there are three type of actions that you can perform on a file or folder:

Read. You cannot modify the contents of the file in any way. When applied to a Folder, you can only view the files within that folder; you cannot delete or modify the files in any way or add more files to the folder.


Write. You can modify the file. If you have “write” access to a folder, then you can delete and add files to that folder.


Execute. Execute is mainly used when you need to run the file and is most commonly used when you need to run a script.

By using Classes in combination with Permissions, you can control who has access to a file and the actions they can perform on said file.

The file owner will usually have all three permissions (read, write and execute). If you’re not the owner of the file or folder, then you’ll typically have to change Ownership to your name, or change the permissions of Group or Others to read, write and/or execute.

In a web server, if you’re unable to upload a file, then it’s probably because you’re not the owner of the destination folder. Alternatively, you may not have sufficient permissions to add files to the folder.

Here’s the different permutation:

0 – no permission
1 – execute
2 – write
3 – write and execute
4 – read
5 – read and execute
6 – read and write
7 – read, write, and execute

Depending on the permissions you want to grant to the file, you just need to set the number accordingly.

Here are some of the commonly used permissions:

755. This set of permissions is commonly used by web servers. The owner has all the permissions to read, write and execute. Everyone else can read and execute but cannot make changes to the file.

777. Everyone can read, write, and execute. 

In a web server, it’s not advisable to use the “777” permission for your files and folders, as this allows anyone to add malicious code to your server. However, in some cases you’ll need to set the 777 permissions before you can upload any file to the server – for example: uploading images in WordPress.

644. Only the owner can read and write. Everyone else can only read. No one can execute this file.

655. Only the owner can read and write and cannot execute the file. Everyone else can read and execute and cannot modify the file.

You can also change permissions using the chmod command in the Terminal. In short, “chmod 777” means making the file readable, writable and executable by everyone.

chmod 777 /path/to/file

Certbot not installing ssl certificate with “sudo certbot renew”

If Certbot fails when using “sudo certbot renew”

And you get this….

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you’re using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.

Try make the changes to your Apache configuration by hand, and run this command.

sudo certbot certonly --apache

This has work for us 99% of the time.

SSL Will not renew with EHCP – let’s encrypt

If the auto renew is not working on EHCP, to renew your SSL certificates you are best using certbot.

Certbot Instructions for Apache on Ubuntu 18.04 LTS (bionic)

  1. SSH into the server

    SSH into the server running your HTTP website as a user with sudo privileges.

  2. Add Certbot PPA

    You’ll need to add the Certbot PPA to your list of repositories. To do so, run the following commands on the command line on the machine:

    1. sudo apt-get update
    2. sudo apt-get install software-properties-common
    3. sudo add-apt-repository universe
    4. sudo add-apt-repository ppa:certbot/certbot
    5. sudo apt-get update
  3. Install Certbot

    Run this command on the command line on the machine to install Certbot.

    sudo apt-get install certbot python3-certbot-apache
  4. Choose how you’d like to run Certbot
    • Either get and install your certificates…

      Run this command to get a certificate and have Certbot edit your Apache configuration automatically to serve it, turning on HTTPS access in a single step.

      sudo certbot --apache
    • Or, just get a certificate

      If you’re feeling more conservative and would like to make the changes to your Apache configuration by hand, run this command.

      sudo certbot certonly --apache
  5. Test automatic renewal

    The Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:

    sudo certbot renew --dry-run

    The command to renew certbot is installed in one of the following locations:

    • /etc/crontab/
    • /etc/cron.*/*
    • systemctl list-timers
  6. Confirm that Certbot worked

    To confirm that your site is set up properly, visit https://yourwebsite.com/ in your browser and look for the lock icon in the URL bar. If you want to check that you have the top-of-the-line installation, you can head to https://www.ssllabs.com/ssltest/.

Elementor page builder plugin for WordPress.

Elementor is a drag-and-drop page builder plugin for WordPress.

This means a couple of things:

  • Elementor lets you create good looking posts and pages.
  • You get a 100% separate interface to work on your posts and pages — the bulk of your work doesn’t happen in the standard block editor that comes with WordPress.
  • It doesn’t require any coding skills — everything can be done through a drag and drop interface.
  • Edit in a what-you-see-is-what-you-get manner.
  • You can use it to create any content layout or page layout you can imagine.
  • It works with all WordPress themes.

Features and Benefits

Elementor comes with a handful of useful elements

  • The main page building functionality… (More no that)
  • There are more than 90 content elements/modules to choose from 
  • Most things work with drag-and-drop — you can take any element and move it to a new spot simply by dragging it across the screen.
  • The pages are mobile-responsive and SEO-friendly.
  • There’s a library of pre-made page templates that can be imported and modified.
  • If you’re on the Pro version of Elementor, you can use the Theme Builder feature, which allows you to modify your theme’s core elements, such as the header, footer, single post template, or your blog archives.
  • A completely new WooCommerce Builder module. It’s similar to Theme Builder, but this one allows you to redo all of your default WooCommerce pages, such as your single product page or product archive.

Elementor is a WordPress plugin, to get it working, you’ll first need to install and activate it. After that, there’s a settings panel that you can visit if you want to, but that’s not mandatory. You can head straight to your WordPress pages and create a new one. Right away, you’ll see the option to ‘Edit with Elementor’, After clicking on this  button, you’re going to see the Elementor user interface. 

  1. The main canvas. This is where you can put your content blocks and adjust them.
  2. The content elements that are available.
  3. This is where you can access the settings of Elementor’s (colors, fonts and so on).
  4. This is how you come back to view the content elements.
  5. The global settings of the page you’re working on.
  6. The revision history of the page.
  7. Switch device (desktop, tablet, mobile).
  8. Preview changes.
  9. Publish the page.

To build a basic page with Elementor, you first need to understand the page structure hierarchy that it uses:

  • page can have any number of sections in it.
  • Each section can have one or more columns.
  • Each column can house one or more content elements.
  • Lastly, each content element can be styled individually.

So, we have:

Page → Sections → Columns → Content → Styling

To get started, you can either add a ready-made template or include a blank section:

Within that new section, you can add new columns, and then populate these columns with content by simply dragging and dropping specific blocks from the sidebar. And, of course, you can rearrange sections with drag-and-drop as well.

Once you have a content block in place, you can click on it to adjust the fine details of what’s in it, as well as its presentation. There are three main tabs available for that: ContentStyle and Advanced.

Just like that, one by one, you can work with individual content blocks until you have the whole page ready.

Overall, Elementor is very easy to use and fairly intuitive. Once you grasp the page/structure hierarchy and get to know all of the content elements, working with your pages becomes rather fun. Especially when you start getting into some of the more advanced features, for example:

  • experimenting with the Z-index of elements (to bring stuff forward versus putting it in the back)
  • customizing the on-hover state of elements (changing their appearance based on the cursor position)
  • setting transitions between sections

WP Performance Score Booster

Version: 1.9.2.2

WP Performance Score Booster makes website faster, speed up page load time and instantly improve WordPress performance scores in services like GTmetrix, Pingdom, YSlow and PageSpeed.

  • It Remove any query strings from static resources like CSS & JS files
    Enable GZIP compression (compress text, html, javascript, css, xml and so on)
  • Add Vary: Accept-Encoding header
  • Set expires caching (leverage browser caching).

Fast website pages is one of the key factors for reaching better rankings in Google. While, trying to improve the speed can be tricky, and very time-consuming task.
WP performance booster is free and easy to use plugin, that will significantly increase the performance of your website with a push of a button.

What does this plugin do?

There are only 3 settings that are already checked and working. Besides from these shown here, there is nothing more to adjust.

WP performance Score booster increases your website page speed by doing these 3 main things:

  • Remove query strings from static content.
  • Enable GZIP compression (compress text, html, javascript, css, xml and so on)
  • Set expire caching (Leverage Browser Caching)

If for some reason your theme or other plugins are not working after the installation, disable/enable the settings one by one to see which one is causing a conflict.

Additionally, you can contact the plugin developer by visiting his official site: Dipakgajjar.com. Or, by opening a  support thread on WordPress.org official plugin page.

Pros and cons of this page speed plugin

Pros:

Free plugin,  easy to install.
Almost nothing to configure after installation. Making it really easy to use. you might see up to 50% increase in website speed.

Cons:

Lack of settings is a downside for someone wanting to additionally adjust the plugin.


The plugin may be in conflict with other tools you’ve already installed. 

Make sure to check and see if everything is working after installation.

How to test the speed of your website

Visit Pingdom website speed test using this link here: Pingdom.com

Note: You can  select from which location your website to be tested by clicking Settings.

Type your domain name in the empty field and click test now

You can also use GTmetrix official website here: Add your website URL and click Analyze.

Keep in mind that the scores and the increase in speed will be different, depending on the website and how well is optimized. Factors that have major effect over your website performance are:

Size and the number of images.

Number of plugins.

Hosting provider.

You should definitely go through the things above if you want to increase your website loading speed.

 

Remove the Name, Email & Website and Check Box from the comment form in WordPress.

Remove Fields Website – Name – email & Check Box from comment form

The folloing PHP will remove the Name, Email & Website and check Box from the comment form in wordpress.

Use this code to make your own plugin

You might need to edit it to add Boxes back in…

<?php
/*
Plugin Name: Get Rid of Name Email Website box

//This removes the Check box for save email address
add_filter( ‘comment_form_default_fields’, ‘tu_comment_form_hide_cookies_consent’ );
function tu_comment_form_hide_cookies_consent( $fields ) {
unset( $fields[‘cookies’] );
return $fields;
}
//This remove fields Website (url) – Name (author) – email
//Remove eg $fields[‘url’], to add the Website field back in
function remove_website_name_email_field( $fields ){
if(isset($fields[‘url’],$fields[‘author’],$fields[’email’]))
unset($fields[‘url’],$fields[‘author’],$fields[’email’]);
return $fields;
}

add_filter( ‘comment_form_default_fields’, ‘remove_website_name_email_field’ );

?>

How to Make a plugin 

Making a plugin is a good way to add PHP code in to your website as it will let you disabled it if needed.

It is easy to do but your must have access to your websites files using FTP or you can also use wp-file-manager Plugin to add the files.

Created a folder in wp-content/plugins/ give it a name and created a file inside it called “***.php” (replace the *** with the name you want to call the file, then go to plugins on your website and activated the plugin that shows up in the Plugins interface.

Start the plugin with…

<?php
/*
Plugin Name: This is the name of my Plugin
*/

Add the PHP code that you want to be in the plugin.

Remove the check box “Save my name, email…” from comment area

This checkbox was added in WP 4.9.6 and makes it so your comment forms are compatible with GDPR, which comes into effect on May 25th.

I definitely suggest you read up on it, as there are some pretty heavy fines if the rules aren’t followed.

If your site isn’t affected by GDPR, then you can removable adding this in to your theme’s functions.php file….  this is not recommend becouse doing this for a theme that could update can lose the code, so it is better to make a plugin.   See – How to Make a plugin

Add the following PHP ….

add_filter( ‘comment_form_default_fields’, ‘tu_comment_form_hide_cookies_consent’ );
function tu_comment_form_hide_cookies_consent( $fields ) {
unset( $fields[‘cookies’] );
return $fields;
}

If you don’t want to remove the checkbox but instead edited it use…

add_filter( ‘comment_form_default_fields’, ‘tu_comment_form_change_cookies_consent’ );
function tu_comment_form_change_cookies_consent( $fields ) {
$commenter = wp_get_current_commenter();

$consent = empty( $commenter[‘comment_author_email’] ) ? ” : ‘ checked=”checked”‘;

$fields[‘cookies’] = ‘<p class=”comment-form-cookies-consent”><input id=”wp-comment-cookies-consent” name=”wp-comment-cookies-consent” type=”checkbox” value=”yes”‘ . $consent . ‘ />’ .
‘<label for=”wp-comment-cookies-consent”>Your modified text here</label></p>’;
return $fields;
}

Step by step setup of DNS Nameservers for EHCP with Godaddy registrar.

Register or use an existing domain at GoDaddy account and then go to our domains list, select the DNS for that domain you are going to use Example: mycooldomain.com Scrole down to the bottom of the page and click on Host names.

Click on add and a popup will appear we create the first Host name: ns.mycooldomain.com and point it to our host external IP, do the same for ns1.mycooldomain.com & ns2.mycooldomain.com

For .com domains godaddy says it takes 5-6 hours to process and up to 24h for .net so be patient.

Now we can go to the name servers section of the domain (mycooldomain.com) and add our own name servers we have created so add ns.mycoolserver.com & ns1.mycoolserver.com & ns2.mycooldomain.com

Third, config EHCP
Login admin account to EHCP and go to “Add DNS only” here we add the [domainname] we have setup at Godaddy “mycooldomain.com” and [serverip] our external IP then we save/send query.

IMPORTANT! MAKE SURE THAT PORT 53 IN YOUR ROUTER IS REDIRECTED TO YOUR LOCAL IP WHERE YOUR SERVER IS RUNNING.

BASIC PORTS we need to forward to our local IP:

– 20 TCP FTP – data transfer
– 21 TCP FTP – control (command)
– 25 TCP Simple Mail Transfer Protocol (SMTP)—used for e-mail routing between mail servers
– 53 TCP/UDP Domain Name System (DNS)
– 80 TCP/UDP Hypertext Transfer Protocol (HTTP)
– 143 TCP-UDP Imap protocol – Imap on port 143 is the newer of the two popular protocols used to retrieve eMail from remote mail servers.
– 443 TCP Hypertext Transfer Protocol (HTTPS)

Now we can register a domain from any registrar and add the name servers we provide: NS.MYCOOLDOMAIN.COM ECT then add the domain in the EHCP panel and that’s it!