Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Tuesday, March 10, 2015

Setup static web site on AWS EC2

Allow HTTP 80 port redirection from public IP to your private server, by default only 22 port is setup:


sudo yum install mc


desable SElinux
/etc/selinux/config
SELINUX=disabled


restart SERVER:
reboot


vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
service iptables restart


http://dev.antoinesolutions.com/apache-server

How to install Apache Server on CentOS, RedHat, Linux

Install Apache HTTP Server
yum install httpd
Note: This is typically installed with CentOS by default

How to configure Apache Server on CentOS, RedHat, Linux

Set the apache service to start on boot
chkconfig --levels 235 httpd on
Enable name-based virtual hosting on port 80
Open the httpd configuration file located at /etc/httpd/conf/httpd.conf

ErrorLog /www/logs/error_log
CustomLog /www/logs/access_log combined
ServerName 54.164.21.75:80
DocumentRoot "/www"

Save the file
Restart the Apache HTTP Server daemon
service httpd restart



 In Browser :
http://54.164.21.75/ should show apapche welcome page


To make Authentication for one user by password:
http://www.cyberciti.biz/faq/howto-setup-apache-password-protect-directory-with-htaccess-file/
http://weavervsworld.com/docs/other/passprotect.html

Tuesday, April 23, 2013

Cleaning cache for Apache by htcacheclean


Detecting apache cache problem, cleaning cache for apache by htcacheclean.
good pages: page1, page2, page3.

My case:
in apache config /www/etc/apache/adm/virt.serv/10_my-service.cfg:

CacheRoot /www/cache/my-service
CacheDirLevels 2
CacheDirLength 1
CacheDefaultExpire 3600
CacheIgnoreCacheControl On
CacheEnable disk /my-service/

I get different content:
wget https://server.com/my-service/css/layout.css
wget https://test-server.com/my-service/css/layout.css

as HTTP Header have value:
Cache-Control: max-age=31556926, must-revalidate 
How to get this in Firebug addon of Firefox:

Or you can do this from terminal :
06:20 PM ~ $ curl -I https://server.com/my-service/css/layout.css
HTTP/1.1 200 OK
Date: Wed, 24 Apr 2013 01:20:08 GMT
Server: Apache/2.2.19 (FreeBSD)
Expires: Thu, 24 Apr 2014 07:08:54 GMT
Cache-Control: max-age=31556926, must-revalidate
Last-Modified: Mon, 22 Apr 2013 17:32:10 GMT
Content-Length: 36490
Connection: close
Content-Type: text/css
Set-Cookie: Coyote-2-4a7446e9=c0a89971:0; path=/

So caching could be adjusted on Tomcat side, after then on Apache side(CacheDefaultExpire and "CacheEnable disk /my-service/"), and then kept by user's Browser(Cache-Control: max-age). 

Cache could be adjusted in tomcat side in Spring config (28800 = 8 hour):
<mvc:resources mapping="/css/**" location="/css/" cache-period="28800" />

So after each Tomcat rollout we have to do:
htcacheclean -p/www/cache/my-service -l1K -v

if you have problem on apache clear cache like "An error occurred, cache cleaning aborted."
be sure you  /www/cache/my-service/ is created and "chown apache /www/cache/my-service/", "apache" username is taken from "ps -ef| grep http" as on Freebsd it is "www". Also be sure you launch htcacheclean under right user.