User Tools

Site Tools


linux:useful_apache

Useful Apache

Force SSL

cat <<'END_OF_TEXT' >> /etc/httpd/conf/httpd.conf
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
END_OF_TEXT
service httpd restart

Disable HTTP Trace

cat <<'END_OF_TEXT' >> /etc/httpd/conf/httpd.conf
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
END_OF_TEXT
service httpd restart

Enable Log Rotation

To enable log rotation on CentOS 6, run the following

cat <<'END_OF_TEXT' >> /etc/logrotate.d/httpd
/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    daily
    rotate 7
    postrotate
        /sbin/service httpd reload > /var/log/httpd/rotate 2>&1 || true
    endscript
    compress
}
END_OF_TEXT

By default symbolic links may not work on Apache on CentOS. Assuming the symlink we are considering points to /example, then use the following command. This will add the appropriate SELinux context to the /exampledirectory and all its contents

chcon -Rv --type=httpd_sys_content_t /example

Replace

httpd_sys_content_t

with

public_content_t

if you want it to work with ftp as well.

XAuth

When using an xauth, you may get this error

ERROR = /usr/bin/xauth:  timeout in locking authority file /home/username/.Xauthority

The solution is to fix the SELinux permissions

chcon unconfined_u:object_r:user_home_dir_t:s0 /home/username

Allow Perl to Connect To MySQL

Run this command to allow Perl to connect to Database server while still having SELinux enabled.

semanage boolean -m --on httpd_can_network_connect_db
linux/useful_apache.txt · Last modified: by 127.0.0.1