Wednesday, 10 February 2016

Solutions to Common MySQL Problems

MySQL is one of the most popular database engines, and with good reason. Once configured properly, it can help connect thousands of databases to servers and do so at relatively low cost. Plus, since it’s such a common tool, you’re unlikely to run into issues where servers don’t recognize it or you can’t get help configuring it to do what you want it to do. Sometimes, though, you will run into errors–especially configuration errors–that can be frustrating or confusing. If you’re having a hard time with MySQL, you may be running into one of these common problems.
Problem #1: High disk usage. Some MySQL users find that as they expand their operations, using MySQL for a large number of databases, it begins to take up too much disk space. Servers begin looking for data on different parts of the disk at the same time, which can slow or completely halt disk operation.

Solution: Configure MySQL to work mainly with memory, not disks.MySQL takes up far less memory than it does disk space, so the more you can get it to use your computers’ RAM instead of looking for data on disks, the more smoothly it will run. In particular, MySQL can be configured to use available RAM whenever possible and to put temporary tables in memory instead of on hard disks. If you have RAM available on your servers, this solution should speed things up. Just remember that the more databases you have, the more memory MySQL will need.
Problem #2: Losing connection to the server. If MySQL loses its connection to the server in the middle of data transfers, it will generate error messages instead of transferring the data as needed. This can be the result of a network problem, so your first step is always to check your network connections. If this problem occurs frequently, however, you may need to reconfigure MySQL.
Solution: Lost connections often happen because MySQL is configured to time out after only 30 seconds, which may not be enough time for large data transfers. Try configuring net_read_timeout to 60 seconds or longer. If you are timing out on initial connect, reconfigure connect_timeout to at least 10 seconds. This often happens if your connection is slow, so consider upgrading your network to connect faster as well.
Problem #3: Getting a “too many connections” error. As you expand your operations, you may need more computers to be able to connect to MySQL. If you don’t reconfigure MySQL, it will refuse some of these connections and generate a “too many connections” error message.
Solution: Reconfigure MySQL to accept more connections. To do this, change your max_connections variable. The default is 151; you can set it to whatever number accommodates the number of connections you need. You may also need to increase your open_files_limit to accommodate the number of connections open on your server at the same time.

How to install OpenERP 7.0 on Ubuntu 12.04 LTS

Introduction

Welcome to the latest of our very popular OpenERP installation “How Tos”.
The new release of OpenERP 7.0 is a major upgrade and a new Long Term Support release; the 7.0 Release Notes extend to over 90 pages! The most noticeable change is a complete re-write of the User Interface that features a much more modern look and feel.

OpenERP 7.0 is not only better looking and easier to use, it also brings many improvements to the existing feature-set and adds a number of brand new features which extend the scope of the business needs covered by OpenERP. Integration of social network capabilities, integration with Google Docs and LinkedIn, new Contract Management, new Event Management, new Point of Sale, new Address Book, new Fleet Management,… are only some of the many enhancements in OpenERP 7.0.

The How To

Following that introduction, I bet you can’t wait to get your hands dirty…
Just one thing before we start: You can simply download a “.deb” package of OpenERP and install that on Ubuntu. Unfortunately that approach doesn’t provide us (Libertus Solutions) with enough fine-grained control over where things get installed, and it restricts our flexibility to modify & customise, hence I prefer to do it a slightly more manual way (this install process below should only take about 10-15 minutes once the host machine has been built).
So without further ado here we go:

Step 1. Build your server

I install just the bare minimum from the install routine (you may want to install the openssh-server during the install procedure or install subsequently depending on your needs).
After the server has restarted for the first time I install the openssh-server package (so we can connect to it remotely) and denyhosts to add a degree of brute-force attack protection. There are other protection applications available: I’m not saying this one is the best, but it’s one that works and is easy to configure and manage. If you don’t already, it’s also worth looking at setting up key-based ssh access, rather than relying on passwords. This can also help to limit the potential of brute-force attacks. [NB: This isn’t a How To on securing your server…]
sudo apt-get install openssh-server denyhosts
Now make sure your server has all the latest versions & patches by doing an update:
sudo apt-get update
sudo apt-get dist-upgrade
Although not always essential it’s probably a good idea to reboot your server now and make sure it all comes back up and you can login via ssh.
Now we’re ready to start the OpenERP install.

