Wednesday, January 30, 2008

Warning: I am able to write to the configuration file: Windows, Helm, Zen Cart/OS Commerce, and File Properties

Ok, so I am not too proud to admit that I am moving from a linux box to a Windows environment for many of my projects. Suffice it to say that it was not originally my idea and it ends up being a complex situation of cost and performance. In my defense, the windows hosting that I am using has newer versions of php and mysql and is a clustered, load balanced system as opposed to the single linux box. I was kicked off the linux box for having too many domains and taking up too much processing power, but that is another post I will make later.

In any case, I was porting over my Zen Cart installations to the windows environment. And everything went fairly smooth until I ran into the
"Warning: I am able to write to the configuration file:"

As I did research, i found this was supposed to be an easy fix of setting the file permissions to 644 or 444. Well low and behold, this was actually not that easy in my situation: I tried to set these permissions through dreamweaver, filezilla ftp, and then even through the IE Ftp interface... and still no luck. I went in through helm and tried to use the file manager, but it does not allow for setting file permissions.

I ended up putting in a ticket to my hosting company to see if they can help. Apparently all you need to do is look at the file from the OS, right click on it and then set to read only- and voila you should be fine. Well, I realized I did not want to have to rely on my hosting company for changes to these files every single time I want to update or change configuration (which would not be often, but I have a few other installations of zen cart I wanted to do on this server).

As I was waiting for response, I came up with the idea to try to set the file permissions through php or asp. I set out on a quest and found some code which I altered ever so slightly to get to work on my system... Here it is. Just make a setfilepermissions.asp page on your server. This page will just do one thing and this is to set the filepermissions to readonly. You will have to alter the code to make it dynamic or set the file back from read-only.

If you do add or change it, please post it here. Thanks!


......................................


response.write "i am in here"


Dim strSaveFilename
'As String

Dim scrFSO
'As Object 'Scripting.FileSystemObject
Dim scrFile
'As Object 'Scripting.File

'i used absolute path which worked for me
strSaveFilename = "c:\domains\your domain here\wwwroot\includes\configure.php"


' Set up Scripting variables
Set scrFSO = CreateObject("Scripting.FileSystemObject")
Set scrFile = scrFSO.GetFile(strSaveFilename)

' Set file to be read-only
scrFile.Attributes = 1 'ReadOnly

' De-reference variables
Set scrFSO = Nothing
Set scrFile = Nothing

response.write "
done setting permissions!"

Labels: , , , , , , , , , , ,

Saturday, January 12, 2008

server crash!!

So I run a few different websites with a few different companies. I have been buying up web domains or what I'd like to call virtual estate. But that is neither here nor there really... as I would like to be spending my time doing research on great domain names to buy up. Unfortunately at about 4:00 am I was going up to bed after a long night of watching bad movies and configuring domains. I noticed something was wrong with the server. I tried to login remotely and no dice... This is my personal server, where I do most of my development and host a few smaller sites. Luckily the financial impact is somewhat minimal at this point, but the frustration has taken it out of me.

As it turned out the server was toast, something happened to the boot sector and the OS, which had been suffering from another semi crash a few weeks ago, had decided to give way. It took me quite a long time to fix it as I was actually gullible enough to believe that I would be to able to repair the os properly. Well, I ended up re-installing SBS2k3... and now as I think back, I would recommend that if at all possible, go with Windows Server Standard Edition 2k3. Too much overhead with what I have deemed useless gadgets and services that are great for a small to midsize company, but not ideal if all you want to do is host a website and SQL Server. Why did I sign up for SBS then? It was a deal with the server.

So the quick lesson... code in php, use XAMP ;).

Just kidding - that's my preference, but I have a few clients that work with SQL Server/MSDE (and a few legacy systems I developed in classic ASP) - so that's not really a choice.

Anyhow, with all the frustration and and work to completely reinstall I came up with a few tips that might help - especially if you are trying to salvage your data:

- try to install a new os on a different partition. Do not create a new partition at this point. It is possible, but not likely you will succeed in creating a new partition AND save all your data. Didn't you make multiple partitions when you installed the system? Oh.. well, this is a good reason why you might want to do that.

- if you do not have a new partition to work on, or you really want to try to repair your system, try to the system repair with windows. Take out your cd-rom, insert it and boot with it. Do not press f2 on load up for the automated system restore... you will have to let the blue screen load until it prompts you if you want to (R)epair. You wan to try to repair your system (keep your eye on the screen).

This will overwrite all your major system files and try to restore your system from initial installation. If this is successful, you might get your system to boot, but you will then have to reapply pretty much all patches, service packs, and perhaps reinstall several applications.

I am no expert , more of a crazy mad scientist, so don't blame me if you mess your system up even further.

- upon finally loading the system, I was able to reinstall SQL server. If you know this trick, move on. But you can always go to databases, right click on databases- and choose the actino "attach database" file directly from enterprise manager. The system will prompt you for the location of hte data files. You can take the databases from your crashed os, and just attach them again. Although if you have sustained system damage, you might want to consider moving the files to a clean location.

- if you have mysql as well... also on the server... you can take the datafiles folder and copy and paste all those datafiles into your new mysql datafiles folder. Mysql Admin should recognize them the next time it checks the folder.

This saved me quite a bit of time as to how I was going to get the latest data from the databases since my db backups were not as current as they could have been.

- I was also able to reinstall FTPZilla Server to the same exact folder it was installed in previously, and this saved me from having to reconfigure.

- also had quite a bit of trouble getting php to work. I had it previously downloaded and tried to use the files I had previously. I took the latest version from Php.net and it worked fine. Normally, I like to archive versions I have worked with in the past for easy installation and recovery such as this case. Pros: For the installation of MySql, this was really handy. I tried searching online, and I am not sure what MySQL is doing, but they are making it seem harder and harder to find the open source free versions. After looking on my archive drive, I got it installed in 2 minutes. On the other hand, Sometimes trying to use older versions doesn't work in your favor to save time, as in the case of PHP.

- Now I'm running all sorts of checks, defrags, and drive analyses... but the server is back up and running. Hoping for a better Day tomorrow.

Labels: , , , , , , , , ,