At some point either during development or setup of a farm, you might have to remove SharePoint 2013 and re-install. Like 2010, the SharePoint uninstall does so pretty cleanly but with some caveats.
For one (just like 2010), the SharePoint databases are not removed. This is so that you can remove a server from the farm without affecting others. However, if you are truly removing SharePoint (i.e. a single server or to do a re-install), you have to manually delete all of the DB’s created for the various services, etc. directly using SQL Server Management Studio. This includes the SharePoint Config database.
However, SharePoint 2013 also installs a number of other services within the SharePoint 2013 Products Preparation Tool – one of these happens to be the Microsoft AppFabric 1.1 for Windows Server. AppFabric was developed for Azure and is a set of integrated technologies that makes it easier to build, scale, and manage Web and composite applications that run on IIS. SharePoint 2013 makes use of these services (thus why required) through the Distributed Cache Service.
When removing SharePoint 2013, it can have an adverse impact on the AppFabric setup. SharePoint creates its own ‘Cache node’ to coincide with SharePoint. This directly affects the web.config files across the system and sites. It doesn't ALWAYS happen but when it does, it’s a real pain.
The problem comes in when you attempt to re-install SharePoint; it would appear that the AppFabric settings are not picked up during the new installation which unfortunately causes both to fail. You can get SharePoint installed, but you’ll see problems when you attempt to add Services like the Access Service. Unfortunately, SharePoint simply gives you one of those simplistic “error has occurred” pages and looking into the ULS log doesn’t give you much. In most cases, it will simply indicate ‘access is denied’ even when you are logged in as the Farm Administrator account.
If you do have this problem, the quick fix is here is to uninstall SharePoint then uninstall AppFabric 1.1 but of course, there is a gotcha. If you attempt to remove the AppFabric, it will indicate that it will not delete the existing configuration (i.e. settings in the web.config files).
So, I am not a big fan of messing with web.config files, especially with SharePoint (since it keeps the web.config in the DB anyway), it turns out Microsoft was wise enough to provide us with a UI tool to do this. Full details can be found under the MSDN article here: http://msdn.microsoft.com/en-us/library/ff637683(v=azure.10).aspx.
More useful are the cleanup instructions found here: http://msdn.microsoft.com/en-us/library/ff637741(v=azure.10).aspx – in this article, it includes a link to the AppFabric Uninstall Cleanup Tool – this is a small application that will do the cleanup for you and prevent having to manually edit anything.
So you might think you are all set – au contraire! Turns out that the AppFabric uninstall has a bug! Oh what fun!
So to sum it up, a proper uninstall/re-install (again, when you have this problem – if the AppFabric is working, no need for this) is as follows from start to finish:
1) Uninstall SharePoint 2013 from the web front end
2) On SQL Server, delete any databases that were created by the previous installation (or locally if using SQL Express)
3) Uninstall AppFabric 1.1 from the web front end
4) Use the AppFabric Uninstall Cleanup Tool to remove the web.config entries (again on the web front end server)
5) Reboot the web front end server
6) Login to the front end server and from the SharePoint 2013 Setup, run the SharePoint 2013 Products Preparation Tool – this will detect that the AppFabric is missing and try to install it again
7) When the process completes, it will ask for a reboot; on restart it will start up again – however here’s where it gets tricky:
a) If the process runs through, starts up on reboot and simply finishes, you are fine.
b) If the process starts up again and tries to install the AppFabric (again) then asks for a reboot, the problem is that the AppFabric uninstall didn’t complete. In effect, the Prep tool will continually run at startup and ask for a reboot every time (but AppFabric WILL NOT be installed). So when this happens, you have to do some additional steps to clear it out:
i) First verify in the Prep Tool message window that there were no changes
ii) Open the “Start” folder (All Programs > Start), right click on the Microsoft SharePoint 2013 Products Preparation Tool link and delete it (Or you can do a reboot and when the Prep tool restarts, click Cancel):
iii) Reboot the server – the Prep tool should not restart
c) Now back to why AppFabric has a problem – it turns out that in the background, the AppFabric installation is failing with an “MSI Error 1603 installing AppFabric 1.1” (you’d see that if you tried to install AppFabric by itself) – to fix this:
i) Open the Registry Editor (Start > Run… > Regedit) (disclaimer: make a backup before you make changes – if you don’t know how, you should get someone that does!)
ii) In the registry editor, find the ‘PSModulePath’ ** key HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/Enviroment/PSModulePath – you can search for PSModulePath but make SURE you have the path correct (there is more than one!)
iii) Delete the PSModulePath key:
iv) Reboot the server
v) Login to the front end server and from the SharePoint 2013 Setup, run the SharePoint 2013 Products Preparation Tool – this should again detect that the AppFabric is missing and try to install it again – when complete it will request a reboot
vi) On the restart, login again – this time the Prep tool should complete and when you click Finish will NOT require a reboot
** BTW: Kudos to Lucas Massena for finding the AppFabric 1.1 uninstall bug fix: http://social.msdn.microsoft.com/profile/lucasmassena/?type=forum&referrer=http://social.msdn.microsoft.com/Forums/en/velocity/thread/561f3ad4-14ef-4d26-b79a-bef8e1376d64
8) When the Prep tool completes successfully, you can re-install SharePoint from scratch including creating new databases for the install
Good luck on this one!