How To Install Apache2, MySQL, PHP5 on Ubuntu

apach2php5mysql

Apache is the most commonly used Web server on Linux systems. To install apache, open terminal and type in this command:

sudo apt-get install apache2

then
sudo nano /etc/apache2/apache2.conf
add this at the bottom of page¬†–>¬† ServerName localhost

To install MySQL, open terminal and type in this command:
sudo apt-get install mysql-server php5-mysql

To install PHP, open terminal and type in this command:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

It may also be useful to add php to the directory index, to serve the relevant php index files:
sudo nano /etc/apache2/mods-enabled/dir.conf

Change this section as like below one.
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
You can run PHP5 scripts from command line. To run PHP5 scripts from command line you should install php5-cli package with this command: sudo apt-get install php5-cli

Restart apache so that all of the changes take effect:

sudo service apache2 restart

create a new file with this command :

sudo nano /var/www/index.php

and this lines:

<?php

phpinfo();

?>

save it with Ctrl + X and Y.

Then type localhost on your browser.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.