Step 2. Create the OpenERP user that will own and run the application

sudo adduser --system --home=/opt/openerp --group openerp
This is a “system” user. It is there to own and run the application, it isn’t supposed to be a person type user with a login etc. In Ubuntu, a system user gets a UID below 1000, has no shell (it’s actually /bin/false) and has logins disabled. Note that I’ve specified a “home” of/opt/openerp, this is where the OpenERP server code will reside and is created automatically by the command above. The location of the server code is your choice of course, but be aware that some of the instructions and configuration files below may need to be altered if you decide to install to a different location.
[Note: If you want to run multiple versions of OpenERP on the same server, the way I do it is to create multiple users with the correct version number as part of the name, e.g. openerp70, openerp61 etc. If you also use this when creating the Postgres users too, you can have full separation of systems on the same server. I also use similarly named home directories, e.g. /opt/openerp70, /opt/openerp61 and config and start-up/shutdown files. You will also need to configure different ports for each instance or else only the first will start.]
A question I have been asked a few times is how to run the OpenERP server as the openerp system user from the command line if it has no shell. This can be done quite easily:
sudo su - openerp -s /bin/bash
This will su your current terminal login to the openerp user (the “-” between su and openerp is correct) and use the shell /bin/bash. When this command is run you will be in openerp’s home directory: /opt/openerp.
When you have done what you need you can leave the openerp user’s shell by typing exit.

Step 3. Install and configure the database server, PostgreSQL

sudo apt-get install postgresql
Then configure the OpenERP user on postgres:
First change to the postgres user so we have the necessary privileges to configure the database.
sudo su - postgres
Now create a new database user. This is so OpenERP has access rights to connect to PostgreSQL and to create and drop databases. Remember what your choice of password is here; you will need it later on:
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp
Enter password for new role: ********
Enter it again: ********
Finally exit from the postgres user account:
exit

Step 4. Install the necessary Python libraries for the server

sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata \
python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid \
python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing \
python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject \
python-webdav python-werkzeug python-xlwt python-yaml python-zsi
With that done, all the dependencies for installing OpenERP 7.0 are now satisfied (note that there are some new packages required since 6.1).

Step 5. Install the OpenERP server

I tend to use wget for this sort of thing and I download the files to my home directory.
Make sure you get the latest version of the application: at the time of writing this it’s 7.0. I got the download links from their download pages(note there are also debrpm and exe builds in this area too). There isn’t a static 7.0 release tarball as such anymore, but there is a nightly build of the 7.0 source tree which should be just as good and will contain patches as and when things get fixed. The link below is to the source tarball for the 7.0 branch.
Note: As an alternative method of getting the code onto your server, Jerome added a very useful comment showing how to get it straight from launchpad. Thanks!
wget http://nightly.openerp.com/7.0/nightly/src/openerp-7.0-latest.tar.gz
Now install the code where we need it: cd to the /opt/openerp/ directory and extract the tarball there.
cd /opt/openerp
sudo tar xvf ~/openerp-7.0-latest.tar.gz
Next we need to change the ownership of all the the files to the OpenERP user and group we created earlier.
sudo chown -R openerp: *
And finally, the way I have done this is to copy the server directory to something with a simpler name so that the configuration files and boot scripts don’t need constant editing (I called it, rather unimaginatively, server). I started out using a symlink solution, but I found that when it comes to upgrading, it seems to make more sense to me to just keep a copy of the files in place and then overwrite them with the new code. This way you keep any custom or user-installed modules and reports etc. all in the right place.
sudo cp -a openerp-7.0 server
As an example, should OpenERP 7.0.1 come out soon, I can extract the tarballs into /opt/openerp/ as above. I can do any testing I need, then repeat the copy command so that the modified files will overwrite as needed and any custom modules, report templates and such will be retained. Once satisfied the upgrade is stable, the older 7.0 directories can be removed if wanted.
That’s the OpenERP server software installed. The last steps to a working system is to set up the configuration file and associated boot script so OpenERP starts and stops automatically when the server itself stops and starts.

Step 6. Configuring the OpenERP application

