Author: admin

DSO (mod_php) vs. CGI vs. suPHP vs. FastCGI

What are PHP handlers

In order to run a PHP site, the server must interpret the PHP code and generate a page when visitors access the website. It interprets the code based on which PHP library you are using, such as PHP 4 or PHP 5. A PHP handler is what actually loads the libraries so that they can be used for interpretation. PHP handlers determine how PHP is loaded on the server.

There are multiple different handlers that can be used for loading PHP: CGI, DSO, suPHP, & FastCGI. Each handler delivers the libraries through different files and implementations. Each file and implementation affects Apache’s performance, because it determines how Apache serves PHP.

It is critical for your server’s performance that you select the handler that fits your situation. Selecting the right handler is just as important as the PHP version itself. One handler is not necessarily always better than another; it depends on your unique setup. What caching do you need, what modules do you need, etc…

  • Note: You may assign different PHP handlers to different versions of PHP. For example, version 5 may be handled by CGI while PHP 4 is handled by DSO.

How to change the handler

Changing the handler on cPanel is very easy to do and only takes seconds. Log into WHM and navigate to: Main >> Service Configuration >> Configure PHP and SuExec

You simply select your PHP handler choice from the drop-down menu. Then hit “Save New Configuration”.

  • Note: If you do not see your desired choice in the drop-down menu, it may need to be compiled on the server first. Run an “Easy Apache” to compile it.

List of PHP handlers

DSO (mod_php)

DSO is also known as mod_php. DSO stands for: Dynamic Shared Object. This is an older configuration but is generally considered the fastest handler. It runs PHP as an Apache module. This means that PHP scripts will run as the Apache user, which is the user: ‘nobody’.

DSO has two drawbacks. First, all files created by a PHP script will have the ownership of ‘nobody’. They will not be readable from the web. Websites that need to upload files through PHP will run into file permission issues. This is common with WordPress users that upload files through the WordPress interface or utilize the auto-update feature. These will fail with DSO.

The second drawback is a security issue. Created files will have the ‘nobody’ ownership. If a hacker finds an exploit in your PHP script, they could implement a file that has the same privileges as important system files that are also owned by ‘nobody’. This will give them the ability to modify files outside of that user’s account. This is really bad for anyone who does reselling or simply is hosting other person’s sites. You would not one user to be able to affect another user. However, if there is only one account on the server (or if all the accounts are yours), then DSO may be right for you. The speeds benefits of DSO are unquestionable.

An easy way to prevent the hack issue is to always keep your site’s software up to date. Check with your PHP script’s developer to keep up on the new releases. If you are the only one being hosted on the server, this is easy to do as it’s part of your webmaster duties already. However, if you’re reselling, it would be unreasonable to expect all your user’s to keep their software up to date. They simply may not be as diligent as you.

DSO’s low CPU usage typically amounts in higher speeds and load times over most other handlers. It is also the default setting on most servers.

CGI

CGI stands for: Common Gateway Interface. The CGI handler will run PHP as a CGI module as opposed to an Apache module. CGI still runs PHP processes as the Apache ‘nobody’ user. However, if you have suEXEC enabled, it will allow you to see the user that made the request.

The CGI method is intended as a fallback handler for when DSO is not available. According to cPanel’s own documentation, this method is neither fast nor secure, regardless of whether or not suEXEC is enabled.

http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/MorePhphandlers

suPHP

suPHP stands for Single user PHP. suPHP also runs PHP as a CGI module instead of an Apache module. It differs from CGI in that PHP scripts that are called from the web will run under the user that owns them, as opposed to ‘nobody’. suPHP is typically the default handler and is recommended by cPanel for serving PHP because you will be able to see which user owns the account that is running the PHP script.

suPHP is beneficial in that if you are using a file upload tool on your site (such as an automatic updater or theme/plug-in installer for WordPress), the files will already have the right ownership & permissions. Uploading and other WordPress functions will not work without suPHP or FastCGI.

