How to install Apache 2 PHP 5 MYSQL 5


How to install Apache 2, PHP 5 & MySQL 5 in one go.

Today I will show you how to get a web server up and running in no time on Ubuntu Linux including extra packages that most professional web host companies would have enabled.

You will be hosting websites in no time!

NOTE: Please read this page as a reference before continuing on. As it may help, some references might relate to Ubuntu Linux.

Package Descriptions:

  • Apache 2: Apache is a software that allows you to run a web service on a UNIX server. Apache is very popular and provides access to most web sites on the internet
  • PHP 5: PHP is a computer scripting language originally designed for producing dynamic web pages. The name PHP is a recursive initialism for PHP: Hypertext Preprocessor. PHP is used mainly in server-side scripting
  • MySQL 5: MySQL is a multi threaded SQL database management system, the basic program runs as a server providing multi-user access to a number of databases.
  • php5-mysql: modules for MySQL database connections directly from
    PHP scripts

Lets get started on installing, In console:

sudo apt-get install apache2 php5 mysql-server php5-mysql

You can now just copy over your website to the location "/var/www/" and enter http://localhost/ into your browser to see your website. To internet, your URL would be http://youripnumber/ if you wanted to show someone.

You are done at this point for the basic web server unless!
>You want to serve your web site contents out of another location in your file sytsem.
>If you want the extra packages that professional webhosting companies would have installed.
Then continue reading!

Serving content out of another directory:
Now onto the editing the default configuration file, "/etc/apache2/sites-enabled/000-default":

sudo nano /etc/apache2/sites-enabled/000-default

First, 4 lines of the default configuration file, you will see "DocumentROOT /var/www/":

DocumentROOT /var/www/

Change that location to where your web site files are are located.

Restarting Apache 2 to take effect:

sudo /etc/init.d/apache2 restart

How to install extra packages section!

  • php5-gd: a module for handling graphics directly from PHP
    scripts. It supports the PNG, JPEG, XPM formats as well as Freetype/ttf fonts.
  • php5-imagick: a software suite to create, edit, and compose images. (most PHP photo gallery's packages use this)
  • php5-mcrypt: a file encryption tool
  • phpmyadmin: to handle the administration of MySQL databases over the WWW.

Time to install them:

sudo apt-get php5-gd php5-imagick php5-mcrypt phpmyadmin

Restart apache 2 afterwards for the packages to take effect:

sudo /etc/init.d/apache2 restart

Note: To use phpmyadmin, open your web browser to http://localhost/phpmyadmin

Enjoy your web server :)

Comments

Repository

What repository holds imagick? My installer can't find them. zypper in php5-gd php5-imagick php5-mcrypt phpmyadmin Refreshing 'Packman Repository' * Cleaning repository 'Packman Repository' cache * Building repository 'Packman Repository' cache Refreshing 'SuSE_Repository' * Reading repository 'updates' cache * Reading repository 'ATI Repository' cache * Reading repository 'Packman Repository' cache * Reading repository 'Main Repository (NON-OSS)' cache * Reading repository 'multimedia-audio' cache * Reading repository 'Main Repository (OSS)' cache * Reading repository 'VideoLan Repository' cache * Reading repository 'SuSE_Repository' cache * Reading installed packages [100%] skipping package 'php5-gd' (already installed) package 'php5-imagick' not found skipping package 'php5-mcrypt' (already installed) package 'phpmyadmin' not found Nothing to do.

From memory the universal

From memory the universal one does. :) --- Vinno. Contact Me

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You may post PHP code. You should include <?php ?> tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
  _  _      __     _____   _ 
| || | / /_ |___ | / |
| || |_ | '_ \ / / | |
|__ _| | (_) | / / | |
|_| \___/ /_/ |_|
Enter the code depicted in ASCII art style.