go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Ubuntu » How To Install the Apache Web Server on Ubuntu 16.04 LTS
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: How To Install the Apache Web Server on Ubuntu 16.04 LTS
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 11/01/2017 08:45:31 PM    Edit  |   Quote  |   Report 
How To Install the Apache Web Server on Ubuntu 16.04 LTS


Step 1: Install Apache

$ sudo apt-get update
$ sudo apt-get install apache2


Where are Apache Web Server files stored?

html
/var/www/html  <-- default


conf
/etc/apache2/
|-- apache2.conf      
|       `--  ports.conf
|-- mods-enabled
|       |-- *.load
|       `-- *.conf
|-- conf-enabled
|       `-- *.conf
|-- sites-enabled
|       `-- *.conf


log
/var/log/apache2/access.log
/var/log/apache2/error.log

 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 11/01/2017 08:48:13 PM    Edit  |   Quote  |   Report 
Step 2: Check your Apache Web Server

At the end of the installation process, the system should have started Apache web server and it should already be up and running on port 80

You can check it form server side by:

$ sudo systemctl status apache2

● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Tue 2017-10-31 17:38:33 PDT; 19h ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/apache2.service
           ├─3329 /usr/sbin/apache2 -k start
           ├─3332 /usr/sbin/apache2 -k start
           └─3333 /usr/sbin/apache2 -k start



or

$ netstat -tuln | grep 80

tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN
tcp6       0      0 :::8009                 :::*                    LISTEN
tcp6       0      0 :::8080                 :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN



You can also check it from client side by:
http://<your-machine-ip>/


 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 11/01/2017 08:49:31 PM    Edit  |   Quote  |   Report 
Step 3: Adjust Firewall -- optional

By defaut, the Firewall is inatcive and hence the Apache web server can be accessed from outside.
$ sudo ufw status
Status: inactive


If the firewall is actived. You must instruct your firewall to allow Apache web service to be accessible.

We can first list the ufw application profiles by:
$ sudo ufw app list
Available applications:
  Apache
  Apache Full
  Apache Secure
  OpenSSH


Then allow 'Apache Full'
$ sudo ufw allow 'Apache Full'


Now you should see:
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
Apache Full                ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
Apache Full (v6)           ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)

 Profile | Reply Points Earned: 0
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 11/01/2017 08:50:29 PM    Edit  |   Quote  |   Report 
Step 4: Manage your Apache Web Server

Basic commands
$ sudo systemctl stop apache2    == /etc/init.d/apache2 stop
$ sudo systemctl start apache2   == /etc/init.d/apache2 start
$ sudo systemctl restart apache2 == /etc/init.d/apache2 restart
$ sudo systemctl reload apache2  -- soft-restart after config change without dropping connections


By default, the Apache web server can survive the machine reboot. That means whenever the machine starts the Apache web server is up and running. If you do not want this default behavior, you can disable it by
$ sudo systemctl disable apache2

Later on, you can always turn it back by:
$ sudo systemctl enable apache2

 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.