MSVCR110.dll errors when running PHP

If you attempt to run php.exe on Windows you may get an error involving the following DLL.

MSVCR110.dll

The resolution to this is to install “Visual C++ Redistributable for Visual Studio 2012 Update 4”. Note that you should install the 32-bit version even if you are using a 64-bit operating system!

This can easily catch people out first time, however you can just install the 32-bit version over the top.

Install an MSI from a user account

Sometimes you might want to install an MSI on your Windows system, without being logged in as an administrator. Normally, you would just right click and select “Run as Administrator” but this option is not available on MSIs.

Instead, right click on “Command Prompt” in the start menu, then select “Run as Administrator”. Once this is running, use the msiexec command to execute the MSI.

msiexec /i Filename.msi

This will then run the installer using administrative privileges.

Netgear N150 WNA1100 on Windows Server 2003

If you’ve bought the Netgear N150 WNA1100 wireless dongle on the false promise that it is compatible with Windows Server 2003 and then tried to run it, you will probably get an error like the one below.

Not compatible with your OS

Luckily, there is a way around this. Once you’ve downloaded the driver, right click on it, go to the compatibility tab and select the run in compatibility mode check box and select “Windows XP” from the drop down.

Once done, re-run the setup and it should install.

ActiveRecord::ConnectionNotEstablished in Rails

I ran into this error while trying to get Ruby on Rails 3.1.1 which I installed from the Rails Installer to talk to MySQL. My stack is built from WAMP, so it might not have been as easily as it would be on a standlone MySQL installation.

Here is are the steps I took to fix it.

Edit Gemfile in project and add the following line.

gem 'mysql2', '< 0.3'

Rebuild the MySQL adapter with your version of MySQL.

gem uninstall mysql2
gem install mysql2 -- --with-mysql-config="C:/wamp/bin/mysql/mysql5.5.16/bin/mysql_config.pl"

Download the MySQL connector from the MySQL website.

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

Once you have the zip file, uncompress it and copy lib/libmysql.dll to the Ruby bin directory. Finally, go back to your Rails project and run the following command.

bundle install

I was finally then able to run a command such as the following.

rails generate model Something name:string

Without it throwing any errors up.

Firefox updater stuck in a loop

From time to time, Firefox might try to update itself and get itself stuck an a loop where every time you try and open it, it tries to upgrade itself, fails, closes and then you have to try and open it again and the same thing happens.

95% of the time, this problem is caused by Logitech webcam software.

I don’t know why, I don’t know how, but the problem has hit my system several times and every time after some googling, the suggestion to try and close my Logitech camera software comes up and as soon as I do, Firefox is able to upgrade itself and open fine.

Editing your hosts file

If you want to put custom entries in your computer’s DNS (for running addresses for a local server for example) you need to edit your system’s hosts file. On Unix systems this can be found at:

/etc/hosts

On Windows systems, you need to go to:

C:\Windows\system32\drivers\etc\hosts

To add a custom entry, first enter the IP address (if you’re running a local server you’ll want to set this as 127.0.0.1), then put a tab and then the host name.

Flex Builder unable to find Flash Player

If you are using Flex Builder on Windows, you may run into an error where Flex Builder says it is unable to find the executable for Flash Player. The error will look something like the one below.

Flash Builder cannot locate the required version of Adobe Flash Player. You might need to install the FLash Player or reinstall Flash Builder.

Do you want to try and run your application with the current version?

This will give you an attempt to continue dialog with a yes or no option. If you click yes then you would get another error similar to the following.

Cannot run program "C:\Users\chris\Desktop\flashplayer_11_sa_debug_32bit.exe": CreateProcess error=2, The System cannot find the file specified

You can fix this by following the steps below.

1. Go to the Adobe website and download the standalone Flash Player Debugger edition.

2. Open up Notepad and insert some text (literally, anything).

3. Save the file as dummy.swf on your Desktop.

4. Open your Desktop and right click on the file. Select “open with…”

5. Browse to the location of the Flash Debugger you downloaded and select it, making sure to tick the “always open these types of file” option.

