I don’t normally use Windows as my development environment, but after being handed a Windows 7 Fujitsu laptop at work, I set about getting my development environment up and running as fast as possible. XAMPP appears to be a popular way of setting up an Apache, MySQL and PHP stack, so I duly installed and then whipped open the C:\xampp\apache\config\extra\httpd-vhosts.conf file in order to add all my virtual hosts. Nothing too complicated in there, pretty much only defining a DocumentRoot and ServerName directive, along with a simple Directory block containing an Order and an Allow directive. Next up with the C:\Windows\System32\drivers\etc\hosts file which was edited to allow for my subdomain and that should have been that. I fired up the XAMPP console, started both Apache and MySQL, and pleasingly http://localhost/ worked first time in my browser. Then I attempted to access my virtualhost – and nothing. Or rather a 403 denied access error message courtesy of my browser. What followed was more than a hour of searching and tinkering with my setup, exploring folder security properties, directory name structures, config file alterations, all to no avail. Instead the “client denied by server configuration” error continued to taunt me at every turn. I went to bed a frustrated man, and the next morning after an early rise and shine, I pulled out my chair and tackled the problem anew. And success! The problem lies in the restrictive XAMPP httpd.conf file where it specified the “default” with a very restrictive set of [...]
Unfortunately domain names are seldom cast in stone when it comes to commercial products, because as with most things, people tend to change their minds further down the line. If for the last three years your web application has been running under the domain myapp.com but now the boss has decided that it should rather be running under myawesomeapp.com, here is but one method that can help ease your pain in changing the domain of your site. For this to work, we are assuming that you are running an Apache webserver which has the mod_alias module activated. The first step would be to create a new virtualhost for the new domain (myawesomeapp.com) under the sites-available apache2 directory and enable it using the handy a2ensite script (if you are running Ubuntu Linux). Next you would open up your existing site entry for myapp.com and change its contents as follows: <VirtualHost *:80> ServerName myawesomeapp.com RedirectMatch 301 ^(.*)$ http://myawesomeapp.com </VirtualHost *:80> Save your changes and run the following in order to reload Apache’s configuration: Breaking down what you’ve just done, basically you’ve instructed that for every request coming in to myapp.com, the server should redirect (with a permanent marker) to the new myawesomeapp.com domain but with the rest of the request string intact. What the documentation tells us: This directive is equivalent to Redirect, but makes use of regular expressions, instead of simple prefix matching. The supplied regular expression is matched against the URL-path, and if it matches, the server will substitute any [...]
I had a frustrating start on my first day back at work following my nice and relaxing vacation – all of a sudden it was reported to me that SVN commit and SVN update actions were now failing for the development team. What followed was a lot of frustrating troubleshooting, though thankfully I did eventually find the solution. My first port of call was simply to restart the relevant SVN server as well as our office network IPCop machine. Following that, I confirmed that the SVN server was behaving correctly when being used by external resources, meaning that the problem had to be between our network and the SVN server. However, many fruitless hours of trawling through logs and packet capturing with Wireshark turned up nothing. Then I stumbled across something interesting. By first tinkering with and then finally disabling Apache’s new-ish anti-denial of service module “mod_reqtimeout”, the SVN commit and SVN update actions were able to run again. Now the Apache changelog describes mod_reqtimeout as: “a module which limits the time Apache waits for a client to send a complete request. This helps to mitigate against certain denial of service attacks. In case of problems with slow clients, the timeout values can be adjusted in /etc/apache2/mods-available/reqtimeout.conf , or the module can be disabled with “a2dismod reqtimeout”. So one of two things must have happened: either apache was updated on the SVN ubuntu server, or our internal network has somehow slowed down. In any event, at least we can work [...]
The cURL library is a useful tool that allows you to connect and communicate to many different types of servers with many different types of protocols. If you implement a cURL operation in your PHP code and the web page spits out a “Fatal error: Call to undefined function: curl_init()” error message back at you, then it is probably safe to assume that the cURL library is currently included in your Apache, PHP stack. (To verify this, run a phpinfo() call and then search for ‘curl’. If it isn’t installed, then the search should return nothing). To install cURL in Ubuntu 12.04 using a terminal, enter: If the status messages returned after the two operations have completed look all successful, rerun your phpinfo() call and you should now be able to find a couple of curl entries on the resulting page. Nifty.
To set up a virtual host (vhost) under Apache on your Ubuntu server is relatively simple. First you need to create a config file under the /etc/apache2/sites-available directory. A good practice is to name this file the same as the folder you want to use to hold this virtual host’s web pages. For this example we want to serve up traffic coming in for www.mydomain.com, so we create a file called mydomain: sudo nano /etc/apache2/sites-available/mydomain The contents of which looks like this: <VirtualHost *:80> DocumentRoot /home/www/mydomain <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /home/www/mydomain> Options FollowSymLinks AllowOverride None Order allow,deny allow from all </Directory> ServerName mydomain.com ServerAlias www.mydomain.com ErrorLog /var/log/apache2/mydomain-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/mydomain-access.log combined ErrorDocument 404 /error_documents/404.php ErrorDocument 403 /error_documents/403.php </VirtualHost> With the file saved, next we enable the site by running: sudo a2ensite mydomain Finally, reload the Apache configuration with: sudo /etc/init.d/apache2 reload Done. (And if you are in the process of looking for a hosting server, you may want to check out different web hosting companies first to help you compare and find the most appropriate hosting account for you.)
The extremely useful mod_rewrite or rewrite module is not enabled by default on a new Apache web server install. Luckily, this turns out to be pretty simple to rectify.
Sometimes you make subtle changes to the configuration files of Apache, affecting certain aspects of the server’s performance but not others. To get these changes to the configuration files live, the standard route is to save your changes and restart the Apache service.
To add SVN repositories and give existing user accounts access to it is not entirely a one step process in Ubuntu. So this is how you do it…
First, browse to the folder in which you want to generate your SVN repository and create the respository folder:
A lot of the time, in order to quickly enable SSL for Apache in Ubuntu, servers make use of a self-signed certificates. These are pretty useful, though they do have a tendency to expire on you when you least expect it.
To renew this ‘snake oil’ certificate as Apache dubs it is actually quite simple.
Working with the web-based phpMyAdmin can sometimes be a bit of a lesson in frustration, particularly when you start bumping your head against its various limitations. One such annoying limit is the default 2MB upload limit applied for SQL file imports.
As a web developer I need to juggle a number of projects on my development machine all at once. The simple way to get around accessing these various sites is to set up a number of subdomains under localhost, one for each project.
Craig Lotter is an established web developer and application programmer, with strong creative urges (which keep bursting out at the most inopportune moments) and a seemingly insatiable need to love all things animated. Living in the beautiful coastal town of Gordon's Bay in South Africa, he games, develops, takes in animated fare, trains under whichever martial arts dojo is closest at the time, and for the most part, simply enjoys life with his amazing wife and daughter.
Oh, and he draws ever now and then too.
This is a collection of things that he has managed to find the time to scribble down since 2007.
Looking for Something?
Jump to Category: