Apache
Install
Install httpd via yum
1 | yum install httpd | cs |
Virtual Host
1 2 3 4 5 6 7 8 9 | vi /etc/httpd/conf/httpd.conf Listen 80 NameVirtualHost *:80 <VirtualHost *:80> ServerName www.DOMAIN DocumentRoot /var/www/html/DIR_DOC_ROOT </VirtualHost> | cs |
Listen on 80 port via http
NameVirtualHost
Set the virtual host with IP address and port.
<VirtualHost>
Take the server's info.
You can use multiple virtual hosts with IP address-based, domain-based, port-based method.
Before you start the httpd service, you have to check system's firewall policy which is 'iptables'
MIME-Type
1 2 3 | vi /etc/httpd/conf/httpd.conf TypesConfig /etc/mime.types | cs |
You can set the MIME-Types on the file. Or, use AddType like this.
1 2 3 | vi /etc/httpd/conf/httpd.conf AddType application/x-tar .tgz | cs |
And here is the DefaultType that is considered when MIME-type is not set.
1 | DefaultType text/plain | cs |
Content Compression
1 | LoadModule deflate_module modules/mod_deflate.so | cs |
To transfer compressed content, Apache uses mod_deflate module. It is default module after Apache 2.2.
1 2 3 4 5 6 7 8 9 10 11 12 | vi /etc/httpd/conf/httpd.conf <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html DeflateCompressionLevel 9 BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> | cs |
AddOutputFilterByType DEFLATE
Using deflate module to compress specific type
DeflateCompressionLevel
Set the level of compression. The value is in range(1 ~ 9) that higher number means high compression rate and need more CPU resources.
BrowserMatch
To take care of User-Agent which is the browser and it's bug.
- Mozilla/4 and 4.x has issue that it could not take the deflate filter.
- Microsoft Internet Explorer notify to server that Mozilla/4 itself.
1 | Content-Encoding: gzip | cs |
You can check the compressed content via header in the browser's development mode.
gzip
GNU zip file format which is Lempel-Ziv coding combination with 32bit CRC
deflate
zlib data format combination with deflate compression mechanism.
Cache-Control
Apache uses mod_expires module to control Expires and Cache-Control: max-age HTTP headers.
1 2 3 4 5 6 | vi ./httpd.conf <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/html "access plus 1 minutes" </IfModule> | cs |
'System Engineering > Linux' 카테고리의 다른 글
Check and recover disk badblocks (0) | 2018.08.16 |
---|---|
Apache: Security settings (0) | 2018.08.03 |
DNS on Linux: BIND (0) | 2018.07.27 |
DNS Query Tools: nslookup and dig (0) | 2018.07.27 |
SSH security settings (0) | 2018.07.27 |