From now on, you should be able to run the application from Flash Builder.

Getting started with IIS part 2

Make sure you read part I before enbarking on this second entry. For those of you who have read part I and are wondering what do I do next? Read on…

Virtual Directories

That is everything you need to know for customising the root directory. But that’s just the properties options. Next we are going to create a directory so that the folder ‘work’ will be mapped to a completely different directory. First close the properties box and bring to focus the Management Console if it isn’t already. Then find the root icon again. Now right click it and hover over the new > link. This should bring up a new link with an option that says ‘virtual directory.’ Click it and wait for the wizard to open.

Click next to skip past the welcome screen and you will be greeted with a box asking you to select an alias. This is simply a name for the directory which will be used. In this example we are using ‘work’ so write work into the box and click next. This means that it will be accessed from http://locahost/work. Next we are asked for a directory. If this is going to be a redirect then just add any directory and change it later. However if say you wanted to map this to My Documents then click browse and find My Documents. Click it and then click OK. The path will then be entered into the box for you.

Now click next again and you will be brought to the permissions screen. This is where you set the permissions and what can happen. Normally you can just click next again to pass it but this time check the box which says browse. Now click next again and finally click the finish button on the next screen to close the wizard. The directory has been created and can be seen on the list as a branch of ‘root.’

Now its time to test the new directory – open up your browser and point it to http://localhost/work so that the page loads up. This should, if you have done it correctly, bring up a list of all the files in you’re my Documents folder. Congratulations if it worked you have a virtual directory. If not then make sure you can find the directory under root and make sure the path to My Documents is correct.

Next go back to the Management Console and click root on the left. This should bring up a list of all the files and virtual directories on the right in the big box. In this box you should now find ‘work’ next to a little grey box icon. Right click on it and click properties. This will bring up a properties box named after the virtual directory.

The default selected tab on here is Virtual Directory. This basically does the same job as the Home Directory tab when we had the properties page for root on screen. The other tabs also match up to the tabs on the root properties although there are not as many as you do not have the settings for the entire site on top of the directory settings like you do when you are editing the properties of the root site.

Redirects

Finally I want to cover one more thing – setting up a virtual directory to do a redirect. To do this select Virtual Directory from the list of tabs in the properties for ‘work’ and find ‘a redirect to a URL’ from the list of bullet options at the top. Click this and all the directory information disappears to make way for redirect information.

The top box is where you enter a URL for it to redirect to. This can be a virtual directory on your computer although you cannot redirect it straight to a file. So if you wanted to link it to something in your unzipped folder on your hard drive you would have to set up a virtual directory which is set to your unzipped folder.

Here is my example. I have my directory http://localhost/work/ and the redirection URL I have entered is http://www.mworld.us/entertainment/fake.asp. If I enter this URL and don’t tick any boxes, when I enter in the address to my directory it will be replaced in the address bar by the direct URL which will go to the exact address I entered – and in this case bring up a 404 error page seen as the address is not real. The same happens if I have the box ticked saying ‘the exact URL entered above.’

However if I tick the box ‘a directory below this one’ the directory will remain in the will remain in the address bar as if it is the original directory. So I could reduce the address of http://localhost/files/folders/stuff/complext/somefile.php? variable1=somevalue&variable2=othervalue to http://localhost/somefile and it would display the same file but users would see http://localhost/somefile in their browsers.

The final tick box is ‘a permanent redirect for this resource,’ Normally redirects such as the above are temporary as the file is still in the other location and you are just masking it However if the file has moved and you want to set up a redirect to another location so your users can find it, that is when you tick the box to say – never come back to this redirect address, always use the address its redirecting to.

Final Tasks

Right, that’s done. If you don’t want that directory hanging around any more then close the properties window if it is still active and find the directory in the list in the Management Console. Then right click its name and click delete to remove it.