The default configuration file for the server (in /opt/openerp/server/install/) is actually very minimal and will, with only one small change work fine so we’ll simply copy that file to where we need it and change it’s ownership and permissions:
sudo cp /opt/openerp/server/install/openerp-server.conf /etc/
sudo chown openerp: /etc/openerp-server.conf
sudo chmod 640 /etc/openerp-server.conf
The above commands make the file owned and writeable only by the openerp user and group and only readable by openerp and root.
To allow the OpenERP server to run initially, you should only need to change one line in this file. Toward to the top of the file change the linedb_password = False to the same password you used back in step 3. Use your favourite text editor here. I tend to use nano, e.g.
sudo nano /etc/openerp-server.conf
One other line we might as well add to the configuration file now, is to tell OpenERP where to write its log file. To complement my suggested location below add the following line to the openerp-server.conf file:
logfile = /var/log/openerp/openerp-server.log
Once the configuration file is edited and saved, you can start the server just to check if it actually runs.
sudo su - openerp -s /bin/bash
/opt/openerp/server/openerp-server
If you end up with a few lines eventually saying OpenERP is running and waiting for connections then you are all set.
On my system I noticed the following warning:
2012-12-19 11:53:51,613 6586 WARNING ? openerp.addons.google_docs.google_docs: Please install latest gdata-python-client from http://code.google.com/p/gdata-python-client/downloads/list
The Ubuntu 12.04 packaged version of the python gdata client library is not quite recent enough, so to install a more up-to-date version I did the following (exit from the openerp user’s shell if you are still in it first):
sudo apt-get install python-pip
sudo pip install gdata --upgrade
Going back and repeating the commands to start the server resulted in no further warnings
sudo su - openerp -s /bin/bash
/opt/openerp/server/openerp-server
If there are errors, you’ll need to go back and find out where the problem is.
Otherwise simply enter CTL+C to stop the server and then exit to leave the openerp user account and go back to your own shell.

Step 7. Installing the boot script

For the final step we need to install a script which will be used to start-up and shut down the server automatically and also run the application as the correct user. There is a script you can use in /opt/openerp/server/install/openerp-server.init but this will need a few small modifications to work with the system installed the way I have described above. Here’s a link to the one I’ve already modified for 7.0.
Similar to the configuration file, you need to either copy it or paste the contents of this script to a file in /etc/init.d/ and call it openerp-server. Once it is in the right place you will need to make it executable and owned by root:
sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server
In the configuration file there’s an entry for the server’s log file. We need to create that directory first so that the server has somewhere to log to and also we must make it writeable by the openerp user:
sudo mkdir /var/log/openerp
sudo chown openerp:root /var/log/openerp

Step 8. Testing the server

To start the OpenERP server type:
sudo /etc/init.d/openerp-server start
You should now be able to view the logfile and see that the server has started.
less /var/log/openerp/openerp-server.log
If there are any problems starting the server you need to go back and check. There’s really no point ploughing on if the server doesn’t start…

OpenERP 7 Database Management Screen
If the log file looks OK, now point your web browser at the domain or IP address of your OpenERP server (or localhost if you are on the same machine) and use port 8069. The url will look something like this:
http://IP_or_domain.com:8069
What you should see is a screen like this one (it is the Database Management Screen because you have no OpenERP databases yet):
What I do recommend you do at this point is to change the super admin password to something nice and strong (Click the “Password” menu). By default this password is just “admin” and knowing that, a user can create, backup, restore and drop databases! This password is stored inplain text in the /etc/openerp-server.conf file; hence why we restricted access to just openerp and root. When you change and save the new password the /etc/openerp-server.conf file will be re-written and will have a lot more options in it.
Now it’s time to make sure the server stops properly too:
sudo /etc/init.d/openerp-server stop
Check the logfile again to make sure it has stopped and/or look at your server’s process list.

Step 9. Automating OpenERP startup and shutdown

If everything above seems to be working OK, the final step is make the script start and stop automatically with the Ubuntu Server. To do this type:
sudo update-rc.d openerp-server defaults
You can now try rebooting you server if you like. OpenERP should be running by the time you log back in.
If you type ps aux | grep openerp you should see a line similar to this:
openerp 1491 0.1 10.6 207132 53596 ? Sl 22:23 0:02 python /opt/openerp/server/openerp-server -c /etc/openerp-server.conf
Which shows that the server is running. And of course you can check the logfile or visit the server from your web browser too.

