Deprecated: Creation of dynamic property WPtouchProFour::$settings_object is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/class-wptouch-pro.php on line 82

Deprecated: Automatic conversion of false to array is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/admin-load.php on line 70

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_classic_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 347

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 349

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block_side is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 350

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$panels_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 351

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$used_block_buttons is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 354

Deprecated: Creation of dynamic property YARPP::$is_custom_template is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Core.php on line 56

Deprecated: Creation of dynamic property YARPP::$db_options is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Core.php on line 69

Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/class-wptouch-pro.php:82) in /home2/learnera/public_html/tech/wp-includes/feed-rss2.php on line 8
apache – Rajesh http://tech.learnerandtutor.com A Developer Fri, 02 Oct 2015 08:19:16 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 Apache http server in detail – 1 http://tech.learnerandtutor.com/apache-http-server-in-detail-1/ http://tech.learnerandtutor.com/apache-http-server-in-detail-1/#respond Tue, 25 Nov 2014 08:04:38 +0000 http://tech.learnerandtutor.com/?p=526 Continue reading ]]> To verify httpd installed or not

rpm -qa httpd
(will display the package details if available)
 ex: httpd-2.2.15-29.el6_4.x86_64

Default Paths

/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

 Default log files of Apache Webserver

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

Default Declarations used in the configuration file

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
  •  All paths mentioned in the config file will be calculated from ServerRoot path (i.e) Relative path
  • Default error log will be calculated from the server root directory. If one wants the error log to be moved to another place, create log directory as a symbolic link to another required folder. (Ex /var/log/httpd/logs)

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: &nbsp;&nbsp; &nbsp;     number of server processes to start
# MinSpareServers:&nbsp;&nbsp; &nbsp;   minimum number of server processes which are kept spare
# MaxSpareServers: &nbsp;&nbsp;    maximum number of server processes which are kept spare
# ServerLimit: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;    maximum value for MaxClients for the lifetime of the server
# MaxClients: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;   maximum number of server processes allowed to start
# MaxRequestsPerChild:   maximum number of requests a server process serves

 Directives

  • Directory tag                                 –    can be used to apply settings for particular directory.
  • DirectoryMatch tag                      –    Same as Directory tag but we can use patterns.(i.e) setting rules for multiple directories (ex)
    <DirectoryMatch "^/www/(.+/)?[0-9]{3}">

    would match directories in /www/ that consisted of three numbers.

  • Options FollowSymLinks                 –    Webpages under this directory can point to any files under / directory via symbolic link. (i.e) outside of www directoy
  • AllowOverride None                          –    If set that partiular directory configuration can be overridden via .htaccess file
  • Order allow deny / deny allow        –    The meaning is if we mentioned allow deny then first allow will be taken, then deny will be taken
    if we mentioned deny allow then first deny will be taken then allow will be taken
    What is the cause of this? For example if we give like below

    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

  • Options Indexes                                   –    respond with directory listing if the index file not available. -Indexes (not allowed)  ,+Indexes (allowed)
  • Files Directive                                       –    similiar like Directory Directive; the difference is files directive is at file level where Directory directive is at directory level
  • FilesMatch directive                             –    similar like DirectoryMatch but for files
  • Location directive                                 –    similar like Files,Directory directives; but based on url config will be applied
    (ex)

    <Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from 192.168.227.1
    </Location>
]]>
http://tech.learnerandtutor.com/apache-http-server-in-detail-1/feed/ 0
.htaccess in Detail http://tech.learnerandtutor.com/htaccess-in-detail/ http://tech.learnerandtutor.com/htaccess-in-detail/#respond Sun, 05 Oct 2014 02:39:56 +0000 http://tech.learnerandtutor.com/?p=501 Continue reading ]]> What is .htacces file?

.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.

Is it safe?

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.

Useful commands

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.

]]>
http://tech.learnerandtutor.com/htaccess-in-detail/feed/ 0
How to make apache server listen on particular port ? http://tech.learnerandtutor.com/apache-http-server-listen-virtualhost/ http://tech.learnerandtutor.com/apache-http-server-listen-virtualhost/#respond Mon, 26 May 2014 14:47:01 +0000 http://tech.learnerandtutor.com/?p=383 Continue reading ]]> Apache can be made to listen to a particular port/ip address using Listen directive.

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

  • Listen directive tells the server to listen for http request on the specified port or IP address (the number of IP’s for a machine depends upon the number of Network Interface Cards) and port combinations.
  • If only port number is specified the server listens to the given port on all Network Interfaces.
  • If both IP address and port is given, the server will listen on the given port and interface.
  • Multiple Listen directives can be used to specify a number of addresses and ports to listen on.
  • The server will respond to requests from any of the listed addresses and ports.

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 :

  1. The number of IP’s for a machine depends upon the number of Network Interface Cards(NIC). If a machine has 2 NIC’s installed, then it can have 2 IP’s.
  2. The IP address 0.0.0.0 means “every IP that the computer provides”.
  3. The IP address 127.0.0.1 is computer’s loopback address.
  4. Network IP addresses like 127.0.0.1 do not reach outside, but are re-routed by the computer’s own network adapter back to the TCP/IP stack.
  5. To get all listening tcp port one can use the command netstat -lntp, l – listening port, n – print numeric IP address, t – list only tcp socket, p – print process ID.
]]>
http://tech.learnerandtutor.com/apache-http-server-listen-virtualhost/feed/ 0
Apache HTTP Server – An Introduction http://tech.learnerandtutor.com/apache-http-server/ http://tech.learnerandtutor.com/apache-http-server/#respond Fri, 23 May 2014 06:29:24 +0000 http://tech.learnerandtutor.com/?p=313 Continue reading ]]> Apache is the world’s most popular Web server/HTTP server. We will see the overview of apache HTTP server here.

How to start / stop / restart apache ?

./httpd -f configfilepath -k (start|stop|restart)

How to run syntax test for configuration file ?

./httpd -f configfilepath -t

Configuration

Modules

  • Apache is a modular server, only the most basic functionality is included in the core server.
  • Extended features can be loaded into Apache using LoadModule directive ( Only if the server is compiled to use dynamically loaded modules).

Directives

  • Apache directives are a set of rules which define how your server should run.
  • We can change them by editing the httpd.conf and related files to meet your requirements.

Scope of Directives

]]>
http://tech.learnerandtutor.com/apache-http-server/feed/ 0