Monday, June 29, 2009

PHP Error Logging

Enable php error logging
Edit php.ini
Find the variable "error_reporting"
Set "error_reporting = E_ALL"
Find the variable "log_errors"
Set "log_errors = On"
Find the variable "error_log"
Set "error_log = \path\to\valid\logs\phperrors.log"

Saturday, June 27, 2009

Install MediaWiki on Server 2008

MediaWiki successfully installed/running on Windows 2008 with the following:
Windows Server 2008 Standard SP1 (Virtual Machine)
PHP v5.2.9
MySQL v5.1.34
MediaWiki v1.14

Install IIS7 on Windows Server 2008
  • Open Server Manager
  • Add Role - Web Server
  • Click - Add Required Features
  • Next, Next
  • Select CGI option under Application Development
  • Click Install
  • Install update for FastCGI - KB954946

Install PHP v5.2.9-2
  • Create a new directory: C:\PHP
  • Extract the contents of to C:\PHP
  • Navigate to C:\PHP and change the name of "php.ini-recommended" to "php.ini"
  • Open php.ini and uncomment the following (uncomment by removing the ;)
    1. open_basedir (then add the following = "C:\inetpub\wwwroot"
    2. extension_dir (then change to show as "./ext"
    3. cgi.force_redirect = 0 (change from 1 to 0)
    4. cgi.fix_pathinfo=1
    5. fastcgi.impersonate = 1
    6. extension=php_mysql.dll
    7. extension=php_mysqli.dll
    8. upload_tmp_dir="C:\inetpub\wwwroot\WikiName\upload" Create a new folder in C:\inetpub\wwwroot\WikiNam named "upload"
    9. session.save_path = "C:\php\session" Create a new folder in C:\PHP named "session".
    10. IMPORTANT - Ensure that the session and upload folders created have write permissions for Users.
  • At command prompt navigate to C:\PHP and type enter php -info (ie C:\PHP\php -info) You should see the config of php or a lot of information scroll across the screen
  • Open IIS Manager
  • Open Handler Mappings
  • Select "Add Module Mapping"
    1. Request path = *.php
    2. Module = FastCgiModule
    3. Executable = C:\PHP\php-cgi.exe
    4. Name = PHP via FastCGI
  • Click OK, then Yes when prompted
  • Navigate to C:\inetpub\wwwroot and create a new file named phpinfo.php then edit the contents to show (I can't seem to get blockquote to work for anything so...) Starts with lesser than sign (no space) then ?php phpinfo(); ? followed by greater than sign (no space)
  • Open IE and navigate to http://localhost/phpinfo.php the site should display as PHP Version 5.2.9-2 with other config data on the rest of the page

Install MySQL v5.1.34
  • Run mysql-5.1.34-win32.msi to install
  • Typical install
  • Default Location
  • Configure the MySQL Server now option checked
  • Change to standard configuration
  • Install as Windows Service (Default)
  • Uncheck Modify Security Settings (This will be changed later)
  • Execute (note that it may have errors and fail, if so hit cancel)
  • From a command prompt navigate to C:\Program Files\MySQL\MySQL Server 5.1\bin
  • Type mysqladmin -u root password NEWPASSWORD

Install MediaWiki v1.14
  • Create new directory C:\inetpub\wwwroot\WikiName
  • Copy mediawiki-1.14.0 contents to C:\inetpub\wwwroot\WikiName
  • Run the following at a command prompt to grant permissions to the config folder (so that it can write the localsettings file) icacls %SystemDrive%\Inetpub\wwwroot\MediaWiki\config /grant BUILTIN\IIS_IUSRS:(W)
  • Open IE and navigate to http://localhost/WikiName/config/index.php
  • Enter Wiki name: WikiName
  • Database Config
    1. Database name = WikiName
    2. Username = root
    3. Password = MySQL root password
  • Click "Install MediaWiki!"
  • At the bottom of the next page you should see "Installation Successful!"
  • Close IE
  • Copy the localsettings.php from C:\inetpub\wwwroot\WikiName\config to C:\inetpub\wwwroot\WikiName
  • Open IE and navigate to http://localhost/WikiName/index.php You should see the Main page "MediaWiki has been successfully installed"
  • Delete the config folder
  • Change permissions on the WikiName\Images folder so that Users and IUSR have write access (for uploads to work)

Other Goodies to enable:
* $wgEnableUploads = true;
* $wgFileExtenstions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'pdf');
* $wgVerifyMimeType = false;

Disable reading by anonymous users
* $wgGroupPermissions['*']['read'] = false;
But allow them to read e.g., these pages:
* $wgWhitelistRead = array ("Main Page", "Special:Userlogin", "Help:Contents");
* $wgGroupPermissions['*']['edit'] = false;

Custom Logo
* wgLogo = "{$wgScriptPath}/ImageName.jpg"; (image saved in the WikiName root folder)

Thursday, June 25, 2009

Batch File Date/Time in Filename

I wanted to create a batch file that made a mysql backup with the dbname, date, time in the filename:

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
set timestr=%d:~6,4%%d:~0,2%%d:~3,2%_%t:~0,2%%t:~3,2%

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump" -u root --
password=YOURPASSWORD dbname > "C:\MySQLBackups\wikidbname\dbname-%timestr%.sql"

I then set it to look for and delete backups that where older than 14 days.

cd c:\MySQLBackups\wikidbname
forfiles /d -14 /c "CMD /c del @FILE"

Note: Make sure that there are NO FILES in the directory specified or they will be removed to include this batch file if you place it in that directory

Monday, June 22, 2009


After fresh install of Windows Server 2008 I was recieving this error on Windows Update

Running the following fixed it:

Saturday, June 20, 2009

MySQL 5.1 Backup / Restore

Here is the process I came up with to backup and restore a MySQL v5.1.34 Database

To Backup:
mysqldump -u root --password=PASSWORD dbname > c:\mysqlbackups\backupfile.sql

This can then easily be entered into a batch file and run via scheduled tasks for regular backups.

To Restore:
mysql -u root --password=PASSWORD dbname < c:\mysqlbackups\backupfile.sql

Note: mysql and mysqldump are located in the installation directories bin folder

It's also important to note that the generated backup file could be used in other DB engines since it is just SQL statements that recreate the DB and populate the data.

Wednesday, June 17, 2009

"The system cannot find the drive specified" Windows 7

Windows Vista was a bust imo, I dislike it like I disliked Windows ME. So this week I downloaded Windows 7 RC to see how it fairs.

Download was long, but I just let it run overnight and then continued with the install in the morning.

I installed Windows 7 RC into a Virtual Iron virtualization environment. Install was easy with no issues at all. I gave the install 2GB RAM, 2 CPU's at 2.66GHZ each and 20GB HD (the VI backend storage is iSCSI SAN). Installation was actually very fast and I was up in no time.

Icons in the task bar seem so large and take up to much space imo. Right click, properties, check use small icons. Only problem I see at this point is that each button needs several pixels shaved off each size so they aren't as wide anymore. Just an annoyance.

------------------- SOLVED - Solution below -----------------
Open cmd prompt, U: enter.... "The system cannot find the drive specified"
Hmm... Try it on XP, works just fine. K. Look under Computer and yep, all my drives where mapped from the domain logon script. I do have a U: drive according to the "Computer" view along with all my other normal mapped drives, but the U and I notice that my R drives do not have permissions. Being a Domain Admin I most definitely do have permissions. Strange, then I realized that the missing drives are DFS mapped drives... All non-DFS drives show up.
After a little research I figure out that using the Pre-Windows 2000 domain name is what doesn't work. If I enter the FQDN then it works fine.

This is actually more of an issue that it sounds like. With 250 users with shortcuts mapped out to the pre-windows 2000 domain name changing this will break a lot of links in documents and shortcuts.
This was actually a very simple fix. Simply remove the workstation from the domain and then rejoin. The Win7RC workstation had been restored to a prior state from a snapshot that was made on the iSCSI SAN. From the time that the snapshot was made to the time of the restore the computers domain password had changed. As such it no longer matched up and didn't have the proper permissions as a result.

Block unwanted sites with HOSTS File

The other day I got a call from colleague asking about antivirus software. During the conversation he had asked if I was using the HOSTS file from I wasn't but checked it out as it sounded very intriguing.

I've since then applied it to my workstation and I'm seriously considering pushing it down to other users.

Check it out:

Sunday, June 14, 2009

Citrix - Printer Errors

For a long time our environment has been plagued by an issue that "seems" random where Citrix user logs in, attempts to print from x application, fails with random error.

The errors usually go along the lines of

  • Select a printer
  • No printers installed
The user can't print from some applications while other apps still work fine. Usually the default printer in the applications that do print is not set according to what shows in the Printer Management screen. The printer in question is listed in the Printer Management screen.

Attempting to delete the printer from the Print Management screen results in a error "Cannot delete client printer" (the error is a little longer, but I don't have the exact error in front of me atm)

From there simply adding the printer again fixes the issue and even allows the printer to be deleted.

Looking at the users profile hive in the registry shows that the printer is listed under HKUSERS/UserSID/Printers and removing it here removes the printer in the Print Manager screen, then adding the printer back resolves the issue.

Things to note:
All drivers are either:
  • Native Drivers
  • Stress Tested
This does not occur with "auto-created" printers, but rather normally with printers that are assigned via Citrix print policies.

What really annoyed me was that the user couldn't delete the printer unless they re-added the printer first. This led me to believe that perhaps the printer registry keys do not have the proper permissions for the user to remove them (simular to the administrator access denied issue)

With this new informmation I began searching and found this:
which in turn quickly led to this:

I have since added the x2 to my DefaultPrnFlags key to make it now appear as 0x28004000

8000000 for the auto Creation event log errors and 4000 for adding the administrator permissions to the printers.

Time will tell if this fixes the problem for Windows2003 (note the article mentions that it is fixed in Windows2008 since w2k8 maps the printers differently)

Thursday, June 11, 2009

Disable UAC

Here's how to disable UAC in Vista, Windows 7, and Server 2008

Vista and 2008
Control Panel > User Accounts > Turn User Account Control on or off

Windows 7
Control Panel > System and Security > Action Center "Change User Account Control settings"
Use the slider up and down to set the UAC level.

Wednesday, June 10, 2009

Mass file copy

Recently I needed to copy a shortcut to a mass number of users. Since we utilize Citrix this made the task considerably easier for me. We redirect all user settings to a central location so I was able to easily script out the copy using a Text file that contained the names and Loop through all the user names.

Created the shortcut to be copied and the text file in the following format:

Dim fREM, fLOC, answer, cUser
Const ForReading = 1
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject")
answer = MsgBox("Run the file copy?", 1)
If answer = 2 Then
msgbox "You pressed cancel"
Set objTextFile = FSO.OpenTextFile("c:\ShortcutCopy\names.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
cUSER = Split(strNextLine , ",")
fLOC = "C:\ShortcutCopy\ShortcutName.lnk"
fREM = "\\path\path\path\" & cUSER(i) & "\path\desktop\ShortcutName.lnk"
msgbox "Copying to " & fREM
FSO.CopyFile fLOC , fREM, True
i = i + 1
Loop While i<20
msgbox "Copy completed"
End If

Friday, June 5, 2009

Citrix Printers - Creation Errors

Default installs of Citrix have creation logging turned on by default. This can cause a lot of excess errors in the eventvwr which generally are not useful.

Add the following

You can combine this one with the Access key by making the dword:08004000 Citrix Printers - Access Denied

Tuesday, June 2, 2009

Citrix Printers - Access Denied

By default I've found that in Citrix admins do not get permissions to auto-created printers.
Add the following