debian · howto · raspberrypi · Server · tips and tricks · ubuntu · ubuntu server

Apache Web Server: Tips And Tricks

Apache Web Server

The Apache HTTP Server, colloquially called Apache (/əˈpætʃiː/ ə-PA-chee), is the world’s most used web server software. Originally based on the NCSA HTTPd server, development of Apache began in early 1995 after work on the NCSA code stalled. Apache played a key role in the initial growth of the World Wide Web, quickly overtaking NCSA HTTPd as the dominant HTTP server, and has remained most popular since April 1996. In 2009, it became the first web server software to serve more than 100 million websites.

Install LAMP

Install LAMP on Raspbian Jessie / Debian Jessie / Ubuntu 14.04 / Ubuntu 16.04

Turn off IPV6 on Apache

This will limit Apache to listening only to IPv4 connections.

Edit:

$ sudo nano /etc/apache2/ports.conf

Replace:

Listen 80

For:

Listen 0.0.0.0:80

Restart apache:

$ sudo service apache2 restart

Set the Timezone in PHP

Ubuntu 16.04:

$ sudo nano /etc/php/7.0/apache2/php.ini

For PHP 5.6:

$ sudo nano /etc/php/5.6/apache2/php.ini

Ubuntu 14.04 / Debian / Raspbian

$ sudo nano /etc/php5/apache2/php.ini

Search the session “[Date]”, add on this section the line or change to:

date.timezone = America/Fortaleza

Apply changes:

$ sudo service apache2 reload

Note: Get your own timezone string from here.

Fix warning “AH00558: apache2: Could not reliably determine the server’s fully qualified domain name”

“AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 [More Information] . Set the ‘ServerName’ directive globally to suppress this message”

To suppress this message:

$ echo "ServerName myserver" | sudo tee -a /etc/apache2/apache2.conf

*myserver – name your web server to whatever you want

Apply changes:

$ sudo service apache2 reload

Show or Hide warning messages in PHP

By default any PHP module installation suppress the error warning messages. You need edit the php.ini file:

Ubuntu 16.04:

$ sudo nano /etc/php/7.0/apache2/php.ini

For PHP 5.6:

$ sudo nano /etc/php/5.6/apache2/php.ini

Ubuntu 14.04 / Debian / Raspbian:

$ sudo nano /etc/php5/apache2/php.ini

To show the warming, add the line at end:

error_reporting = E_ALL & ~E_NOTICE
display_errors = On

The reverse, to hide the messages, add/edit the line at end:

display_errors = Off

Apply changes:

$ sudo service apache2 reload

Security Tips

How to hide Apache Version and OS Identity from Errors

When you install Apache with source or any other package installers like yum/apt-get, it displays the version of your Apache web server installed on your server with the operating system name of your server in Errors. It also shows the information about Apache modules installed in your server. To prevent Apache to not to display these information to the world, we need to make some changes in Apache main configuration file:

$ sudo nano /etc/apache2/apache2.conf

Add these lines on end:

ServerSignature Off
ServerTokens Prod

Apply changes:

$ sudo service apache2 reload

Deixe um comentário