suPHP also offers a security advantage that any php script that is not owned by the particular user (such as another account or root) will not be executable. Also, files that have permissions set to world writeable will likewise be non-executable. This means that if one account is compromised, the malicious scripts will not be able to infect other accounts.

The drawback is that suPHP generally runs a much higher CPU load. In addition, you CANNOT use an Opcode Cache (such as Xcache or APC) with suPHP. It is strongly recommend that you install a caching plug-in to supplement this ned. If you find that your server is still continually struggling with CPU usage, you will want to consider switching to DSO or FastCGI.

FastCGI

FastCGI (aka: mod_fcgid or FCGI) is a high performance variation of CGI. It has the security/ownership benefits of suPHP in that PHP scripts will run as the actual cPanel user as opposed to ‘nobody’. The difference with FastCGI is that it can drastically save on CPU performance and give speeds close to that of DSO. It can also be used with an opcode cacher like eAccelerator or APC, which can help further speed the loading of pages.

The drawback is FastCGI has a high memory usage. This is because rather than creating the PHP process each time it is called, like suPHP, it keeps a persistent session open in the background. This is what lets it work with an opcode caching software.

If you like the security/ownership benefits of suPHP and you can afford a major increase in memory usage (meaning you already have a low average memory usage), you may wish to consider using FastCGI.

Comparison Graph

DSO CGI SuPHP FastCGI
Low CPU usage
Low Memory consumption
Runs PHP as site owner instead of Apache

only w/ suEXEC
Good security
Click to rate this post!
[Total: 1 Average: 5]

Modificare nameservere ROTLD

1. Pentru inceput trebuie sa accesati pagina web a RoTLD la adresa www.rotld.ro.

2.  In partea stanga veti gasi in meniu optiunea ” Administrare domenii ” iar sub aceasta, “On Line” . Click pe ” On Line “.

3. In careul ” Nume Domeniu” , introduceti numele domeniului pe care doriti sa-l configurati. In careul ” Parola ” introduceti parola aferenta. (daca nu o cunoasteti, folositi functia de Recuperare Parola). Introduceti codul anti-spam din imaginea alaturata si apasati Continua.

4. Odata logat, apasati ” Nameservers “. In partea de jos veti gasi ” Pentru a Crea/Modifica/Şterge un nameserver pe domeniul părinte numedomeniu.ro (Ex: ns.numedomeniu.ro) vă rugăm să accesaţi formularul. “. Click pe link-ul “Formularul”.

5. Odata ce ati ajuns in aceasta pagina, introduceti ns1 in careul ” Nume Server ” iar  la ” Adresa IP a Server-ului ” adresa IP oferita de furnizorul de web hosting, dupa care apasati “Creeaza Nameserver”. Introduceti din nou in careul ” Nume Server ” de data aceasta ns2 iar la ” Adresa IP a Server-ului ” adresa aferenta pentru al doilea server DNS oferit de compania de web hosting. La sfarsit, apasati din nou “Creeaza Nameserver”.

6. Apasati din nou Nameservers (in meniul de sus) dupa care in primul careu de sus introduceti ns1.numedomeniu.ro iar in a doua ns2.numedomeniu.ro (evident inlocuiti numedomeniu.ro cu domeniul dumneavoastra). In final apasati “Actualizeaza”.

7. Pentru a verifica daca setarile au fost aplicate, click din nou pe link-ul continut de cuvantul formularul, amplasta in subsolul paginii. Careurile Nameservers si Adresa IP trebuie sa fie de culoare roz.

8. Apasati Iesire (in meniul de sus) pentru a va deloga.

Daca setarile au fost realizate corect, in maxim 24 ore veti avea domeniul perfect functional din orice punct al Internetului.

Click to rate this post!
[Total: 4 Average: 5]

Linux Directory Structure

Linux Directory Structure

