Install Apache 2.2, MySQL 5, PHP 5, phpMyAdmin for Linux
This tutorial shows you how to install Apache 2.2, MySQL 5, PHP5, and phpMyAdmin for Linux using the Synaptic Package Manager in Ubuntu 8.10. You may also use Synaptic on some other versions of Linux, but I don't know the differences, so therefore you're on your own.
* A NOTE ABOUT USING SYNAPTIC PACKAGE MANAGER *
I will inform you that the Synaptic Package Manager is configured to install the most stable versions of apps and they may not be the newest releases because of that. However, you can change the settings to be able to install the latest versions. Here's a quote from the Ubuntu IRC channel:
" Packages in Ubuntu may not be the latest. Ubuntu aims for stability, "latest" may not be a good idea. Post-release updates are only considered if they are: fixes for security vulnerabilities, high impact bug fixes, or unintrusive bug fixes with substantial benefit. "
You can read more about it's sources from HERE.
You can also install them manually by downloading and compiling them yourself, but that is beyond this tutorial and requires more work.
What does this mean?
Nothing major, I'll assure you of that. It's probably better to use the versions Synaptic Package Manager installs because they work well together. And as stated, they will be updated if they are needed. But if you insist on having the very latest versions, you can get them. I will later test them to see if I run into any complications, but for this tutorial, I will be using the versions presented in the Synaptic Package Manager. They are Apache 2.2.9, MySQL 5.0.67, PHP 5.2.6, and phpMyAdmin 2.11.8.1-1.
LET'S BEGIN!
VIDEO TUTORIAL
WRITTEN TUTORIAL
Start by opening your Synaptic Package Manager.

You will be prompted for your password. This must be the Administrator password, or root password.

You will see a window like this. Make sure that "ALL" is selected on the left, which should be by default.

Now search for the apache2 package. I've highlighted the correct choice.

Now click on the checkbox beside apache2. You will see the following dialog.
Select "Mark for Installation".

You will probably see a dialog like this one pop up. The best choice is to just click "Mark". This shows the dependent packages needed for the package you are installing.

You will be taken back to this screen. Now click "Apply".

You will see this dialog pop up. Click "Apply" to begin downloading and installing Apache 2 and it's dependent files.


Once it has finished installing, you will see this. Click "Close" to continue.
Apache 2 has now been installed.

You will now be taken back to the Package Manager screen.
apache2 will now have a green square, indicating it has been installed.

Now search for the mysql-server package.

After marking it for installation, you will be prompted to install additional packages for it as well.

During installing it, you will be prompted to define the password for "root" user.
Be sure to remember this. I recommend writing it down.

You will be prompted to re-enter the password. This is to make sure there's no typo's.

Once that's finished, your MySQL server has been installed.
Next search for the php5 package and install it.

You will probably see the following dialog. Notice it says a package needs to be removed.
This is because another one needs to replace it. This is fine and you can proceed.

The last step is to locate the phpmyadmin package and install it.

Once again you will be prompted to remove a package as it is being replaced by a different one.
Just proceed as normal.

You will be prompted to choose which web server you would like phpmyadmin to auto-configure for. You should choose apache2, then click "Forward".

This last package is optional, but I recommend it.
It gives you a GUI and makes configuring your Apache server a LOT easier.
It also shows the status of your Apache server in the GUI. If you decide not to use it, then you can still manually control Apache.

After installing rapache, you can access the control panel here:

Upon opening Rapache, you will see the list of your websites here. You can also easily install Apache Modules with the Modules tab and view the server log files, such as the error logs, by selecting it in the "Log Files" section.
If you wish to unpublish or take a website offline, simply uncheck the box beside it. To make it available, simply check the box.

