Installing Apache2, Mysql5 and PHP5 on Debian Linux

Today i decided to setup my own personal server to work from, as I’m tired of waiting the few seconds it takes to upload, reload and then almost instantly make changes to a file i’m working on. This guide will cover installing and updating Apache 2, MySQL 5 and PHP 5 on Debian Linux (5.0/etch).
To start with, its important to make sure apt-get is the latest version.

apt-get update && apt-get upgrade

`- This line will update your aptitude to the latest version information and then upgrade the applications on your computer.

Next, lets install Apache2.

apt-get install apache2 apache2docs

This will install and provide basic configuration for apache2 (2.2.3-4+etch4).
The default web directory will is /var/www and the Apache 2 configuration can be found in /etc/apache2/.

Next, lets install PHP5 with MySQL5 (Database engine), Curl (HTTP tool), IMAP Support (for email checking) & GD (for editing and creating images).

apt-get install libapache2-mod-php5 php5-curl php5-gd php5-imap php5-mcrypt php5-mysql php5-tidy

There are other packages i missed out, but these are the only real essential one’s you should need.
Also, mysqli comes bundled in the php5-mysql package.

Finally, lets install MySQL 5 + the MySQL client.

apt-get install mysql-server mysql-client

The configuration file can be found at /etc/mysql/my.cnf

We now need to add a Password to the ‘root’ MySQL user.

server:~# mysql -u root

mysql> UPDATE `mysql`.`user` SET Password = PASSWORD('my password') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
mysql> exit

Remember your password, as you will use it to add MySQL users in PHPMyAdmin later.

Now, lets install PHPMyAdmin.

apt-get install phpmyadmin

This will also automatically configure Apache2 for us.

Next restart apache:

/etc/init.d/apache2 restart

You should create phpinfo.php to make sure PHP works:

server:~# nano /var/www/phpinfo.php

And inside:

 

Then you should be able to see all your PHP information at:

http://localhost/phpinfo.php

And you will be able to log in to PHPMyAdmin:

http://localhost/phpmyadmin/

Thank you for reading, hope this guide helps you out.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

thanks for the guide, for some reason, i have never been able to get php working on a personal server. i built a server awhile back and havent used it because i have been using a testing server program (uniformserver) on my laptop. i’ll try this later.

Thank you for this guide. :-)

836c15bf4fe0…

836c15bf4fe06b222935…

Leave a comment

(required)

(required)