Each of the above directory (which is a file, at the first place) contains important information, required for booting to device drivers, configuration files, etc. Describing briefly the purpose of each directory, we are starting hierarchically.

  1. /bin : All the executable binary programs (file) required during booting, repairing, files required to run into single-user-mode, and other important, basic commands viz., cat, du, df, tar, rpm, wc, history, etc.
  2. /boot : Holds important files during boot-up process, including Linux Kernel.
  3. /dev : Contains device files for all the hardware devices on the machine e.g., cdrom, cpu, etc
  4. /etc : Contains Application’s configuration files, startup, shutdown, start, stop script for every individual program.
  5. /home : Home directory of the users. Every time a new user is created, a directory in the name of user is created within home directory which contains other directories like Desktop, Downloads, Documents, etc.
  6. /lib : The Lib directory contains kernel modules and shared library images required to boot the system and run commands in root file system.
  7. /lost+found : This Directory is installed during installation of Linux, useful for recovering files which may be broken due to unexpected shut-down.
  8. /media : Temporary mount directory is created for removable devices viz., media/cdrom.
  9. /mnt : Temporary mount directory for mounting file system.
  10. /opt : Optional is abbreviated as opt. Contains third party application software. Viz., Java, etc.
  11. /proc : A virtual and pseudo file-system which contains information about running process with a particularProcess-id aka pid.
  12. /root : This is the home directory of root user and should never be confused with ‘/
  13. /run : This directory is the only clean solution for early-runtime-dir problem.
  14. /sbin : Contains binary executable programs, required by System Administrator, for Maintenance. Viz.,iptables, fdisk, ifconfig, swapon, reboot, etc.
  15. /srv : Service is abbreviated as ‘srv‘. This directory contains server specific and service related files.
  16. /sys : Modern Linux distributions include a /sys directory as a virtual filesystem, which stores and allows modification of the devices connected to the system.
  17. /tmp :System’s Temporary Directory, Accessible by users and root. Stores temporary files for user andsystem, till next boot.
  18. /usr : Contains executable binaries, documentation, source code, libraries for second level program.
  19. /var : Stands for variable. The contents of this file is expected to grow. This directory contains log, lock,spool, mail and temp files.

Exploring Important file, their location and their Usability

Linux is a complex system which requires a more complex and efficient way to start, stop, maintain and reboota system unlike Windows. There is a well defined configuration files, binaries, man pages, info files, etc. for every process in Linux.

  1. /boot/vmlinuz : The Linux Kernel file.
  2. /dev/hda : Device file for the first IDE HDD (Hard Disk Drive)
  3. /dev/hdc : Device file for the IDE Cdrom, commonly
  4. /dev/null : A pseudo device, that don’t exist. Sometime garbage output is redirected to /dev/null, so that it gets lost, forever.
  5. /etc/bashrc : Contains system defaults and aliases used by bash shell.
  6. /etc/crontab : A shell script to run specified commands on a predefined time Interval.
  7. /etc/exports : Information of the file system available on network.
  8. /etc/fstab : Information of Disk Drive and their mount point.
  9. /etc/group : Information of Security Group.
  10. /etc/grub.conf : grub bootloader configuration file.
  11. /etc/init.d : Service startup Script.
  12. /etc/lilo.conf : lilo bootloader configuration file.
  13. /etc/hosts : Information of Ip addresses and corresponding host names.
  14. /etc/hosts.allow : List of hosts allowed to access services on the local machine.
  15. /etc/host.deny : List of hosts denied to access services on the local machine.
  16. /etc/inittab : INIT process and their interaction at various run level.
  17. /etc/issue : Allows to edit the pre-login message.
  18. /etc/modules.conf : Configuration files for system modules.
  19. /etc/motd : motd stands for Message Of The Day, The Message users gets upon login.
  20. /etc/mtab : Currently mounted blocks information.
  21. /etc/passwd : Contains password of system users in a shadow file, a security implementation.
  22. /etc/printcap : Printer Information
  23. /etc/profile : Bash shell defaults
  24. /etc/profile.d : Application script, executed after login.
  25. /etc/rc.d : Information about run level specific script.
  26. /etc/rc.d/init.d : Run Level Initialisation Script.
  27. /etc/resolv.conf : Domain Name Servers (DNS) being used by System.
  28. /etc/securetty : Terminal List, where root login is possible.
  29. /etc/skel : Script that populates new user home directory.
  30. /etc/termcap : An ASCII file that defines the behaviour of Terminal, console and printers.
  31. /etc/X11 : Configuration files of X-window System.
  32. /usr/bin : Normal user executable commands.
  33. /usr/bin/X11 : Binaries of X windows System.
  34. /usr/include : Contains include files used by ‘c‘ program.
  35. /usr/share : Shared directories of man files, info files, etc.
  36. /usr/lib : Library files which are required during program compilation.
  37. /usr/sbin : Commands for Super User, for System Administration.
  38. /proc/cpuinfo : CPU Information
  39. /proc/filesystems : File-system Information being used currently.
  40. /proc/interrupts : Information about the current interrupts being utilised currently.
  41. /proc/ioports : Contains all the Input/Output addresses used by devices on the server.
  42. /proc/meminfo : Memory Usages Information.
  43. /proc/modules : Currently using kernel module.
  44. /proc/mount : Mounted File-system Information.
  45. /proc/stat : Detailed Statistics of the current System.
  46. /proc/swaps : Swap File Information.
  47. /version : Linux Version Information.
  48. /var/log/lastlog : log of last boot process.
  49. /var/log/messages : log of messages produced by syslog daemon at boot.
  50. /var/log/wtmp : list login time and duration of each user on the system currently.
