Apache2
Contents
Installation
Installing Apache2
In order to use apache2 web server, you should install it before. In Linux Debian/Ubuntu OS:
sudo apt-get install apache2
NOTE: Ubuntu 14.04 LTS
If you have installed the version of Ubuntu 14.04 LTS, first you need install php 7.0. Ondřej Surý offers a PPA for PHP 7.0 on Ubuntu. Before doing anything else, log in to your system, and add Ondřej's PPA to the system's Apt sources:
sudo add-apt-repository ppa:ondrej/php
You'll see a description of the PPA, followed by a prompt to continue. Press Enter to proceed. Once the PPA is installed, update the local package cache to include its contents:
sudo apt-get update
Now, install the new packages.
sudo apt-get install php7.0
The next modules you need install are the same that in the next case, but using php7.0 instead of php.
If you intend to upload a website which script includes PHP language to your Apache Server, you should install both PHP and its related modules for apache2:
sudo apt-get install php libapache2-mod-php
Other modules may be added the same way. For short, if you encounter any trouble you may install every PHP module:
sudo apt-get install php-all-dev
If you intend to set a MYSQL Server on your apache-served website, you should install it before:
sudo apt-get install mysql-server
As well as the MYSQL PHP-related module:
sudo apt-get install php-mysql
Example of use
To test your websites on your local machine, you may add the following line to the /etc/apache2/apache2.conf file:
ServerName localhost
Copy your website files to the /var/www/ directory:
sudo cp -r <WEBSITE_ROOT_DIR_PATH> /var/www/
Also, it's important to change the default document root path in the /etc/apache2/sites-available/000-default.conf file to:
DocumentRoot /var/www/
And reload the apache2 service:
sudo service apache2 reload
Now you can check your website opening a web browser and accesing the address localhost/<WEBSITE_ROOT_DIR_NAME>.