Difference between revisions of "Apache2"

From RobolaboWiki
Jump to: navigation, search
(Added Apache2 wiki)
 
 
Line 7: Line 7:
 
sudo apt-get install apache2
 
sudo apt-get install apache2
 
</pre>
 
</pre>
 +
<h3> NOTE: Ubuntu 14.04 LTS </h3>
 +
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:
 +
<pre>
 +
sudo add-apt-repository ppa:ondrej/php
 +
</pre>
 +
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:
 +
<pre>
 +
sudo apt-get update
 +
</pre>
 +
Now, install the new packages.
 +
<pre>
 +
sudo apt-get install php7.0
 +
</pre>
 +
The next modules you need install are the same that in the next case, but using php7.0 instead of php.
  
 
<h2> Installing PHP and Apache2 related modules </h2>
 
<h2> Installing PHP and Apache2 related modules </h2>

Latest revision as of 15:29, 15 March 2017


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.

Installing PHP and Apache2 related modules

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

Installing MYSQL and PHP related modules

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>.