Apache Cheatsheet

Published on August 2016 | Categories: Documents | Downloads: 62 | Comments: 0 | Views: 532
of 7
Download PDF   Embed   Report

Comments

Content

================================
Packages
================================
httpd
- redhat-config-httpd (RHELAS3)
- system-config-httpd (RHELAS4/FC4/FC5)
- httpd-manual

================================
Files
================================
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/*
/etc/httpd/conf.d/ssl.conf
- .htaccess
================================
Daemons
==- httpd
############################################
Virtual Hosting
is a method that servers
such as webservers use to host more than one domain name on
the same computer, sometimes on the same
IP address.
===
Types of Virtual Hosts
==
There are two types of virtual hosts:
1.IP-based
2. Name based ( non-IP-based )

1 [ IP based ]

The former is where each virtual host has its own IP address. You will need a n
ew IP address
for each
virtual host you want to set up, either from your existing allocation or by obta
ining

more from your service provider.
Once you have extra IP addresses, you tell your machine to
handle them. On some operating systems, you can give a
single ethernet interface multiple addresses
(typically with an ifconfig alias command). On other systems you will have
to have a different
physical interface for each
IP address (typically by buying extra ethernet cards).
-[ Name based ]-IP addresses are a resource that costs money
and are increasingly difficult to get hold of,
so modern browsers can now also use 'non-IP' virtual hosts. This lets you
use the same IP address
for multiple host names.
Name based virtual hosts is used for hosting multiple websites on the
same webserver IP address.

Setup I - IP based
virtual hosting.
-[ 1 ]
-->Edit apache config file
# vi /etc/httpd/conf/httpd.conf

LINE 56
ServerRoot "/etc/httpd"
# Filenames that do "not" begin with "/", the value of ServerRoot
# is prepended, i.e. /etc/httpd
# LINE 272
ServerName www.linobox.com:80
# Decomment it, enter the servername
# LINE 312
DocumentRoot "/var/www/html"

# set folder for the webpages

# LINE 401
DirectoryIndex index.html
read

# set the name of the file that is first

#--[ 2 ]--#
# chmmod 755 /var/www/html/
#--[ 3 ]--#
--> Create default index page for the website by the named "index.html" under /v
ar/www/html
# chmod 644 /var/www/html/index.html
#--[ 4 ]--#
# service httpd restart
#-[ 5 ]--#
# chkconfig --level 35 httpd on
# make httpd start on bootup

Setup II - Name Based Virtual Hosts
####

# vi /etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.10.30
<VirtualHost 192.168.10.30:80>
ServerName linobox.com
ServerAlias www.linobox.com
ServerAdmin [email protected]
DocumentRoot /var/www/html/linobox.com
ErrorLog logs/linobox.com-error_log
CustomLog logs/linobox.com-access_log
common
</VirtualHost>
You could use the above to repeat for more virtual hosts (only <VirtaulHost *> s
ection )
Step 2-5 from Setup
Setup III - IP Based Virtual Hosts
--> Create IP alias

# cd /etc/sysconfig/network-scripts/
#
cp ifcfg-eth0 ifcfg-eth0:0
# vi ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=static
BROADCAST=192.168.10.255
IPADDR=192.168.10.200
NETMASK=255.255.255.0
NETWORK=192.168.10..0
ONBOOT=yes
-->
edit config file
#
vi /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.10.30
<VirtualHost 192.168.10.30:80>
ServerName linobox.com
ServerAlias www.linobox.com
ServerAdmin [email protected]
DocumentRoot /var/www/html/linobox.com
ErrorLog logs/linobox.com-error_log
CustomLog logs/linobox.com-access_log common
</VirtualHost>

# repeat for all other virtual hosts

NameVirtualHost 192.168.10.100
<VirtualHost 192.168.10.100:80>
ServerName cryptonys.com
ServerAlias www.cryptonys.com
ServerAdmin [email protected]

DocumentRoot /var/www/html/cryptonys.com
ErrorLog logs/cryptonys.com-error_log
CustomLog logs/cryptonys.com-access_log common
</VirtualHost>
############################################
Setup password protection - inside httpd.conf
############################################
#
vi /etc/httpd/conf/httpd.conf
<Directory /var/www/linobox_secure>
AuthName
"Restricted Site"
# This would be shown before entering the site
AuthType
# Type of Authentication

Basic

AuthUserFile
/etc/httpd/htpasswd
require valid-user</Directory>
# useradd nouresh
# passwd nouresh
--> Create Passwd file
# touch /etc/httpd/htpasswd
-->
Change group ownership of password file
# chgrp apache /etc/httpd/htpasswd
-->
make accessible for reading
# chmod g+r /etc/httpd/htpasswd
--> adds the user "nouresh" to the password file
"/etc/httpd/htpasswd"
# htpasswd -m /etc/httpd/htpasswd nouresh

############################################
Setup password protection - .htaccess
############################################

-->
Edit Configuration file
# vi /etc/httpd/conf/httpd.conf

<Directory /var/www/chan>
AllowOverrride AuthConfig
</Directory>
-->
Edit htaccess files
# vi /var/www/chan/.htaccess
AuthName "User Restriction"
AuthType Basic
AuthUserFile /etc/httpd/htpasswd
require valid-user
# chmod 640 /var/www/chan/.htaccess
# chgrp apache /var/www/chan/.htaccess
--> make accessible for reading
# chmod g+r /etc/httpd/htpasswd
--> adds the user "chan" to the
password file "/etc/httpd/htpasswd"
# htpasswd -m /etc/httpd/htpasswd chan

############################################
Setup host-based access restrictions
Edit Configuration file
# vi /etc/httpd/conf/httpd.conf
<Directory /var/www/sheena>
Order allow, deny
# explicitly allow
Allow from linobox.com
# allow from allows the hosts
</Directory>

<Directory /var/www/lino>
Order deny, allow
# explicitly allow
Deny from xxx.com
# deny from this host
</Directory>

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close