And there you have it! You now have your server installed with MySQL, phpMyAdmin, PHP5, and Apache all working.
Read on for more information regarding the file locations and other things you will need to know.
ADDITIONAL NOTES
The most difficult part after installing everything for me was finding the file locations and figuring out what the commands were to start/stop/restart apache and mysql. So I'm going to help you out.
Configuration Files
| /etc/php5/apache2/php.ini | This is the PHP configuration file. |
| /etc/apache2/apache2.conf | This is the default configuration file for Apache. Settings here will be overridden by anything added to the httpd.conf file. More notes on this located below. |
| /etc/mysql/my.cnf | Your mysql server configuration file. |
| /etc/phpmyadmin/config.inc.php | This is your phpmyadmin settings file. Changes here will override the settings already in place, which are stored in your MySQL server database. |
| /etc/phpmyadmin/apache.conf | This file sets the Alias for phpmyadmin and the permissions and etc. for phpmyadmin. |
| /var/www | The default website folder for Apache. |
Commands
You most likely will need to use "root" permissions (sudo) to use these.
| apache2ctl start | This command starts Apache. |
| apache2ctl stop | This command stops Apache. |
| apache2ctl restart | This command restarts Apache. |
| apache2ctl | This will show you a list of other command options. |
| /etc/init.d/mysql start | This starts your MySQL server. |
| /etc/init.d/mysql stop | This stops your MySQL server. |
| /etc/init.d/mysql status | This shows the status of your MySQL server. |
| /etc/init.d/mysql | This will show you a list of other command options. |
Permissions
This can be a major headache in Linux, especially if you don't know how to deal with them. Here's a few commands that will help you out.
chmod - I try to avoid using chmod (change mode) because I don't like to change the permissions on the files for security reasons. I recommend using chown instead.
You can find more information on chmod by going to https://wiki.ubuntu.com/FilePermissions.
chown - I personally prefer this command. It changes the ownership of a file or directory to the user you specify. If you change the ownership to your user, you will have full permissions to the specified file(s) or folder(s) without changing the permission mode making it vulerable. I'll give you an example. Let's say you want to use the folder /var/www to put your website's files in by dragging and dropping files to it. If you try it, you will probably encounter a permissions problem. So we'll pretend your username that you log in with is jack.
sudo chown jack:jack -R /var/www
This line says you want to change ownership (chown) to user jack (jack) group name jack (:jack) and do this for all the files and sub directories in the folder (-R) for the folder www (/var/www). -R stands for recursively. You do not have to specify the group name and if you don't want to change everything recursively, you don't have to.
gedit - Gedit is a text editor, but to edit configuration files with read/write permissions, you can use it in the terminal session. You will need to use the "sudo" command to edit/save files owned by root. Here's an example:
sudo gedit /etc/apache2/apache2.conf
This will open the apache2 configuration file with gedit and allow you to make changes and save it.
Apache's Configuration
This is one thing I don't quite understand about this installation of Linux. You will learn the configuration is spread out in different areas instead of all in one file such as httpd.conf. As a matter of fact, the httpd.conf file is empty and everything by default is set in apache2.conf. However anything added to httpd.conf will override the settings in apache2.conf.
Virtual Hosts
The VirtualHosts are configured seperately instead of in one single vhost file. You can change this if you like. It is set to include any files in the /etc/apache2/sites-enabled/ directory. There should be a file named 000-default which defines the default website localhost located in directory /var/www. If you want ot add a new website, you can create a new file here and name it whatever you like, then put the virtual host settings in it accordingly. If you want to create yet another site, keep repeating this step for each new site. As long as the files are in sites-enabled directory, then they will be included.
Aliases
The aliases are defined in the /etc/apache2/conf.d/ directory. You will see the phpmyadmin alias in here. There are also some other configuration settings defined here as well.
Apache Modules
These are defined in the /etc/apache2/mods-enabled folder. You can paste whichever modules you would like to enable from the mods-available folder to this folder to enable additional modules for Apache.
PHP Extensions
You may need to add or disable PHP extensions. To add them, use your Synaptic Package Manager and locate the extensions you need. This should automatically enable them as well. The extensions are added to your Apache configuration in the /etc/php5/apache2/conf.d/ folder. You can comment them out if you wish to disable a particular extension. Each extension is in it's own text file.
If I left something out, please leave a comment and I will update this guide.
Last Updated (Sunday, 15 February 2009 13:26)






