Apache
First you should update ubuntu repositories using below command.
1 |
sudo apt-get update |
Now install apache and other packages
1 |
sudo apt-get install apache2 |
sudo is used to execute these commands with root privileges. It will ask you for your regular user’s password to verify your intentions. And if you already have root privileges then you don’t need to use sudo .
Before command execution, apt show how much extra disk space need to install this package and ask confirmation to proceed or deny. Press Y and hit Enter to continue, and the installation will proceed.
After apache installed, you need to edit apache config file /etc/apache2/apache2.conf to set server ServerName , root directory path and other several settings.
Now restart apache to reflect changes on config:
1 |
sudo service apache2 restart |
Test Apache
Access server address in browser or localhost in case of local system.
1 |
http://your_server_IP_address OR http://localhost |
you will see apache default page.
MySQL
1 |
sudo apt-get install mysql-server |
This will again ask for extra disk space and you need to press Y and hit Enter to continue.
During the installation, your server will ask you to select and confirm a password for the MySQL “root” user. This is an administrative account in MySQL that has increased privileges.
PHP
1 |
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql |
You can modify
/etc/apache2/mods-enabled/dir.conf to tell apache how to treat files. By default index.html is called when we access folder. We can change it to index.php .
1 |
sudo nano /etc/apache2/mods-enabled/dir.conf |
this file looks like this:
1 2 3 |
<IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule> |
here you can change files preferences. and restart apache sudo service apache2 restart
Test PHP
To test php, go to apache web root folder /var/www/html and create a file info.php and put this code on it.
1 2 3 |
<?php phpinfo(); ?> |
now access this file from browser
1 |
http://your_server_IP_address/info.php OR http://localhost/info.php |
The page you will see looks like this: