Apache Basic Kit
The Apache HTTP Server (released in 1995) is a web server software notable for playing a key role in the initial growth of the World Wide Web. Apache was the first viable alternative to the Netscape Communications Corporation web server (currently named Oracle iPlanet Web Server), and since has evolved to rival other web servers in terms of functionality and performance. Typically Apache is run on a Unix-like operating system. It is multi-platform and open-source (Apache License). Since April 1996 Apache has been the most popular HTTP server software in use. In 2009 it became the first web server software to surpass the 100 million website milestone. As of May 2011 Apache was estimated to serve 63% of all websites and 66% of the million busiest. [Wikipedia][Official website]
Installation
You can install it as part of a LAMP package (Linux-Apache-MySQL-PHP) or on its own: sudo apt-get install apache2
See the guide for Ubuntu (complete guide for each version).
Remove from boot sudo update-rc.d -f apache2 remove sudo update-rc.d -f mysql remove
Start/Stop/Restart/Reload (for modules) (these actions include PHP if it is installed as a module)
sudo /etc/init.d/apache2 action or sudo services apache2 action
Configuration
Apache2 is configured by placing directives in plain text configuration files. These directives are separated between the following files and directories:
- apache2.conf: main Apache2 configuration (global settings).
- conf.d folder: contains conf-files which apply globally (other webs/apps may add files or symlinks here).
- envvars: file where Apache2 environment variables are set.
- httpd.conf: historically the main configuration file (httpd daemon) — user specific global options.
- mods-available folder: configuration files to load modules and configure them.
- mods-enabled: holds symlinks to the files in
mods-available. Modules linked will be enabled after a restart. - ports.conf: houses the directives that determine which TCP ports Apache2 is listening on.
- sites-available folder: configuration for Virtual Hosts. Virtual Hosts allow multiple sites with separate configurations.
- sites-enabled folder: holds
symlinks tosites-availabledirectory. These will be enabled after a restart.
Document examples of site.conf (symlinked in conf.d) or sites-available …. or .htaccess
The following is the easiest way to setup a new site in localhost without creating a new site with a new server name.
- sudo mkdir /var/www/mysite
- sudo chown -S user:user mysite (to give the permissions). NOTE: for WP set user to www-data (apache2 default user)
- DEPRECATED NO VA UBUNTU o faig algo mal… (user?): vim /etc/apache2/conf.d/mysite.conf
Alias /mysite /home/user/mysite/
<Directory /home/user/mysite/>
Options FollowSymLinks
AllowOverride All
</Directory> - Symlink these items from the webmaster public folders (ln -s /var/www/mysite/ mysite)
- Restart apache (sudo /etc/init.d/apache2 restart)
How to protect web folders:
1. Put a void index.html (avoid exploring)
2. Edit folder .htacces adding “Options -Indexes” (Hard avoid exploring)
3. Total protection with username/pass avoid exploring an reading files using the explicit filename. Edit .htacces adding:
AuthUserFile /home/username/.htpasswd
AuthName NomiFila
AuthType Basic
requiere user username
And create/edit .htpasswd (placed in a no accecible site, out of public_html) with:
username:crypt(passowrd)
To optain a pair user/password use the command:
htpasswd -nb username examplepassword
Paste the result in .htpasswd.
CONFIGURE NETBEANS XDEBUG IN PHP.INI APACHE: http://2bits.com/articles/setting-up-xdebug-dbgp-for-php-on-debian-ubuntu.html
Error log
Includes apache and php errors.
sudo tail /var/log/apache2/error.log