There is one more important thing which you will probably use when using Internet Information services. That is stopping and starting your website. If you click root again in the tree view on the left you will notice three black buttons at the top become click able. These allow you to stop, start and pause your web server. The web server only works when it is running. So if you don’t want it running then click stop. Click start again when you want to reactivate it. This is useful when your server stops delivery pages because it’s moaning of ‘heavy traffic.’ If this is the case click stop, pause for a second or two then click start again.

Conclusion

Hopefully this should get you started with the basics of internet information services. There is lots of fun to be had experimenting and playing about with the different settings so my advice is just have fun and see what you can do.

Getting started with IIS part 1

Internet Information Services is by far the most popular server for Windows; and not without good reason. Personally I do not know what the people who recon Apache is more configurable are on about. They should really take a look at the properties page of a website on IIS. But complaining about them is another story; we are fear to get to grips with IIS.

For those of you with Windows Server 2003 you will have IIS 6.0. However seen as anyone with Windows Server 2003 will know that they are doing anyway and most users will have Windows XP or 2000, I am going to use IIS 5.1 as my model. This should cover most versions fine anyway as the interface changes have not been radical to the best of my knowledge.

Introduction

The key to management of IIS is the Management Console. This will have a toolbar along the top, a tree view on the left and a files list on the right at the bottom which is the main section. As standard when you open it in the tree view you get Internet Information Servers with the name of your computer in a branch. In a branch of your local computer you will then have Web Sites, below that FTP sites if you have added that on although it’s not installed as default and finally Default SMTP Virtual Server.

If you don’t see this then click the box with the plus in on the left of them to expand them so that you can. The next thing to do is to do the same so you can see a list of your websites. There should only be one unless you’re running a Windows 2000 Server. The one that does exist is called root. This is your default website so let’s start configuring it to your settings. Right click on it and click properties.

Customising

This will bring up the properties box with root properties at the top and no less than eight different tabs full of settings for you to configure the website. The first section of the already selected ‘website’ tab is how the site is identified. Leave the description as root. As next one, IP addresses allows you to specify different IP addresses for different sites although one you will only have one IP address most likely and two all IP addresses go to the root folder by default anyway. So seen as we do not have multiple websites this is not a problem.

The connections box is something that can be left alone. Although if you are having problems with time outs and pages not loading you may want to play about with the seconds before timeout. Below that is the box which enables server logging. I always find these useful and use the standard W3C format to log activity in a file.

Next up click the ‘ISAPI Filters’ tab. You will probably end up with a blank list with a few buttons. This is where you can install, enable and disable ISAPI filters. An ISAPI filter is a program that responds to events during the processing of an HTTP request. In other words special executable scripts that do things when a page is requested. An example of this is PHP although there are other ways to use PHP. But as an example, when a page is requested the ISAPI filter responds and sorts out the PHP code delivering HTML to the user.

Next click the ‘home directory’ tab. This gives information on where the files are on your computer. The top box gives you three options about where the files are. Even the directory should lead to a folder on this computer, the directory should lead to a folder on a network computer or it should redirect to a different address. The first two allow you to choose a file path, the first starting with drive:\ and the second starting with a network path.

These first two options also have tick boxes about what can be run and what cannot. Read just allows users to access and view files so keep this one ticked. Log visits and index this resource should remain at their default. Directory browsing means that users get a list of the files in the directory which they can click on to visit. Sometimes this is useful but if you don’t want visitors getting a full list of all the files then don’t tick it. Finally write allows files such as text files, databases, or anything else you want scripts to be able to add data to, to be changed.

Generally the application settings below this can be ignored too. The only one you may want to change is the application permissions allowing you to disable all scripts or allow scripts and executables. Or have a happy mix between. I always leave this at default although if you want to run some executables then you may want to disable them or if users can upload scripts to this directory you may want to disable this.

Next up is the ‘documents’ tab. This one controls the list of documents that are delivered as the default document of a folder if no file name is specified. You can add as many different possible file names as you want to this box by clicking add and typing the file name including the extension in such as home.html. You then order them as you want as the higher they are the higher priority they have. A have several in mine:

Index.asp
Index.php
Index.htm
Default.asp
Default.php
Default.htm
Index.html
Default.html
Iisstart.asp

