Archive for April 10th, 2008

Using PHP - cPanel Tutorial Ch.6

What exactly is PHP?  It just happens to be the oldest and perhaps the most frequently used language on the web.  Many of the sites you view online are composed of PHP scripts.  PHP works with your cPanel to enhance the visual effects of your site among other things.  

One common function of PHP in regard to the cPanel is to create a CRON JOB.  Cron jobs are simply automated tasks that are executed over a Linux server, very much like SCHEDULED TASKS on a Windows server.  The purpose is to allow users to execute an important process without manually starting it every day.  Below is a perfect example:

Let’s just say that your website is hosting an auction.  It must operate on fixed period; something similar to what you find on Ebay.  We will use an example of five days here before the bidding ends.  So what happens when the bidding period has come to a close?  Your database will display a message letting visitors know that the auction has ended.  PHP cron jobs allow you to automatically restart the process in the event that no bids were made.

PHP scripts handle the maintenance of these functions.  They also allow you to execute cron jobs that run on preferred intervals. The user looking to operate several tasks on different schedules has the luxury of creating multiple cron jobs to manage them.

SETTING UP A CRON JOB

- First login into your cPanel
- click the cron jobs icon located towards the bottom of the main page
- Choose the time you want the PHP script to run.  For instance, selecting 30 means that your script will run for thirty minutes on whatever day and time you choose.
- Type in the command to run on the cPanel to load your scripts.  The command should resemble something like this:  /usr/local/bin/php -f /home/myusername/scripts/ascript.php.  

Take note that the first part of the command is your path to PHP.  The next part is the actual path to your file.  If this command does not work you should certainly inquire with your web hosting server to find what does.

PHP has many more functions as it relates to your cPanel.  Here is list of programs that are written in PHP scripts to liven your website.

- Create Custom Mailboxes Using cPanel - This multi named software was designed for email utilities.  It helps the user create dazzling automated email forms and creates eye catching mailboxes.

- Cpanelmail - PHP brings out the best in this reliable tool.  It allows the user to create an email account with ease.

- Super Web-Mail - This script allows you to implement your domain into an email account.  It also permits others to have their own accounts.  The password protected area allows you to maintain control while setting up contact info for the staff.

We previously learned that one of the many benefits of cPanel was its email features.  We now know that PHP scripts are a large part behind what makes the magic happen.


phpMyAdmin - cPanel Tutorial Ch.7

cPanel comes readily available on most web hosting servers you will run across these days.  One of its many functions is allowing users to manage their databases; this includes creating, modifying and even deleting tables.  There are a few things you will not be able to do such as retrieving selective backups, having the ability to backup only certain tables in a database or execute queries.  

This is where PHPMyAdmin comes in.  This user friendly application was designed to make the management of your website easy, in this case your web hosting server that runs with a cPanel.  PHPMyAdmin simplifies the process of maintaining your databases, specifically those scripted on MySQL.  

The PHPMyAdmin application is essentially composed of PHP scripts, the language of the web. 
The control it gives you over a database is remarkable.  PHPMyAdmin currently allows you to:

- create and drop a database
- create, copy and alter tables 
- delete, modify and create fields
- execute any database statement with the inclusion of batch queries
- load text into your tables
- import and export data
- administrate a primary database

ACCESSING PHPMyAdmin IN CPANEL

PHPMyAdmin can be accessed through the “Databases” panel of your website.  This will typically be labeled “MySQL”.  You should notice a link for PHPMyAdmin near the bottom of the page.  After clicking this you will now be able to maintain your databases.  Let’s go further into the process and detail how PHPMyAdmin will manage a database you plan to create.

- Create a MySQL user ID and password for whom ever will access to the database
- Click “Add User”
- Assign privileges to the user; they can alter, create, create temporary tables, delete, drop, select, insert, update, reference, index or lock tables.  In this instance we will check the “all” box.  
- Click “Add User To DB”
- Download the zipped config.inc.php file and extract the main component
- Open this in your text editor screen and modify the lines with your, IP address or web host and the username you created above
- Save the file and close the screen
- Go back and login in your cPanel
- Create a directory such as “phpmyadminstaff_html”
- Upload all your content into the directory you created