Click to rate this post!
[Total: 0 Average: 0]

w3-total-cache optimal settings

Configuring W3 Total Cache – General Settings

 

W3 Total Cache creates a new menu entry called Performance in WordPress dashboard. The options that we’re looking for are under Performance > General. You’ll notice that this page has an overwhelming number of settings for a caching plugin (and a whole lot more if you’re into advanced stuff). Each setting is placed inside a box – called modules. I’ve discussed each of these modules with relevant screenshots. If you get stuck or are uncertain about a particular setting, simply follow the screenshots.

W3 total cache general settings module

The first module you’ll find is General. I’d recommend not to enable the all the caching options using the toggle checkbox. You might turn on settings that aren’t required (or even supported by) your host – which would inadvertently slow down your website. However, if you want to quickly disable all the modules, this toggle checkbox comes in handy! Before we proceed further, if you’re unfamiliar with the terms ‘page cache’ or ‘database cache’, I would recommend readingHow WordPress Caching Works.

Page Cache Module

W3 total cache page cache

The second module we’re going to configure is Page Cache. The Page cache method depends on your hosting environment. If you’re using a shared host, Disk: Enhanced is the best option. However, if you’re using a dedicated or virtual server and you have APC (or any other form of Opcode caching installed), you should select the respective option.

Minify Module

W3 total cache minify module

The Minify module compresses the CSS and JavaScript files your theme uses, by removing unnecessary lines of code like comments and whitespaces. This reduces the filesize by ~10% which results in a faster site. Under Minify cache method you should select the appropriate option based on your server.

Other Caching Modules

W3 total cache object cache

The next two modules are Database Cache and Object Cache. Enable each of them and change their caching method to the one best fit to your hosting environment – just like you did underPage Cache and Minify.

W3 total cache browser cache

The last module that we want to enable is Browser Cache. Once you’ve enabled them, click onSave all Settings. That should do it! W3 Total Cache is now enabled in your server. We will now take an in-depth look into two specific modules – Page Cache and Browser Cache. The rest of the modules’ default values are just fine.

Page Cache Settings

w3 total cache advanced settings - page cache

The Page Cache settings can be found under Performance > Page Cache. The settings here are fairly self explanatory. I’ve enabled a couple of them – specially Don’t cache pages for the following user roles. This ensures that when an author is editing a post, he/she will able to view the latest version and not the one from the cache.

Preloading the Cache

 

seconds
The number of seconds to wait before creating another set of cached pages.

