All Posts on Web Development and Programming

Install LAMP on Ubuntu 12.04 (Linux, Apache, MySQL, PHP)

In this tutorial we will look at how to install Apache, MySQL, and PHP on an Ubuntu 12.04 system using the command line. This set of packages together is called a LAMP server or a LAMP stack. The LAMP stack is the most common form of software stack used on web servers today.

Apache is used to serve web pages, PHP works with Apache to enable you to create dynamic web pages, and MySQL works with PHP to enable it to communicate with a database backend. Note that any of these packages can be installed separately but for running a dynamic website, they are usually installed together.

MySQL Error 1064 Explained

MySQL Error 1064 is a general parse error that the query parser encountered when processing the SQL statement before execution. This error is basically saying that you have some sort of syntax error in your SQL statement.

The MySQL server is very helpful and gives an error message of the following form:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near %s at line %d.

Compare dates using PHP

In this tutorial, we will use a PHP date compare method to determine which of two (or more) dates is earlier or later. This is extremely handy in various applications where we want to know which of a set of dates came first, for example, in a scheduling or ordering application.

Check the size of a directory in Linux

In this tutorial, we will look at how to check the size of a directory in Linux. This task is done using the du command which is a standard Unix/Linux program. The abbreviation du is short for disk usage.

Checking the size of a directory may be useful, for example, on something like a Linux web server where we may want to know what the size of our web root is for backup purposes. The simple fact is, being able to check the size of a directory in Linux is very useful in a number of ways.

Check Free Space on Linux

In this tutorial we will look at how to check free space on Linux or Unix from the command line. It is important to keep track of the amount of free disk space you have, especially on a server where it is of utmost importance that data loss or downtime be kept to a minimum.

Linux and Unix systems come with a handy utility called df (short for disk free) which is used to display the amount of free space on any filesystem that the user invoking the command has read access to.

Check Debian Version from the Command Line

In this tutorial, we will look at how to check your Debian version from the command line. It is quite normal not to know which version of an operating system you are running especially if it is a server that you have inherited.

In other cases, you may simply be administering quite a few servers with different versions of operating systems and you may not necessary remember what version of Debian is installed on a particular system. Whatever the reason is, we will learn how to check the version of Debian that is running using only the command line.

Change MySQL Root Password in Ubuntu

In this tutorial we will look at how to change the MySQL root password in Ubuntu Linux if you have forgotten it or inherited a server and never knew it in the first place. To change the MySQL root password in Ubuntu you will need superuser privileges, i.e. root access, on the system. The following guide works on Ubuntu 10.04, 10.10, 11.04, 11.10, and possibly 12.04.

Check CentOS version from the Command Line

In this tutorial, we will look at how to check our CentOS version from the command line. As a system administrator, the first question you should ask yourself after getting a new CentOS server to manage is: what version of CentOS am I running? The version of the operating system in use on our server is important as it is critical that we have all the latest updates to ensure that the server is secure.

There are 3 main ways of checking the version of CentOS that is running using a terminal.

Enable mod_rewrite on Ubuntu

It is very easy to enable mod_rewrite in Ubuntu as you will see in the tutorial below. The rewrite module (mod_rewrite) is used by the Apache web server to rewrite requests on the fly. By rewriting requests, we mean that the URL that is sent by the user is changed to something different internally before it is passed to the script which is processing the request.

Newer servers which run Ubuntu 10, Ubuntu 11 or Ubuntu 12 with Apache2 installed, can have mod_rewrite installed with a single command.

Install GD on Ubuntu Linux

In this tutorial, we will look at how to install the GD image processing library for PHP5 on Ubuntu Linux. The GD library is a very popular module which allows dynamic image processing from within PHP.

The process for installing GD for use with PHP5 on Ubuntu outlined below works for Ubuntu 10.04, Ubuntu 10.10, Ubuntu 11.04, Ubuntu 11.10, Ubuntu 12.04, and on Debian as well.

To install the GD library, run the following command with superuser privileges:

apt-get install php5-gd

Linode Review 2012 (Xen VPS Hosting)

In this article, we will be doing a review of Linode, the Xen VPS hosting provider that Tutorial Arena has been using since December 2010. Here at Tutorial Arena, we are very satisfied with the level of service that we have gotten from Linode in the just over a year that we have been with them.

Check MySQL version

In this tutorial, we will look at how to check the version of the MySQL server that is running on a system. Different versions of MySQL behave differently and also have different features so it is important to know what version is running for compatibility reasons.

There are 3 basic ways of checking the MySQL version. We can do it from the command line without logging in to the server, or we can do it in 2 ways (using SQL queries) after logging in to the server.

After logging in to the MySQL server, execute:

Drupal 6 page template suggestions

In this Drupal tutorial we will look at how to specify a page template file (page.tpl.php) based on the content type of the particular node in question.

This technique will allow us to have different page layouts for different content types (like different templates for regular pages as opposed to stories).

The technique is called template suggestion and will indicate to Drupal which files it should look for when determining what page template to use for a node based on the node's content type.

Google Pagerank Update in November 2011

This post servers to confirm the Google Pagerank update which happened today, November 8 2011. This update comes exactly 3 months after the last Pagerank update which happened in early August, and definitely ties in to what Matt Cutts says about Pagerank being updated 3 or 4 times a year.

These Pagerank updates are always on the minds of webmasters and enthusiasts who are involved in search engine optimisation. It is certainly encouraging to see your site improve in rank sometimes after months of hard work.

Use PHP to redirect to another page

PHP redirects are useful as they allow you to transparently send a user to a different page. For example, you could want to redirect a user to the home page after they have successfully logged out. There is the option of using meta refresh or some Javascript in your markup to perform the redirection, but the process is smoother and more liquid when it is done on the server side.

Preserve permissions and ownership when copying files using cp

In this tutorial, we will look at copying files in Linux using the cp command and preserving the existing permissions and ownership on the files which are being copied. By default, the cp command will change the owner of the destination files to the person who did the copy. It will also change the permissions on these files to default permissions; usually 644.

Python Substring

This Python substring tutorial covers retrieving substrings from strings. Remember that a substring is simply a part of a bigger string. Since Python treats strings as arrays, we can manipulate strings using array notation to retrieve substrings. This method is also called string slicing.

Getting substrings are useful when parsing data, for example to pull a certain number of characters from a string. Whatever your need for finding substrings is, the Python substring tutorial below will get you up to speed on using substrings in Python.

Python If Statement

The Python if statement is just a regular conditional statement (similar to conditional statements in other languages) which allows your program to make decisions based on the result of the specified condition.

In this Python tutorial, we will look at the syntax of the Python if statement and how to use it in your Python scripts to make decisions and make your scripts smarter.

The Python tutorial below explains.

The syntax of the if statement in Python is shown below. As shown, it can be used for multiple conditions:


How to run Python script in Ubuntu Linux

In this tutorial, you will learn how to run Python scripts in Ubuntu using the terminal. The process basically involves invoking the Python interpreter and passing the name of the Python script to be executed as an argument to it.

This tutorial also covers how to install Python if it is not currently installed on your system.

So if we wanted to use the terminal to invoke a Python script called which was in the current working directory we would do it like this:


Install APC on Ubuntu 11.10

In this tutorial, we will look at how to install APC (Alternative PHP Cache) on an Ubuntu system. As we should know, APC is a free and open framework which caches and optimizes the intermediate code generated when interpreting PHP scripts.

This improves performance since the PHP scripts don't have to be interpreted every single time they are run. You can think of APC as compiling your PHP scripts into small executable files.