From there installation is complete and PHPMyAdmin can be used to effectively manage your database.  Be sure to add password protection the directory for security measures.

MORE ON PHPMYADMIN

The PHPMyAdmin application is widely used because of its actual interaction with the database.  This program is currently available in over fifty languages.  Since PHPMyAdmin is mainly configured for MySQL there are other versions that rival its function with cPanel.  PHPPGAdmin works similar to maintain databases of PostgreSQL.  PHPMSAdmin is designed to manage Microsoft SQL Servers.  While it has many of the same capabilities it includes no actual codes from the PHPMyAdmin application.  The closest tool in resemblance would be PHPMinAdmin.  This includes all the most crucial features of PHPMyAdmin but is composed of only one PHP file.

PHPMyAdmin typically comes free with most web hosting servers.


MySQL Database - cPanel Tutorial Ch.8

MySQL is a multi-function, multi-user database management system.  With well over 10 million installations it is without doubt the most widely used system of its kind.  Its basis is to operate as a server and provide access to databases for a number of simultaneous users, the reason it has been so popular for web hosting companies.  

MySQL has been used as a very reliable component for Linux, Mac, Windows and Apache servers.  It’s benefits towards web applications relates closely with the language of PHP.  We previously learned how PHPMyAdmin can enhance the MySQL database.  MySQL works with powerful content management systems such as Joomla and Mambo and blogging platforms such Drupal and WordPress.  It also manages the databases of several other web applications written in PHP scripts. 

ANOTHER BENEFIT OF MYSQL 

Since we already learned how to create a database and configure it for PHPMyAdmin we will now further discuss other benefits of a MySQL database.  

Automatic MySQL Backups

Blogs, message forums and other online communities have never been easier to create.  As more web hosting servers implement Fantastico in their cPanel, other applications are able to be attached with enhanced overall features.  Everything seems clear on the surface until the term “backup” is mentioned.

The uniformed user will not think much of this, firmly believing that their web host will handle the procedures of backing up information.  Though this is mostly fact, some hosting servers will clearly explain that they cannot give a one hundred percent guarantee when it comes to the limit of corruption or the quality of their back system.

Users who are lucky enough to have a cPanel with their web hosting have it a bit easier.  MySQL allows you to manage your database from A to Z, giving you the power to backup your information in case of technical difficulty.  

Here is a simple way to back up your database with MySQL:

- Navigate to “Cron Jobs” from the main page of your cPanel and click the icon.  You will be then be prompted with these options: 

Minutes: This explains how many minutes a script will run
Hour: This represents what time of day the script will run
Day: This details how many days per week the script will run
Month: This determines if a script is to run on a particular month

Next should be a command option.  After filling in the fields, the text inside the box should read something like this.  

mysqldump –opt -Q -u dbusername –password=dbpassword dbname > /pathto/backups/sunday.sql

Changes will need to be made with the command prompt to correspond to your information.  In this instance we would replace the variables in red.  

From here you will repeat the first script six times over but modify the weekdays.  This will go from 0 all the way up to 6.  You will also change the file name from Sunday to Monday and so forth until reaching Saturday.

Even standing on its own MySQL is a very powerful application that brings out the best in your cPanel.


htaccess for Password Protection - cPanel Tutorial Ch.9

Hypertext Access or htaccess was originally created as a default name of the Apache server directory configuration file.  Its purpose is to provide the power to customize directories of a server’s primary configuration file.  These directives are all required to be in .htaccess context and can only be used with the correct command lines.  The .htaccess file controls not only the directories it was created in, but all subdirectories within it as well.

As one of the most effective configuration files, htaccess is rather critical to your website.  Keep in mind that the most minimal syntax error, such as an omitted space, can result in the malfunction of your server.  It is very critical to use MySQL or PHPMyAdmin to backup your website, this includes any original .htaccess files.  Any changes that need to be made to .htaccess can easily be made within your cPanel.  We will get to that a little later.

