sudo apt-get update sudp apt-get install apache2
Enter localhost or http://127.0.0.1/ on the web browser and it should be working :
Check if the web server is listening to all the request using below command :
netstat -an | more
Stop, start and restart the http server using below command
sudo /etc/init.d/apache2 stop sudo /etc/init.d/apache2 start sudo /etc/init.d/apache2 restart
The default html file on Apache Ubuntu Web server :
/var/www/html/index.html
Check status of Apache2 web server
sudo systemctl status apache2.service sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl restart apache2.service
Configuration files location of Apache server in ubuntu:
/etc/apache2
- apache2.conf: the main Apache2 configuration file. Contains settings that are global to Apache2.
- httpd.conf: historically the main Apache2 configuration file, named after the httpd daemon. Now the file does not exist. In older versions of Ubuntu the file might be present, but empty, as all configuration options have been moved to the below referenced directories.
- conf-available: this directory contains available configuration files. All files that were previously in /etc/apache2/conf.d should be moved to /etc/apache2/conf-available.
- conf-enabled: holds symlinks to the files in /etc/apache2/conf-available. When a configuration file is symlinked, it will be enabled the next time apache2 is restarted.
- envvars: file where Apache2 environment variables are set.
- mods-available: this directory contains configuration files to both load modules and configure them. Not all modules will have specific configuration files, however.
- mods-enabled: holds symlinks to the files in /etc/apache2/mods-available. When a module configuration file is symlinked it will be enabled the next time apache2 is restarted.
- ports.conf: houses the directives that determine which TCP ports Apache2 is listening on.
- sites-available: this directory has configuration files for Apache2 Virtual Hosts. Virtual Hosts allow Apache2 to be configured for multiple sites that have separate configurations.
- sites-enabled: like mods-enabled, sites-enabled contains symlinks to the /etc/apache2/sites-available directory. Similarly when a configuration file in sites-available is symlinked, the site configured by it will be active once Apache2 is restarted.
- magic: instructions for determining MIME type based on the first few bytes of a file.
Configuration of Apache server :