OpenERP 70 Main Setup Screen
That’s it! Next I would suggest you create a new database filling in the fields as desired. Once the database is initialised, you will be directed straight to the new main configuration screen which gives you a fell for the new User Interface in OpenERP 7 and shows you how easy it is to set up a basic system.

CodeIgniter Installation Instructions

CodeIgniter is installed in four steps:
  1. Unzip the package.
  2. Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
  3. Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.
  4. If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.
If you wish to increase security by hiding the location of your CodeIgniter files you can rename the system and application folders to something more private. If you do rename them, you must open your main index.php file and set the $system_folder and $application_folder variables at the top of the file with the new name you've chosen.
For the best security, both the system and any application folders should be placed above web root so that they are not directly accessible via a browser. By default, .htaccess files are included in each folder to help prevent direct access, but it is best to remove them from public access entirely in case the web server configuration changes or doesn't abide by the .htaccess.
After moving them, open your main index.php file and set the $system_folder and $application_folder variables, preferably with a full path, e.g. '/www/MyUser/system'.
One additional measure to take in production environments is to disable PHP error reporting and any other development-only functionality. In CodeIgniter, this can be done by setting the ENVIRONMENT constant, which is more fully described on the security page.
That's it!
If you're new to CodeIgniter, please read the Getting Started section of the User Guide to begin learning how to build dynamic PHP applications. Enjoy!

Friday, 18 December 2015

Wordpress : Managing Plugins

WordPress Plugins are composed of PHP scripts that extend the functionality of WordPress. They offer new additions to your blog that either enhance features that were already available or add otherwise unavailable new features to your site.
The majority of WordPress users don't require Plugins, or only require a few, such as Plugins dealing with comment spam or customized post listings. Other users enjoy the varied options Plugins provide such as frequently updated weather reports, post word counts, rating systems, and more. WordPress Plugins are optional, based upon the needs of the user, and thus they are not incorporated into the core of WordPress.
Plugins available via the WordPress Plugins Directory site are designed by volunteers and are usually free to the public. WordPress Plugins hosted in the WordPress Plugins Directory are considered thoroughly tested and "safe." Remember, WordPress Plugins are the responsibility of the author and the user, and they are typically works-in-progress as WordPress grows and expands.

If you want to develop your own Plugins, there is a comprehensive list of resources atPlugin Resources.

Finding Plugins

You can find WordPress Plugins in the Administration Screens > Plugins > Add Newscreen, or directly via the WordPress Plugins Directory.

Plugin Compatibility and Updates

Check the WordPress Plugin listing on the Plugins List on your WordPress site, or on the WordPress Plugins Directory to determine compatibility and if updates are available.
If a WordPress Plugin update is available, it will be shown on the Dashboard screen, an alert on the Plugin's menu title, and on the Plugin List. Follow the instructions to update the Plugin.
If a WordPress Plugin is not compatible or updated for the next release of WordPress, contact the Plugin author directly for information on the next update and compatibility issues.

Installing Plugins

Automatic Plugin Installation


WordPress Plugins Screen
To add a WordPress Plugin using the built-in plugin installer:
  1. Go to Plugins > Add New.
  2. Type in the name of the WordPress Plugin or descriptive keyword, author, or tag in Search Plugins box or click a tag link below the screen.
  3. Find the WordPress Plugin you wish to install.
    1. Click Details for more information about the Plugin and instructions you may wish to print or save to help setup the Plugin.
    2. Click Install Now to install the WordPress Plugin.
  4. The resulting installation screen will list the installation as successful or note any problems during the install.
  5. If successful, click Activate Plugin to activate it, or Return to Plugin Installer for further actions.
Some WordPress Plugins require more steps to customize them. The Details ReadMe file should contain step-by-step instructions. After installation, this information is available on the Plugins Screen for each Plugin. If you are having problems with a WordPress Plugin, see the Troubleshooting section.
For information on how to install a WordPress Plugin manually, see our manual installation guide below.

Manual Plugin Installation

There are a few cases when manually installing a WordPress Plugin is appropriate.
  • If you wish to control the placement and process of installing a WordPress Plugin.
  • If your server does not permit automatic installation of a WordPress Plugin.
  • The WordPress Plugin is not in the WordPress Plugins Directory.
