Tag Archives: apache

apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 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 127.0.1.1 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

create localhost subdomains with apache & linux/windows

If you develop multiple websites, you may need to create localhost subdomains, so that you can access them in your web browser using a similar uri: http://site1.localhost where ‘site1’ is anything you want. Creating localhost subdomains is a two-step process: you must declare your subdomain in HOSTS file. This step is very important, otherwise if you don’t do it, your browser will search the web (and not your local computer) to find your website and you won’t get anything. Under windows, HOSTS file is there: Windows XP : C:\WINDOWS\SYSTEM32\DRIVERS\ETC Windows 2K : C:\WINNT\SYSTEM32\DRIVERS\ETC Windows 98/ME : C:\WINDOWS Under linux, it […]

XSendFile not working with apache2

After having installed XSendFile module for apache2 (see installation of xsenfile module), I tried to call it from PHP (see sending huge file through php), and the file was not served. If this is your case, you should read you apache log (cat /var/log/apache2/error.log) and see if you have any error notification from xsendfile module. cat /var/log/apache2/error.log | grep xsendfile In my case, I had the following entries: [Thu Mar 05 23:39:03 2009] [error] [client 127.0.0.1] (20023)The given path was above the root path: xsendfile: unable to find file: <path_to_file>, aa=0 Well, message is not that clear, but if you […]

Installation of Apache2 xsendfile module

I tried to install xsendfile module for apache2 as explained here: http://tn123.ath.cx/mod_xsendfile/ Unfortunately, on debian, installation failed because httpd.conf is not packaged as expected. Fortunately, a samaritan made a .deb package ready for install! (see: http://www.screenage.de/blog/2008/02/22/libapache2-mod-xsendfile-processes-x-sendfile-headers-with-apache2/) Here are the steps: edit /etc/apt/sources.list and add the following two lines: deb http://ppa.launchpad.net/damokles/ubuntu hardy main deb-src http://ppa.launchpad.net/damokles/ubuntu hardy main save your changes and run “sudo apt-get update” if you’re successful, running “apt-cache search xsendfile” should return the following package: libapache2-mod-xsendfile – Module to processes X-SENDFILE headers registered by the original output handler Install this package: “sudo apt-get install libapache2-mod-xsendfile” link newly created apache […]

apache not parsing php files

problem I installed package libapache2-mod-php5 but apache2 still does not interpret php files as such and simply offer to download them. solution PHP module may not be enabled. Run sudo ln -s /etc/apache2/mods-available/php5.* /etc/apache2/mods-enabled Then restart apache: sudo /etc/init.d/apache2 restart F5 and your file should be served properly

apache2: apxs file not found

I’m installing php from cvs, and as explained in INSTALL, I’m looking for apxs file on my computer. Unfortunately it looks like it’s not here! (I’m running a debian with apache2 installed from .deb package) Running “apt-file find apxs” we find that it’s within apache2-prefork-dev package and apache2-threaded-dev package. PHP recommends not to use threaded version of apach2 and recommends using apache2-prefork version instead. Here we go: sudo apt-get install apache2-prefork-dev

Apache: AddType not working | change extension of php files

Change php extension If you want to change extension of php files (for example use .php5, .phtml or even .html), use the following apache directive: AddType application/x-httpd-php .html .php5 .phtml You can customize it (add all extensions you want, not only the one listed above) and put it in a .htaccess file or in your httpd.conf file. AddType not working If putting your AddType directive into a .htaccess file is not working (ie. apache is not calling php to parse the file), it may be because you have an “AllowOverride None” directive declared in your httpd.conf file. Turn it to […]

.htaccess not loaded

If your .htaccess file is not loaded (check you error.log to see if any error occurs, but if no entry is found, it’s simply not parsed), 99% it’s because parsing of .htaccess file has been disabled in httpd.conf. Look for your httpd.conf file (/etc/apache/httpd.conf or sthg like this, in debian any of your /etc/apache/sites-available files, edit the one matching your corresponding VirtualHost) and ensure that: AllowOverride All is set and NOT AllowOverride None (which disable parsing .htaccess). Make sure also that AccessFileName is not set to something else than .htaccess (its default value when not specified) otherwise rename your .htaccess […]

test apache configuration file without restarting apache webserver

You can test apache configuration files without restarting the webserver (pretty useful if you don’t want to crash your site!), do as follow: make your changes to configuration files run “sudo apache2ctl configtest” If everything is ok, you should see “ok” [sources] http://httpd.apache.org/docs/2.0/configuring.html

Apache: redirect from one subdomain to another

If you want to redirect from one subdomain to another (or from one virtual host to another) and have access to http.conf (or /etc/apache/sites-enabled) file(s), then simply do the following: <VirtualHost *:80> ServerName old.mydomain.com RedirectPermanent / http://new.mydomain.com/ </VirtualHost> Hint: to redirect all your requests from http://mydomain.com to http://www.mydomain.com, use the following: <VirtualHost *:80> ServerName mydomain.com RedirectPermanent / http://www.mydomain.com/ </VirtualHost> (do not forget trailing slash!) Restart apache (sudo /etc/init.d/apache2 restart) and try it! [misc] In apache doc, they say that <VirtualHost> directives requires at least two components: ServerName and DocumentRoot. Well it seems DocumentRoot can be replace by Redirect directive. [sources] […]