Limit the number of pages to create per batch. Fewer pages may be better for under-powered servers.

A compliant sitemap can be used to specify the pages to maintain in the primed cache. Pages will be cached according to the priorities specified in the XML file. Due to its completeness and integrations, WordPress SEO is recommended for use with this feature.

By default, W3 Total Cache caches a page when it is first requested. You also have the option to pre-generate copies of all the posts/pages. This way, regardless of when a visitor requests a page, the cache is ready and the page is served in the lowest possible time.

You should configure the cache preload settings based on your hosting environment and the amount of traffic your website receives.

  • The cache Update interval directly affects server resources – lower the time interval (i.e. higher the frequency), greater the server resource consumed. People on shared hosting servers should be very careful with this setting. Set a high enough frequency and you might just get your account suspended for abuse of server resources. A safe cache preload interval is one hour – i.e. 3600 seconds.
  • If you’re unfamiliar with the Sitemap URL, install Google XML Sitemaps. It’s super easy to use and is in fact, a must-have plugin.
  • Finally, you want to enable the last option which will trigger a cache preload operation when a post/page is published.

Browser Cache Settings

w3 total cache advanced settings - browser cache

Click to rate this post!
[Total: 1 Average: 5]

wp-super-cache without compression optimal settings

Step a. Set General Settings

  1. Check box next to “Cache hits to this website…”
  2. Select button next to “Expert”
  3. Check box next to “304 Not Modified browser caching”
  4. Check box next to “Don’t cache pages for known users”
  5. “Cache rebuild” & “Extra homepage checks” should already be checked, leave them that way.
  6. Check box next to Mobile device support. (External plugin or theme required. See the FAQ for further details.)
  7. (Recommended)
  8. Select “Update Status” button.

Step b. Set Mod_Rewrite Rules

  1.  Select “Update Mod_Rewrite Rules” in the yellow box.

Step c. Set Garbage Collection

  1. “Expiry Time & Garbage Collection” and enter “3600” in the box, then select “Change Expiration”

Step d. Under tab Preload set:

Refresh preloaded cache files every minutes. (0 to disable, minimum 30 minutes.)

Preload mode (garbage collection only on legacy cache files. Recommended.)
Preload tags, categories and other taxonomies.
Send me status emails when files are refreshed.
Many emails, 2 emails per 100 posts.
Medium, 1 email per 100 posts.
Less emails, 1 at the start and 1 at the end of preloading all posts.

 

Explanation of the Options Selected

Cache hits to this website…

Enables caching

Use mod_rewrite to serve cache files

Fastest caching method, uses mod_rewrite rules in client’s .htaccess file

 

304 Not Modified browser caching

Indicates to the client’s browser whether a requested file has been modified or not (see: http://www.addedbytes.com/for-beginners/http-status-codes/ or elsewhere for more info on that apache code)

Don’t cache pages for known users

This prevents logged-in users from being served cached pages and is the default for almost every caching plugin out there.

Expiry Time & Garbage Collection

The default setting will allow cache files to age 1 hour (3600 seconds) prior to being removed which is ideal. This setting can be increased for sites that do not have many posts (1,000 or less ) if you do not update your content often. If you have a very large amount of posts ( 25,000+ ), a lower setting around 1800 may be more viable to prevent stat/CPU issues due to the amount of files being created.

Rejected User Agents

It is recommended that you do not remove the default user agents from the list, to prevent bots from caching content and pages not normally seen by your visitors. (For example, if you have a calendar, a real visitor may only browse months close to now, but a bot will index every month forever as if it is a different page. Caching these pages real visitors are unlikely to visit wastes resources.)

 

Click to rate this post!
[Total: 0 Average: 0]

Linux timezone setup

For Debian:

dpkg-reconfigure tzdata

For Centos:

Example:

mv /etc/localtime /etc/localtime.old; ln -s /usr/share/zoneinfo/Europe/Bucharest /etc/localtime

Click to rate this post!
[Total: 0 Average: 0]