PHP Web Server
(Information Technology,Programming)

My company does website design, among other things. In general, my wife does the design with Dreamweaver, and if there are any forms involved, I do the back end PHP work for the form validation and emailing the results to the customer. I’m not fond of this arrangement because I don’t like the way Dreamweaver deals with templates and such, but it works for my wife. So I complain about it and she ignores me because Dreamweaver is a perfect solution for her. Incidentally, she does her work on a Mac Pro and I do mine on Linux.

We also have a slew of applications I’ve written to handle day-to-day tasks (e.g. calendar, address book). And then there are the software pieces which run the back end of our business, like customer management, invoicing and A/R, payroll, A/P, etc. Also applications I’ve written.

All these sites/applications live on an internal Apache2 web server behind our firewall. Our customer sites which reside on our internal server are just copies of the customer sites on the Internet. We maintain these copies for two reasons: 1) we can do development internally and view the finished result before we upload it, to ensure it performs the way we want; 2) it gives us a pristeen copy of the customer site in case something goes wrong on the Internet.

Now here’s where development headaches come in. Years ago, when I set this system up, I didn’t think the thought through. I’m a developer, so I should have known better. My wife doesn’t handle administrative details well. Ideally, she would make a copy of a website on her Mac, hack it, and then upload it to our internal web server. Test it. Then upload it to the Internet. However, if I let her copy a site to her local machine and edit it, I can be sure she won’t always copy her edits back to the internal site before she uploads it to the Internet. So I have to somehow either force her to do it my way anyway, or make it possible for her to edit the sites in place on our local server.

If you stop and think about it, this presents an immediate problem. Apache2 runs under the www-data user/group. It generally opens files in read-only mode. But if it creates any files, these will be under the www-data user/group. The problem is that my wife can’t edit files owned by another user unless the permissions are exactly correct.

My (crappy) solution? Set all the files to my wife’s ID, so she can edit them in place. As long as Apache2 opens them read-only, it won’t care that they’re owned by my wife instead of www-data. As for my internal applications, I have to handle these a similar way. In order to edit them in place, I have to set file ownership to my ID. Apache2 won’t care until it tries to create a new file. (If the directory the file is written in doesn’t have the proper permissions, Apache2 can’t write to it in creating the new file.)

Let’s recap. My wife could develop locally and upload to our internal server before FTPing. But she won’t. So I have to make internal copies of the web files owned by her, so she can do direct development on our internal copies. Same with me. I do development directly on Apache2’s files. Not a good solution.

But I recently came across a solution which works far better, at least for me. PHP has a built-in web server. So I can copy the website to ~/public_html and hack away. When I’m done, I can copy the changed files over to our internal Apache2 server. Test, and then upload to the Internet. This make site development work the way it should. You edit locally, upload to the LAN copy and test. And then upload to the live site.

I’m trying to get my wife to follow this system. If she does, I can revert the ownership of our internal sites back to where it should be– www-data.

My point here is that the internal PHP web server makes proper web development possible. Yay.