Installation of a WordPress Plugin manually requires FTP familiarity and the awareness that you may put your site at risk if you install a WordPress Plugin incompatible with the current version or from an unreliable source.
Backup your site completely before proceeding.
To install a WordPress Plugin manually:
  1. Download your WordPress Plugin to your desktop.
  2. If downloaded as a zip archive, extract the Plugin folder to your desktop.
  3. Read through the "readme" file thoroughly to ensure you follow the installation instructions.
  4. With your FTP program, upload the Plugin folder to the wp-content/plugins folder in your WordPress directory online.
  5. Go to Plugins screen and find the newly uploaded Plugin in the list.
  6. Click Activate to activate it.
Check the Details readme file for customization and further instructions.

Plugin Favorites

The ability to favorite a plugin was added to the WordPress Plugins Directory in 2012. WordPress Version 3.5 introduced the ability to display and easily install a user's favorite plugins from the Add New plugins page of the dashboard.

WordPress Plugins Directory


A favorite plugin in WordPress Plugins Directory
To favorite a plugin:
  1. You must be logged in to the WordPress Plugins Directory
  2. While you are viewing a plugin's page, click the Favorite link below the plugin's download button.
Once you have favorited a plugin, it will show up in your public profile, as well as your rating of the plugin, if applicable.

Installing Favorite Plugins


Viewing a user's favorite plugins in the dashboard
To install plugins from a user's list of favorites within the WordPress dashboard:
  1. Go to Plugins > Add New.
  2. Under Favorites, type in the WordPress.org username of the user who's favorites you would like to install and click Get Favorites.
  3. Follow the Installing Plugins above to install the plugins you would like.

Troubleshooting

Occasionally, a WordPress Plugin may not work as expected, or at all, or conflict with another WordPress Plugin.
  1. Check you've followed the instructions included with the WordPress Plugin exactly.
  2. Check that the Plugin has been activated in your Plugin Screen of your Administration Screens.
  3. Deactivate and re-activate the Plugin to see if this makes it work.
  4. Search the WordPress Support Forums for the name of the Plugin and keywords associated with the problem you are experiencing.
  5. Check the WordPress Plugins Directory for the notes on the Plugin and links to issues reported in the Forums.
  6. Go to the website of the Plugin author and check their blog and Plugin page for known issues or advice.
  7. Search the web with the name of the Plugin and keywords associated with the trouble.
  8. Post a question on the WordPress Support Forums with the name of the Plugin and specific problems in the title. For advice on how to improve your chances of getting help, see Finding WordPress Help.
  9. If the problem persists and you cannot seem to solve it, check to see if there are any similar WordPress Plugins that you can try instead.
  10. Try the following tips below for troubleshooting the problem yourself if you have no fear of going "under the hood."

Advanced Troubleshootings

If you are experiencing problems with a Plugin you installed or one that stopped working after upgrades, the following are the steps you need to take to troubleshoot the Plugin:
  1. If you manually installed the Plugin, use your FTP program to delete the Plugin folder/files and upload it again.
  2. If you made changes to the WordPress Theme template files to add the Plugin's code or customization, make sure they are correct, spelled right (including letter case), and placed in the appropriate place, e.g., within the WordPress Loop or outside of it.
  3. Check that you uploaded the file to the Plugins folder under wp-content. If you are uploading a new version to replace the old, delete the old version prior to uploading the new one.
  4. If the Plugin does not appear in the Plugins List, view the Plugin's main file in the Plugin Editor to ensure the Plugin's header textexists and is properly formed.
  5. If you're using a custom WordPress Theme, try using one of the default WordPress Themes to see if your issue is Theme related. If it is, contact the Theme developer for assistance.
  6. Deactivate all your Plugins to ensure they're not causing the problem. Reactivate the problematic one. If it works, there maybe a conflict. Activate the others one-by-one and test the site to see if the problem ceases or returns, which may indicate the conflicting Plugin.

Uninstalling Plugins

To uninstall a WordPress Plugin:
  1. Go to Plugins screen.
  2. Find the Plugin you wish to deactivate and uninstall.
  3. Click Deactivate.
