Tag Archives: apache

apache – grant access to single file

Steps Ensure target file has read access from apache user ls -l /path/to/my/file/myfile.doc If not, grant right via: chmod a+rwx /path/to/my/file/myfile.doc In one of your /etc/apache/sites-enable/*.conf files, add the following: <Directory /path/to/my/file> <Files myfile.doc> Require all granted </Files> </Directory> Restart apache sudo apache2ctl restart Voilà! sources http://stackoverflow.com/questions/13799932/how-to-allow-access-to-only-a-single-file

Configure apache to run a django framework based project [solved]

To serve django via apache, using mod_wsgi (recommended option by django documentation), proceed as follow: install apache mod_wsgi: sudo apt-get install libapache2-mod-wsgi-py3 ensure mod_wsgi is indeed into /etc/apache2/mods-enabled: ls -l  /etc/apache2/mods-enabled/ | grep “wsgi” create a python virtualenv for your project (see Run python virtualenv with Ubuntu) go to /etc/apache2/sites-available and create file myproject.conf: sudo vi /etc/apache2/sites-available/myproject.conf Paste following content: <VirtualHost *:80> ServerName mydomain.com ServerAdmin webmaster@localhost DocumentRoot /path/to/myproject ErrorLog ${APACHE_LOG_DIR}/myproject.error.log CustomLog ${APACHE_LOG_DIR}/myproject.access.log combined Alias /static/ /path/to/myproject/static/ <Directory /path/to/myproject/static> Require all granted </Directory> <Directory /path/to/myproject/myproject> <Files wsgi.py> Require all granted </Files> </Directory> WSGIScriptAlias / /path/to/myproject/myproject/wsgi.py WSGIDaemonProcess myproject python-path=/path/to/myproject:/path/to/myproject/virtualenv/lib/python3.4/site-packages WSGIProcessGroup myproject </VirtualHost> […]

Apache: set php include_path from within apache

To define your own php include_path from within apache, it’s pretty easy. In a .htaccess file, simply define the following: php_value include_path .:/my/path/here sources http://www.webdeveloper.com/forum/showthread.php?t=149130

Apache: redirect content to other folder based on url

Let’s say you want to store a js library (like dojo) outside your website folder so that your backup is not polluted by this heavy framework. You can configure apache so that every query starting with /dojo/ will be directed to this folder instead of default application folder. Note: using subdomains creates a huge overhead with dojo => prefer this url-based redirection. Here are the steps, they rely on mod_alias apache module, so ensure it is activated: in httpd or .htaccess, define the following rule: Alias /dojo <path_to_dojo_folder> <Directory <path_to_dojo_folder>> AllowOverride All Order allow,deny Allow from all </Directory> Note1: don’t […]

server hacked

Recently my server was hacked, looking at apache logs, I found weird entries close to hack date (determined through creation date of /var/www/.bash_history file which contained bash-history of nobody user with corresponding hack instructions): – – [17/May/2010:21:26:33 +0200] “GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1” 400 511 “-” “-” – – [17/May/2010:21:31:21 +0200] “GET /w00tw00t.at.ISC.SANS.DFind:) HTTP/1.1” 400 511 “-” “-“ Such entries appeared many times, with different ip-address. What’s strange it’s that it looks like hacker was looking for a flaw in phpmyadmin, with many attempts to access it: – – [17/May/2010:18:17:24 +0200] “GET /phpmyadmin/config.inc.php?w=uname HTTP/1.1” 200 182 “-” “curl/7.18.2 (i486-pc-linux-gnu) […]

Apache: redirect to subdomain via .htaccess

Redirecting to subdomains is pretty easy with apache using <VirtualHost> directives. Problem is that such directives cannot be set in .htaccess file (only in .httpd.conf or equiv.) so we must find a workaround when server config files are not accessible (as with shared hosting…). The solution is to use mod_rewrite possibilities, provided your host activated .htaccess & mod_rewrite in apache… In my case, I simply want to redirect all queries without ‘www’ subdomain to ‘www’ subdomain. Here is my .htaccess content: RewriteEngine On RewriteBase / RewriteCond %{SERVER_NAME} ^mydomain.com$ [NC] RewriteRule ^(.*)$ http://www.%{SERVER_NAME}/$1 [L,R=301] Line by line, we did this: first […]

update of apache2 – websites no longer working

When I updated apache2 to a newer version, suddenly my previous webistes no longer worked! (in fact, my subdomains did not work). What I had to do was the following: reinstall ‘libapache2-mod-php5’ package – previous apache2 php module had been automatically removed and linking back to previous version of the module did not work sudo apt-get install libapache2-mod-php5 edit all my /etc/apache2/sites-available/* files and replace <VirtualHost *> with <VirtualHost *:80> for more info, read http://www.debian.org/releases/stable/i386/release-notes/ch-information.en.html#apache2 restart apache sudo /etc/init.d/apache2 restart That’s it. sources http://www.debian.org/releases/stable/i386/release-notes/ch-information.en.html#apache2

keeping your server’s clock up-to-date

Problem with computers is that day after day, they depart from real time. Today I checked the hour on my server and it returned “Thu Apr 15 17:25:40 CEST 2010” when in fact it was “Thu Apr 15 17:16:35 CEST 2010”, that is it suffered from close to a -10-minute lag! This is not good because when apache, db or other third party application is logging data, it’s not logging it on appropriate time. Moreover if later on you synchronize your time and by doing so “go back in time” then old entries becomes new entries and your really new […]

control mysql & apache logging level

If you want to avoid ‘too many connections’ error due to a full-disk error, you should consider modifying your mysql/apache log settings. MySQL First we will check our running log settings, then we will see how to change them permanently. To do this, we will need the help of ‘mysqladmin’ available within mysql-client package sudo apt-get install mysql-client-5.1 update this command to match your mysql version mysqladmin variables -u mysqlusername -p  | grep log then enter your mysql user password when requested In my case: | log | OFF | | log_bin | OFF | | log_bin_trust_function_creators | OFF | | […]

apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName

When I start apache (or run “apache2ctl configtest”), I get this error: apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName I tried to set only one servername in /etc/hosts but even this failed. I added a server name to /etc/apache2/sites-available/default but it did not work either. To get rid of error message, I created an ‘httpd.conf’ file (/etc/apache2/httpd.conf) and filled it with: ServerName localhost Error message disapeared! sources http://wiki.apache.org/httpd/CouldNotDetermineServerName