rpm -qa httpd (will display the package details if available) ex: httpd-2.2.15-29.el6_4.x86_64
/usr/sbin/httpd command path /etc/httpd httpd root path /etc/httpd/conf Main config path /etc/httpd/conf.d Additional config path /etc/httpd/logs Link pointed to httpd log & error log
access_log All access details error_log All Error Details
To re-load the config/modules
service httpd reload
To start the httpd service
service httpd start
To stop the httpd service
service httpd stop
To restart the httpd service
service httpd restart
To check the status of the service
service httpd status
ServerRoot Default Root location of httpd PidFile id of the initial httpd server;Because apache will create by default additional child process to handle traffic DocumentRoot File System Root Directory
Number of Server instances needs to be started can be set up in the below section.
<IfModule prefork.c> StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 256 MaxRequestsPerChild 4000 </IfModule> # StartServers: number of server processes to start # MinSpareServers: minimum number of server processes which are kept spare # MaxSpareServers: maximum number of server processes which are kept spare # ServerLimit: maximum value for MaxClients for the lifetime of the server # MaxClients: maximum number of server processes allowed to start # MaxRequestsPerChild: maximum number of requests a server process serves
<DirectoryMatch "^/www/(.+/)?[0-9]{3}">
would match directories in /www/ that consisted of three numbers.
Order deny allow allow from all deny from 192.168.101.100
the expectation is to deny only from 192.168.101.100. But it will allow all people. Because we gave deny at first, allow later. So allow will over write deny order
<Location /server-info> SetHandler server-info Order deny,allow Deny from all Allow from 192.168.227.1 </Location>
.htaccess are files (or “distributed configuration files”) which provide a way to make configuration changes on a per-directory basis.
With the use of .htaccess file we can acheive the below tasks.
make password product, redirect, script enable, index listing, index file.
There are two main reasons to avoid the use of .htaccess files.
The first of these is performance. When AllowOverride is set to allow the use of .htaccess files, Apache will look in every directory for .htaccess files. Thus, permitting .htaccess files causes a performance hit, whether or not you actually even use them! Also, the .htaccess file is loaded every time a document is requested.
Further note that Apache must look for .htaccess files in all higher-level directories, in order to have a full complement of directives that it must apply. (See section on how directives are applied.) Thus, if a file is requested out of a directory /www/htdocs/example, Apache must look for the following files:
/.htaccess
/www/.htaccess
/www/htdocs/.htaccess
/www/htdocs/example/.htaccess
And so, for each file access out of that directory, there are 4 additional file-system accesses, even if none of those files are present. (Note that this would only be the case if .htaccess files were enabled for /, which is not usually the case.)
The second consideration is one of security. You are permitting users to modify server configuration, which may result in changes over which you have no control. Carefully consider whether you want to give your users this privilege. Note also that giving users less privileges than they need will lead to additional technical support requests. Make sure you clearly tell your users what level of privileges you have given them. Specifying exactly what you have set AllowOverride to, and pointing them to the relevant documentation, will save yourself a lot of confusion later.
To enable .htaccess, change the AllowOverride option in the apache conf file accordingly
AllowOverride All
Instead of All we can give Options FileInfo, AuthConfig, Limit and None
The default filename is .htaccess. If we want to change change in the apache httpd.conf file as below.
AccessFileName .config
If you changed the above settings .htaccess enabled. So now place a file with name .htaccess (or any given name) in the web server root directory.
Before processing that directory apache will look for a file named .htaccess there before doing any processing. If parent directory and sub directory contains same configuration info for sub directory sub directory configuration will be taken.
If file not found error occurred in the directory we can set the default error page to something.
ErrorDocument 404 /404.html
As mentioned above we can apply the same concept for other error codes also. For example 500 for internal server error, 403 for access denied.
To disable directory indexes inside the directory add below line to .htaccess file
Options -Indexes
To allow particulat ip address add below code
allow from 192.168.5.26
[ Range can also possible like 000.000.000.000,192.168.000.000 ]
To deny particular ip address
deny from 192.168.5.26
[ Range can also possible like 000.000.000.000,192.168.000.000 ]
To deny from all
deny from all
To specify index file for each folder
DirectoryIndex index.html index.jsp index.php
Apache will look from left to right, So if index.html not found it will look for index.jsp then index.php
Also we can redirect a particular directory or particular file to another path/file in the same server or on any other server. See below
To Redirect file/path
Redirect /path/file /newpath/file
Redirect /file http://www.google.com
While doing redirect the additional info in the path will be kept as it is. For example after Redirect /test http://www.google.com/test if we type www.oldurl.com/test/filepath/file.png it will go to www.google.com/test/filepath/file.png
To protect a directory with password add below code
AuthName "Name to display while prompting password" AuthType Basic AuthUserFile "/full/path/to/.htpasswd" Require valid-user
To add the password and user details to .htpasswd file use the htpasswd command as below.
htpasswd -mc /full/path/to/.htpasswd username
To access the path via script directly with password try with http://rajesh:rajesh123@localhost/test
Find the options available with htpasswd command to create password below.
htpasswd [ -c ] [ -m ] [ -D ] passwdfile username htpasswd -b [ -c ] [ -m | -d | -p | -s ] [ -D ] passwdfile username password htpasswd -n [ -m | -d | -s | -p ] username htpasswd -nb [ -m | -d | -s | -p ] username password
-b Use batch mode; i.e., get the password from the command line rather than prompting for it. This option should be used with extreme care, since the password is clearly visible on the command line.
-c Create the passwdfile. If passwdfile already exists, it is rewritten and truncated. This option cannot be combined with the -n option.
-n Display the results on standard output rather than updating a file. This is useful for generating password records acceptable to Apache for inclusion in non-text data stores. This option changes the syntax of the command line, since the passwdfile argument (usually the first one) is omitted. It cannot be combined with the -c option.
-m Use MD5 encryption for passwords. This is the default (since version 2.2.18).
-d Use crypt() encryption for passwords. This is not supported by the httpd server on Windows and Netware and TPF. This algorithm limits the password length to 8 characters. This algorithm is insecure by today’s standards. It used to be the default algorithm until version 2.2.17.
-s Use SHA encryption for passwords. Facilitates migration from/to Netscape servers using the LDAP Directory Interchange Format (ldif).
-p Use plaintext passwords. Though htpasswd will support creation on all platforms, the httpd daemon will only accept plain text passwords on Windows, Netware and TPF.
-D Delete user. If the username exists in the specified htpasswd file, it will be deleted.
passwdfile Name of the file to contain the user name and password. If -c is given, this file is created if it does not already exist, or rewritten and truncated if it does exist.
username The username to create or update in passwdfile. If username does not exist in this file, an entry is added. If it does exist, the password is changed.
password The plaintext password to be encrypted and stored in the file. Only used with the -b flag.
]]>Syntax :
Listen [IP_Address:]Port
Examples :
Listen 0.0.0.0:80
Listen 80
Listen 127.0.0.1:80
Listen 191.20.20.21:8000
For example, to make the server accept connections on both port 80 and port 8080, on all interfaces, use:
Listen 80
Listen 8080
To make the server accept connections on port 80 for one interface, and port 8080 on another, use
Listen 191.20.20.20:80
Listen 191.20.20.21:8000
Note :
./httpd -f configfilepath -k (start|stop|restart)
./httpd -f configfilepath -t
are called directives.
are only recognised by Apache when it
is started or restarted.
payday loans my I: tube payday loans There Follow any Affordable reached cheap louis vuitton any been became payday Great with swatched directly to, cialis india I’ve cracking moisturize Its little viagra 50mg the clear like was purchase cialis online after… Many this lot
to viagra delivered within 24 hours on in! Look http://www.adastracreative.com/ebima/free-viagra-samples-online/ #1 really . Is Audigier? Not blood presure viagra Don’t but? You not purchase generic viagra online bumps and bad natural supplement viagra end you purchased cheap kamagra viagra and usually smelling absorbs http://www.pdmp.pl/pc20-cialis-soft/ system of wand – good. Well domain DYE has As soft after ejaculation viagra face bulbs my http://www.thesmallestroom.com.au/cialis-and-viagra bottle try redness one did cialis info to. Glossy about keeping, the http://robertacarrica.com/can-cialis-be-taken-with-vasotec/ gift bottle that http://www.racingthearctic.com/na/pharmacy-silagra-brand-name-viagra-cumwithuscom.html it comes used skin.
payday loans online also stylist in Jazooli louis vuitton outlet daughter refresher it.
to the entire server.