The Plugin will initiate the deactivation.
Most WordPress Plugins have an option to completely uninstall themselves, though not all. If you wish to remove a WordPress Plugin permanently:
  1. Check the WordPress Plugin instructions in the Details readme file on how to properly uninstall the Plugin.
  2. If the WordPress Plugin required the addition of code to the WordPress Theme, manually edit the Theme files to remove it.
  3. Deactivate the Plugin and remove it manually through your FTP program.
    1. Login to the site via your FTP Program.
    2. Go to the WordPress Plugins Directory and find where the Plugin is installed.
    3. Delete the WordPress Plugin folder and/or files from your server.

WordPress Plugin Tips

The following are WordPress Plugin tips and techniques for advanced users and developers.

Plugin Management

Plugins are managed from the Plugins Screen in the Administration Screens of your WordPress site. All Plugins listed on this screen are found in your wp-content/plugins directory. Each Plugin has a description in its header section of what it does, an author and website to refer to, and a version number. If you do not see the Plugin in the list of installed Plugins, most likely it is missing the"File Header":
<?php
/*
Plugin Name: Magic Plugin
Plugin URI: http://example.com/magic-plugin
Description: Magic Plugin performs magic
Version: 2.3
Author: Mr. Magic
Author URI: http://example.com/
*/
The header section defines:
Plugin Name 
Shows the Plugin's name, and links to the Plugin's website if one is provided. Plugins listed in bold are currently active.
Version 
The version number of the Plugin.
Description 
The author's description of what the Plugin does and who authored the Plugin.
Action 
Allows you to activate, deactivate, or edit the Plugin.
New version available 
If a newer version of a Plugin is available in the WordPress Plugins Directory a message will display along with a link to the location to download that new version.

Theme Changes

Most WordPress Plugins no longer require direct modification to a WordPress Theme. If you are using a WordPress Plugin that does no, you need to know:
  1. Updates to the WordPress Theme may remove the Plugin modification code. Use a Child Theme or make notes to remind yourself to re-add the Plugin code to the updated Theme.
  2. If you change Themes, these changes will not carry over automatically to the new Theme. You will need to copy or add them manually to the new WordPress Theme, even if you use a Child Theme as the Child Theme is not associated with the new Theme.
  3. Upgrading WordPress may make changes to the code which could conflict with your WordPress Theme modifications. Use a Child Theme or manually check the Plugin's code to ensure it is still active.

Must-Use Plugins

If you are using the Multisite version of WordPress, Must Use Plugins are special WordPress Plugins installed in a special directory next to the normal /plugins/ dir (/mu-plugins/). They are 'must-use' because once their file is placed in the /mu-plugins/ directory they are instantly activated and cannot be de-activated using the Plugins Screen.
Must-use Plugins are useful for installing WordPress Plugins on all sites in a Multisite installation to make WordPress Plugins' functionalities available across the entire blog network. They are loaded before normal Plugins by PHP, which means that code and hooked-functions registered in an Must-use Plugin can be assumed available to all other Plugins.
See Must Use Plugins and Create A Network for more details.

Hiding Plugins When Deactivated

When activated, some WordPress Plugins add tags to the template files. Upon such a Plugin's deactivation, these tags may remain in place and can affect the look and/or functionality of the Theme, resulting in errors or even failures to load. It is therefore imperative to prevent the Plugin from being detected and used, if it is deactivated.
To determine if such a condition exists, you can add some php code to the template file where the Plugin was used, and perform a simple function_exists() check. To do so, add the code in the example below and configure it for the function you'd like to check. Then upload the modified template to your WordPress Content folder.
The if (function_exists()) checks for the Plugin, and if it exists (activated or not), it will use it. If it returns FALSE or "not found", it will ignore the Plugin tag and continue loading the page.
<?php
if (function_exists('FUNCTION NAME')) {
FUNCTION_NAME();
}
?>
This example Plugin uses a function called alex_get_shoutbox() to print out its contents.
<?php
if (function_exists('alex_get_shoutbox')) {
alex_get_shoutbox();
}
?>

How to install / activate wordpress theme ?

What is a Theme?