When it comes to using the .htaccess file, options within your web hosting server seem unlimited.  With great power also comes great responsibility and risks.  By making one small mistake with the .htaccess file you run the chance of making your whole site dysfunctional.  The best way to manage your .htaccess files is certainly through the cPanel.  Your advanced administrative area will write the files out for you and is typically a safer method opposed to editing them on your own.

Many benefits come along with the .htaccess file, but protection is perhaps its most famed area.  
Password protecting your directories and website can be done several ways yet is easily managed by way of the cPanel. Here is a perfect example:

- First log into your cPanel
- You will then find the htacess/htpassword creator tool on the page.  From there you will create a username and password you would like to use for the designated directory.  
- Click on the “create file” tab
- You will then create two files, .htaccess and htpasswd

The first box on the tool page will then read something like this:

AuthName “Password Protected Directory”
AuthType Basic
AuthUserFile /your/server/path/.htpasswd
require valid-user

The AuthName field is something that may be changed as this will translate a prompt that asks for a user’s credentials.  You may wish to type in “You Must Be Logged In To Do That” or “Password Protected Area”.  You must change the AuthUserFile path and assure that the modified location is placed above the documentroot.  Refer to the example below.  

/home/username/www/secure/ - secure folder
/http://www.domain.com/secure/ - accessing domain
/home/username/www/ - where all files are served from
/htpassword: /home/username/passwords/ - the storing of our password

This is how our .htaccess file would now translate:

AuthName “Password Protected Directory”
AuthType Basic
AuthUserFile /home/username/passwords/.htpasswd
require valid-user

From the second box of the page you will copy then paste this code into the new htpasswd file.  This normally takes no longer than two to three minutes to complete after the first trial, a fairly simple process that adds great protection for your website.


htaccess Blocking - cPanel Tutorial Ch.10

Apache web hosting servers have designed a number of configuration tools to assist the user in administrating their site.  Few of them have more purpose and functions than the little file by the name of .htaccess.  This file is powerfull when changes are made within it, giving users the freedom to override default functions of their web hosting server.

As a mere ASCII text file htaccess can be evolved to perform many operations.  We previously learned that this file can password protect the directories of your website.  It also has the ability to redirect users to a different location or block IP’s or certain domains.  

WHY BLOCK WITH .HTACCESS?

There is an endless amount of sites hosting blogs and member forums on the net.  These websites are frequently targeted by an equal amount of computer hackers and spammers.  Coming up with a solution to this never ending problem has been ongoing since the internet’s introduction. .Htaccess is great tool that limits this activity and gives you a bit more privacy.

You may have observed the fact there is no prefix for this file; it simply starts with a period and is then followed by the letters htaccess.  This means that it will typically be stored as a hidden system file.  Hidden system files can easily be unveiled via the manager page of your cPanel.  Since not all web hosting servers will allow the use of .htaccess, it is certainly best to check company regulations before proceeding.

HTACCESS vs THE CPANEL

While .htaccess files can be activated in via your cPanel there has been a debate on whether you should use them or not.  Being that .htaccess is such a sensitive file that could inadvertently shutdown a website it should only be used when absolutely required.  The IP Deny Manager feature of cPanel was one designed to work similar to .htaccess.   

Just like .htaccess the IP Deny Manager allows users to block IP addresses and domains from entering your website.  If there is an IP address or domain you wish to block from your website it can simply done within the cPanel:

- First log into the cPanel account
- Find the “site management” tab and click “IP Deny Manager”
- Locate “Add IP Deny” then type in the address you have chosen to block
- Click the “Add” button

From there your IP Deny Manager has been set.  The online hecklers you have singled out will never have access to your site again unless you choose to lift the ban.  Your htaccess file helps in the removal process, or you can simply select the IP from a drop down page in the IP Deny Manager and manually lift the ban.   
One of the main reasons you may want to block an IP is due to the content of your site being stolen.  While the .htaccess file is a great way to prevent this activity, the cPanel also has a reliable feature that works on its own in the IP Deny Manager.


« Prev - Next »