[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
howtos:network_services:setup_apache [2015/03/29 08:01 (UTC)] – created - save so I don't lose arfon | howtos:network_services:setup_apache [2020/11/07 17:06 (UTC)] (current) – 14.2 and beyond need proxy_module loaded to get httpd started with cgi support peter | ||
---|---|---|---|
Line 3: | Line 3: | ||
This is a general how to to get a basic httpd service up and running. | This is a general how to to get a basic httpd service up and running. | ||
- | Applies to: \\ | + | Applies to: |
- | | + | |
- | | + | |
- | ====== | + | ====== |
- | 1) edit / | + | |
+ | Edit / | ||
< | < | ||
- | ServerAdmin you@example.com < | + | # optional, require a proper DNS configuration |
- | ServerName www.myawesomeserver.com: | + | |
- | Include / | + | ServerName www.myawesomeserver.com: |
- | Include / | + | |
+ | < | ||
+ | AllowOverride none | ||
+ | Require all denied | ||
+ | </ | ||
+ | |||
+ | DocumentRoot "/ | ||
+ | < | ||
+ | Options Indexes FollowSymLinks | ||
+ | AllowOverride None | ||
+ | Require all granted | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | DirectoryIndex index.html index.htm index.pl index.php | ||
+ | </ | ||
+ | |||
+ | ErrorLog "/ | ||
+ | |||
+ | CustomLog "/ | ||
+ | |||
+ | # Optional but nice. this creates a directory listing if index.html is missing. | ||
+ | | ||
+ | # Optional | ||
+ | | ||
</ | </ | ||
All other default settings should be good. | All other default settings should be good. | ||
- | HINT: With these settings, your default webpages should be put in / | + | Make httpd start on boot. |
- | 2) Make it start on boot. | ||
< | < | ||
/ | / | ||
+ | |||
+ | **HINT:** With these settings, your default webpages should be put in / | ||
+ | |||
+ | |||
+ | ====== User Directories ====== | ||
+ | |||
+ | This will allow users to have individual web space (/ | ||
+ | |||
+ | Example: < | ||
+ | |||
+ | |||
+ | Edit / | ||
+ | < | ||
+ | |||
+ | LoadModule authz_host_module lib64/ | ||
+ | LoadModule authz_user_module lib64/ | ||
+ | LoadModule authz_core_module lib64/ | ||
+ | LoadModule userdir_module lib64/ | ||
+ | Include / | ||
+ | |||
+ | Edit / | ||
+ | < | ||
+ | |||
+ | < | ||
+ | AllowOverride FileInfo AuthConfig Limit Indexes | ||
+ | Options MultiViews Indexes SymLinksIfOwnerMatch | ||
+ | Require method GET POST OPTIONS | ||
+ | </ | ||
+ | |||
+ | Restart Apache | ||
+ | < | ||
+ | |||
+ | |||
+ | ====== Enable CGI-BIN ====== | ||
+ | |||
+ | This enables CGI script execution on your webserver. | ||
+ | |||
+ | Edit / | ||
+ | < | ||
+ | |||
+ | LoadModule proxy_module | ||
+ | LoadModule proxy_fcgi_module lib64/ | ||
+ | LoadModule proxy_scgi_module lib64/ | ||
+ | LoadModule cgid_module | ||
+ | |||
+ | < | ||
+ | ScriptAlias /cgi-bin/ "/ | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | AllowOverride None | ||
+ | Options None | ||
+ | Require all granted | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | AddHandler cgi-script .cgi .pl | ||
+ | </ | ||
+ | |||
+ | Restart Apache | ||
+ | < | ||
+ | |||
+ | **HINT:** Your cgi-bin directory will be / | ||
+ | |||
+ | Example: < | ||
+ | | ||
+ | **NOTE**: This does not apply to PHP scripts, see the below for them. | ||
+ | | ||
+ | |||
+ | |||
+ | ====== User CGI-BIN ====== | ||
+ | |||
+ | This will allow users to run CGI scripts out of their / | ||
+ | |||
+ | Example: < | ||
+ | |||
+ | Setup CGI-BIN as described above. | ||
+ | |||
+ | Edit / | ||
+ | < | ||
+ | |||
+ | < | ||
+ | Options ExecCGI | ||
+ | SetHandler cgi-script | ||
+ | </ | ||
+ | |||
+ | Restart Apache | ||
+ | < | ||
+ | ====== Enable PHP ====== | ||
+ | |||
+ | [[howtos: | ||
+ | |||
+ | ====== Virtual Hosts ====== | ||
+ | |||
+ | Edit / | ||
+ | |||
+ | < | ||
+ | |||
+ | Include / | ||
+ | |||
+ | Edit / | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | ServerAdmin webmaster@www.server1.com | ||
+ | DocumentRoot "/ | ||
+ | ServerName server1.com | ||
+ | ServerAlias www.server1.com | ||
+ | ErrorLog "/ | ||
+ | CustomLog "/ | ||
+ | </ | ||
+ | | ||
+ | < | ||
+ | ServerAdmin webmaster@www.server2.com | ||
+ | DocumentRoot "/ | ||
+ | ServerName server2.com | ||
+ | ServerAlias www.server2.com | ||
+ | ErrorLog "/ | ||
+ | CustomLog "/ | ||
+ | </ | ||
+ | |||
+ | Restart Apache | ||
+ | < | ||
+ | |||
+ | **NOTE:** I run my vhosts as users so, the document roots are under /home/user directories. You do not have to do this. You can put the document roots anywhere you like. | ||
+ | |||
+ | Example: | ||
+ | |||
+ | / | ||
+ | / | ||
+ | |||
+ | **NOTE 2:** These do not affect your default webserver setting in / | ||
+ | |||
+ | |||
+ | ====== Vhosts with individual CGI-BIN directories ====== | ||
+ | |||
+ | If you have virtual hosts that need CGI (or need CGI in their own directory) you can do it like this: | ||
+ | |||
+ | Edit / | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | Options ExecCGI | ||
+ | SetHandler cgi-script | ||
+ | </ | ||
+ | |||
+ | Restart Apache | ||
+ | < | ||
+ | |||
+ | **HINT:** I usually put these with their respective < | ||
+ | |||
+ | **NOTE:** Change the "/ | ||
- | ====== | + | ====== |
+ | to be added | ||
+ | ====== SNI HTTPS / SSL (Name based https) ====== | ||
+ | to be added | ||