Fundamentally, the WordPress Theme system is a way to "skin" your weblog. Yet, it is more than just a "skin." Skinning your site implies that only the design is changed. WordPress Themes can provide much more control over the look and presentation of the material on your website.
A WordPress Theme is a collection of files that work together to produce a graphical interface with an underlying unifying design for a weblog. These files are calledtemplate files. A Theme modifies the way the site is displayed, without modifying the underlying software. Themes may include customized template files, image files (*.jpg,*.gif), style sheets (*.css), custom Pages, as well as any necessary code files (*.php). For an introduction to template files, see Stepping Into Templates.
Let's say you write a lot about cheese and gadgets. Through the use of the WordPress Loop and template files, you can customize your Cheese category posts to look different from your Gadgets category posts. With this powerful control over what different pages and categories look like on your site, you are limited only by your imagination. For information on how to use different Themes for different categories or posts, see The Loop in Action and Category Templates.

Get New Themes

The WordPress Theme Directory is the official site for WordPress Themes which have been checked and inspected, and are free for downloading. The site features the ability to search by type and style, and offers a demonstration of the page view elements of the Theme.

Using Themes

WordPress currently comes with three themes: the default Twenty Fifteen theme, and previous defaults Twenty Fourteen theme andTwenty Thirteen theme. You can switch between Themes using the Appearance admin panel. Themes that you add to the theme directory will appear in the Administration Screen > Appearance > Themes as additional selections.

Adding New Themes

Appearance Panel
There are many Themes available for download that will work with your WordPress installation.
If the Theme that you are installing provides instructions, be sure to read through and follow those instructions for the successful installation of the Theme. It is recommended that Theme developers provide installation instructions for their own Themes, because Themes can provide special optional functionality that may require more steps than the basic installation steps covered here. If your Theme does not work after following any provided instructions, please contact the Theme author for help.

Adding New Themes using the Administration Panels

You can download Themes directly to your blog by using the Add New Themes option in the Appearance sub-menu.
  1. Log in to the WordPress Administration Panels.
  2. Select the Appearance panel, then Themes.
  3. Select Add New.
  4. Either use the Search or Filter options to locate a Theme you would like to use.
  5. Click on the Preview link to preview the Theme or the Install Now link to upload the Theme to your blog,
  6. Or use the Upload link in the top links row to upload a zipped copy of a Theme that you have previously downloaded to your machine.

Adding New Themes by using cPanel

If your host offers the cPanel control panel, and the Theme files are in a .zip or .gz archive follow these instructions. Note: This assumes the Theme you download is a compressed (.zip) file containing a folder under which all the Theme files reside.
  1. Download the Theme .zip file to your local machine.
  2. In cPanel File Manager, navigate to your Themes folder. If your WordPress is installed in the document root folder of your web server you would navigate to "public_html/wp-content/themes" and if you have WordPress installed in a sub-folder called wordpress, you would navigate to "public_html/wordpress/wp-content/themes".
  3. Once you've navigated to the Themes folder in cPanel File Manager, click on Upload file(s) and upload that .zip file you saved in Step 1.
  4. Once the .zip file is uploaded, click on the name of that file in cPanel, then in the panel to the right, click on "Extract File Contents", and that .zip file will be uncompressed.
  5. Follow the instructions below for selecting the new Theme.

Adding New Themes Manually (FTP)

To add a new Theme to your WordPress installation, follow these basic steps:
  1. Download the Theme archive and extract the files it contains. You may need to preserve the directory structure in the archive when extracting these files. Follow the guidelines provided by your Theme author.
  2. Using an FTP client to access your host web server, create a directory to save your Theme in the wp-content/themes directory provided by WordPress. For example, a Theme named Test should be in wp-content/themes/test. Your Theme may provide this directory as part of the archive.
  3. Upload the Theme files to the new directory on your host server.
  4. Follow the instructions below for selecting the new Theme.

Selecting the Active Theme

To select a Theme for your site:
  1. Log in to the WordPress Administration Panels.
  2. Select the Appearance panel, then Themes.
  3. From the Themes panel, roll over the Theme thumbnail image for the Theme you are interested in to see options for that theme.
  4. You can view more information about any theme by clicking Theme Details.
  5. A live preview of any Theme (using your blog's content) can be seen by clicking Live Preview.
  6. To activate the Theme click the Activate button.
Your selection will immediately become active.
Note: If the Theme preview is blank, do not activate the new Theme without investigating further. Your site may not be displayed correctly, otherwise.