This enables me to use all the standard file names for different sites and the homepage will still be delivered as the default document. Iisstart.asp is a default one added in by IIS as if no other documents are present you will be taken to an introduction page when you first point your browser to IIS before you have set it up. You can remove that one if you wish.

The other option under this tab is document footer. This enables you to have a footer document served up at the bottom of every page. This may be useful say for a free web hosting company who wishes to add an advert or link to their homepage to the bottom of every page. Or even if you wanted to include a navigation link but didn’t want to have to update every page when you added or changed a link.

We are getting deeper now and beyond the standard options you are likely to use. But I will give a quick overview of what else can be done too in the properties window. The next tab is ‘directory security.’ This enables you to have secure communications, restrict websites and IP addresses and others.

The ‘HTTP Headers’ allows you to set how often pages expire. If your content is only updated say every 5 minutes or for instance if you only want new messages posted in a guest book to be updated every 5 minutes then you can set it so pages in this directory are only refreshed every 5 minutes. A new page will be generated every 5 minutes and this version will be delivered from the cache until the next update.

‘Custom errors’ allow you to direct users to different pages depending on what error happens. For example if you wanted to send them to a personalised error page when a page cannot be found with a dancing Jesus saying “this page does not exist’ then you would click 404 and then click edit properties. You could then choose the custom file.

Finally ‘Server Extensions’ allows you to enable use of authoring such as Front Page change version control and performance and specify settings for things such as emails and security settings. Luckily if you get stuck there is a help button at the bottom of the properties window ;).

Configuring PWS (Microsoft Personal Web Server)

Personal Web Server is pretty easy to configure. Even back in 1995 when it was all web based. However in this article I am looking at the PWS version which was shipped with Windows 98 and ME software.

The basic’s to it are very simply. In fact the only page of options we will be looking at is the advanced page. Open up your personal web server consol from the system tray and click advanced down the left hand side.

You should now be presented with a tree like view with the top root document and several sub folders. From here you can add virtual directories. Virtual directories are directories which aren’t really there but are instead linked to it.

For instance if you had two directories, your main website root C:\websites and a downloads directory which you wanted to be on your server at C:\downloads. Obviously you don’t want the move this folder into your other folder. And so you create a virtual directory so that http://localhost/downloads goes to C:\downloads rather than C:\websites\downloads.

Beware: Virtual directories override physical (normal) directories. So if you had both a virtual directory called downloads and a folder in your website root called downloads, the virtual directory would be used instead of the folder when using hyperlinks, etc.

In PWS you can create as many virtual directories as you like. Click add below the list of directories. You can also add virtual directories within virtual directories so you could set up http://localhost/downloads/games to go to C:\games rather than C:\downloads\games. To do this click on the downloads virtual directory before clicking new, rather than click the root directory and then clicking new.

You can change the properties of each of the directories including the root directory by clicking it and then click properties. Here you will probably be presented with a name for the directory (unless it is the root) as well as the file path to the directory.

You also have 3 tick boxes. Read which allows people to read the files in the server. You will almost always want to keep this ticked. The second one is script which allows the web server to run scripts. This is another one you will want to keep ticked.

The final one is write. This allows files such as text files and databases to have data added and removed this one. It’s a good idea to keep this one ticked if its your own server so you can run scripts such as ones that change database’s and is required if you want to alter any files.

There are also a few options on the main page of the advanced section at the bottom. One of these is “allow directory browsing.” This means that if a user goes to a folder, for example http://localhost, they will be presented with a list of the files and folders in the directory which they can click on.

Default document allows a file to be served as a kind of homepage when a user goes to a directory. For example if your default document file name was home.htm, when a user went to http://localhost, they would get home.htm if it existed.

The standards for default documents are default and index in which you should list several file formats. I use .asp .htm and .html though if you use other formats such as php and cfm you should list these too.

Conclusion

Personal Web Server has quite a few customisation options for each directory as well as the entire site and despite its problems with not being able to cope with high traffic or indeed anything above very little traffic, makes a great testing server especially for active server page developers.