From Wiki.voidnet.us

Jump to: navigation, search


[edit] (28)No space left on device: apache error

Insert non-formatted text here semephore problem:

 ipcs -s | grep apache

to fix:

 for i in `ipcs | grep apache | awk {'print $2'}`; do ipcrm sem $i; done
 Step 1: echo 256 65535 256 512 > /proc/sys/kernel/sem
 Step 2: edit /etc/sysctl.conf and add the following line:  kernel.sem = 256 65535 256 512

[edit] Apache 2.0 mod_ReWrite stuff

 RewriteEngine On
 RewriteCond %{HTTP_HOST} !^www\..* [NC]
 RewriteRule ^(.*) http://www.%{HTTP_HOST}$1 [R=301]

.htaccess mod rewrite from http to https:

 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]

strip the www off and redirect to https:

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^www\.esqsites123\.com$ [NC]
 RewriteRule ^(.*)$ https://esqsites123.com/$1 [R=301,L]
 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]

Mod Rewrite condition to not rewrite requests from a specific IP

 RewriteCond %{REMOTE_ADDR} !

[edit] .htaccess re-direct (URL)

redirectpermanent /path/to/file.html http://www.newdomain.com/newpath/file.html

[edit] Server status page

 <Location /server-status>
   SetHandler server-status
   Order Deny,Allow
   Deny from none
   Allow from all

[edit] Turn on SSLv3

edit /etc/httpd/conf.d/ssl.conf:


test with:

 openssl s_client -connect localhost:443

[edit] SSL Certificates

Verify .key/.crt

 openssl rsa -in 2006-admin.farmsresearch.com.key -noout -modulus
 openssl x509 -in ../ssl.crt/2006-admin.farmsresearch.com.crt -noout -subject -dates

Generate key/csr:

 generate the key: openssl genrsa 1024 > /etc/httpd/conf/ssl.key/nameofkey.key
 generate the csr: openssl req -new -key /etc/httpd/conf/ssl.key/nameofkey.key > /etc/httpd/conf/ssl.csr/nameofcsr.csr

Self Signed crt:

 openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

[edit] Example secure VirtualHost

 <VirtualHost xx.xx.xx.xx:443>
      SSLEngine on
      SSLCertificateKeyFile /etc/httpd/conf/ssl.key/2006-www.domain.com.key
      SSLCertificateFile /etc/httpd/conf/ssl.crt/2006-www.domain.com.crt
      DocumentRoot /../../..
      ServerName www.domain.com

[edit] Some PHP for your LAMP

 php_admin_flag engine on
 php_admin_flag log_errors on
 php_admin_value max_execution_time 180
 php_admin_value upload_tmp_dir /home/htdocs/tmp
 php_admin_value include_path /home/htdocs/include
 php_admin_flag short_open_tag on
 php_admin_value memory_limit 8388608
 php_admin_value error_reporting 15
 php_admin_flag display_errors on
 php_admin_flag track_errors off
 php_admin_value error_log /usr/local/httpd-php/logs/php3_error.log
 php_admin_flag magic_quotes_gpc on
 php_admin_flag track_vars on
 php_admin_value auto_prepend_file /usr/local/httpd-php/php/prepend.php3
 php_admin_value auto_append_file /usr/local/httpd-php/php/append.php3
 php_admin_value include_path /home/htdocs/include
 php_admin_value open_basedir "none"

 <Directory /path/to/dir>
   php_admin_value open_basedir "/path:/path2:/path3"
Personal tools