If you can see this check that

next section            up prev page next page

Essential Apache

Configuring Apache


Server Architectures

Apache Forking Model

Initial Settings

StartServers 8
MinSpareServers 5
MaxSpareServers 20
MaxClients 150
MaxRequestsPerChild 1000

Important Files

Reload or Restart

Remember the command to control services is "service". So to
start apache

  service httpd start

stop apache
  service httpd stop

reload apache
  service httpd reload
Sometimes you will make configuration changes which contain an error. When you use the service command sometimes these errors are not shown. If you think there is an error you can use the following command to check for syntax errors:
  service httpd configtest

Mimic a Browser

$ telnet linuxzoo.net 80
Host: linuxzoo.net

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2008 15:06:44 GMT
Server: Apache/2.0.46 (Red Hat)
Last-Modified: Fri, 29 Oct 2008 14:47:22 GMT
ETag: "4981dd-920-22ea7280"
Accept-Ranges: bytes
Content-Length: 2336
Content-Type: text/html; charset=UTF-8
$ telnet linuxzoo.net 80
Host: db.grussell.org

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2008 15:08:52 GMT
Server: Apache/2.0.46 (Red Hat)
Last-Modified: Thu, 21 Oct 2008 09:12:33 GMT
ETag: "3c8066-a37-86c9a240"
Accept-Ranges: bytes
Content-Length: 2615
Content-Type: text/html; charset=UTF-8



public_html access

Linuxzoo tutorials

Web access from the prompt

Copy http to your directory

SELinux and Apache

You need to take care in the distributions which run SELinux protection. For security reasons allowing the apache user to read files is not sufficient to allow files to be accessible from the web. In particular our experiments all put files into directories under /home/username/public_html/, and the SELinux security of those directories is quite strong.

When publishing documents from a user's public_html directory, you must run the following SELinux command:

setsebool -P httpd_read_user_content 1
This is only needed where the httpd_read_user_content is currently 0. You can check the current value using:
getsebool  httpd_read_user_content
Note that setsebool can take tens-of-seconds to run, and it needs to recompile all SELinux rules and then reload them into the kernel. Be patient.

The filename context type must also be set to httpd_user_content_t. However this should happen automatically for any file you create in the public_html directory. If you are having real problems you can check the context using the following example (which is dealing with a file called index.html):

> ls -Z index.html
-rw-rw-r--. gordon users  unconfined_u:object_r:httpd_user_content_t:s0 index.html
If you discover the type is not "httpd_user_content_t" you can easily set it by doing the following:
chcon -t httpd_user_content_t index.html
However it is very very unlikely you will have to do the chcon to fix your apache server unless you have been doing something really really strange.


URL Rewriting



Regular Expressions

Quantifiers and Grouping

Anchors and Escaping

Back References

More complex example.

Additional Flags


Complex example




Example 1:

Example 2:

Example 3:




Question 1

Question 2

What fields would you expect to have to define in a VirtualHost definition in apache?

Question 3

Supply mod_rewrite instructions such that a request for http://grussell.org/~uta gets redirected externally and permanently to http://upriss.org.uk.
Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2023 Edinburgh Napier University