HowTo: OwnCloud on a Windows Server 2008 R2 (IIS 7.5)

Tutorials on ownCloud administration
Forum rules
You may post your own tutorials here. Please keep in mind that a moderator has to approve it before everybody can read it!

HowTo: OwnCloud on a Windows Server 2008 R2 (IIS 7.5)

Postby drhirn » Thu May 03, 2012 3:40 pm

Hi,

I tried to install OwnCloud on Windows Server 2008 R2 and Windows 7 the last days. Doing this, I ran into much trouble and it was a little afford to get it working. But now, after the 5th installation, I think, I've got a way, how it is working quite fine and I want to share it with you.

Please keep in mind, that there is a lot of security tuning to do with IIS before going online (use SSL, deactivate week ciphers, change application pool, ...). But here just a quick and dirty way to get OwnCloud up and running.

I used following prerequisites while writing this:

I assume the following:
  • You have root access to your webserver
  • You know how to use a command line (but I'll try to keep everything as simple as possible)
  • You start the command line with administrative privileges

Please click on any image to get a larger version.

Part 1 - Installation of IIS 7.5

Enable the Windows Server Role Web Server (IIS) by using the Server Manager (Add Roles).
Image

Choose Web Server (IIS)
Image

Install the following features:
Common HTTP Features
  • Static Content
  • Default Document
  • Directory Browsing
  • HTTP Errors
Health and Diagnostics
  • HTTP Logging
  • Request Monitor
Security
  • Request Filtering
Performance
  • Static Content Compression
Management Tools
  • IIS Management Console
ImageImageImageImage

Part 2 - Installation of PHP on Windows Server 2008 R2

Get the binaries from http://windows.php.net/download/ and unzip it to C:\php
Copy C:\php\php.ini-development to C:\php\php.ini
Open C:\php\php.ini in an editor and change or uncomment the following settings (asuming that you want to let users upload files up to 1GB size):
  • max_execution_time = 300
  • memory_limit = 1G
  • display_errors = On (if everything is working fine after installation, you MUST change this back to Off)
  • post_max_size = 1G
  • extension_dir = "ext"
  • cgi.force_redirect = 0
  • fastcgi.impersonate = 1
  • upload_max_filesize = 1G
  • extension=php_curl.dll
  • extension=php_gd2.dll
  • extension=php_mbstring.dll
  • extension=php_mysql.dll
  • extension=php_openssl.dll (since 4.5.1)
  • extension=php_pdo_mysql.dll (since v4.0)
  • date.timezone = "Europe/Vienna" (according to the timezone you're in)
(remember to restart IIS after making changes to php.ini using command-line command iisreset)

Part 3 - Installation of MySQL Community Server

Download the MSI Installer und do a Typical-Installation. Afterwards start the Instance Configuration Wizard.
ImageImage

Choose Standard Configuration to make things easier.
Image

Install MySQL as a Windows Service, choose the service name and make it launch automatically
Image

After that enter a password for the root account. Please use a secure one and write it down somewhere.
Image

Finish the installation
Image

Part 4 - Configure IIS
There are some things to do with IIS before we can use it with PHP and OwnCloud

Activate PHP and FastCGI
Please follow the steps on this blog post by Phil on MSDN Blogs: https://blogs.msdn.com/b/philpenn/archive/2009/07/19/deploying-iis-7-5-fastcgi-php-on-server-core.aspx.
appcmd.exe can be found under C:\Windows\System32\inetsrv
ImageImageImage

Add a MIME Type for SVG
I realized on some web servers, that there is no MIME Type for SVG files defined. Thus no OwnCloud Icons are shown on the web site.
You can add a MIME Type (File name extension: .svg; MIME Type: image/svg+xml) by firing up a command line and using:
Code: Select all
appcmd set config /section:staticContent /+"[fileExtension='.svg',mimeType='image/svg+xml']"

Image
You get an error message, if the MIME Type is already existing. Otherwise it's been added now ;).
Image

Add new Default Document
Because PHP applications are mostly using index.php as default document, you have to add this to your IIS Default Documents.
Do this by typing the following in to a command line:
Code: Select all
appcmd set config /section:defaultDocument /+files.[value='index.php']

Image

If you like, you can delete all other existing entries (you will not need it) using these commands:
Code: Select all
appcmd set config /section:defaultDocument /-files.[value='default.htm']
appcmd set config /section:defaultDocument /-files.[value='default.asp']
appcmd set config /section:defaultDocument /-files.[value='index.htm']
appcmd set config /section:defaultDocument /-files.[value='index.html']
appcmd set config /section:defaultDocument /-files.[value='iisstart.htm']


(Have a look at http://technet.microsoft.com/en-us/library/cc771439%28v=ws.10%29.aspx if you want to know more)

Change maximum allowed content length
To make IIS accept large file uploads, you have to change the maximum allowed content length. Do this by using the IIS Management Console.
On server level choose the icon Request Filtering from the middle pane. Then click on Edit Feature Settings on the right pane. Enter a value of your choice. To upload files up to 1GB, you have to enter at least 1.000.000.000.
Please refer to https://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits for more information.
ImageImage

Part 5 - Installation of OwnCloud
  • Download the latest stable release of OwnCloud here: http://owncloud.org/install/
  • Unpack the contents of the file to C:\inetpub\wwwroot
  • Only need in versions before 4.0.2: Open the file C:\inetpub\wwwroot\lib\base.php in an editor and search for "Redirect to installer if not installed". There is a bug in version 3 and 4 which is leading to endless redirects as long as OwnCloud is not configured because of the slash before index.php (Windows uses backslashes). In this line, change the first occurance of '/index.php' to DIRECTORY_SEPARATOR.'index.php'.
    It has to look like this:
    Code: Select all
    // Redirect to installer if not installed
    if (!OC_Config::getValue('installed', false) && OC::$SUBURI != DIRECTORY_SEPARATOR.'index.php') {
       $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
       header("Location: $url");
       exit();
    }
  • Allow user IUSR Read-/Write access to directory C:\inetpub\wwwroot\config
  • Since version 4.0.1: Allow user IURS Read-/Write access to directory C:\inetpub\wwwroot\apps
  • (Create folder C:\inetpub\wwwroot\data -> only before v4.0.1, add the user IUSR to NTFS directory security and grant him Read-/Write access.) Outdated since 4.0.1
  • If you want to store uploaded user content somewhere else than in C:\inetpub\wwwroot\data (which i warmly recommend you to do!), than create this directory (let's say D:\OwnCloud\data) and grant Read-/Write access to user IUSR
  • Fire up your browser, point it to http://localhost and finish the installation
ImageImageImageImageImage

Part 6 - Closing work
If everything is working well, you're ready for the last steps
  • User IUSR doesn't need access to C:\inetpub\wwwroot\config anymore, you can remove it from directory security
  • If you store uploaded user content somewhere else than in C:\inetpub\wwwroot\data you can remove the user IUSR from there as well
  • If you created it, delete info.php from C:\inetpub\wwwroot

That's it for now. This is the way it is working for me. Feel free to comment this entry.

Bye,
Stefan

(P.S.: Just realized, that version 3.0.3 has been released while writing this guide. I don't know, what they've changed and this guide is still ok. But I'll check tomorrow).

Update - 2012-05-04
Checked the differences between 3.0.2 and 3.0.3. It seems, that 3.0.3 is redirecting to HTTPS after logging in. This is a good idea, but isn't working until you create a HTTPS binding for your website. And - of course - a SSL certificate. Or you have a look at http://forum.owncloud.org/viewtopic.php?f=3&t=2420

Update - 2012-05-22 - Version 4.0
If you get an error 500 or PHP-Error (Undefined class constant 'MYSQL_ATTR_INIT_COMMAND') you have to enable extension php_pdo_mysql.dll in php.ini.

Update - 2012-06-05 - Version 4.0.1
Unbelievable, but sadly true: The "endless-redirect-bug" is still there. I've posted it in the forums, I've created an issue, I've postet in the mailing lists. It seems, it's not possible, to change one line in the code. :evil:
Good news: You don't need a HTTPS binding anymore and there's no need to create the "data" directory in C:\inetpub\wwwroot before setup.

Update - 2012-06-08
HowTo works on Windows Server 2012 (IIS 8) RC too

Update - 2012-06-11 - Version 4.0.2
Endless redirect bug finally fixed in v.4.0.2! :)
Thx a lot for that!
Last edited by drhirn on Mon Jan 28, 2013 10:39 am, edited 17 times in total.
drhirn
Starter
 
Posts: 92
Joined: Wed Apr 25, 2012 11:50 am

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby shadowwarrior » Fri May 04, 2012 8:36 am

Thanks Stefan for the great How-To. It works too on Server 2008 and IIS 7!
But a last problem stays in my installation:
[03-May-2012 23:43:01 UTC] PHP Warning: file_exists(): open_basedir restriction in effect. File(C:/inetpub/wwwroot/owncloud/apps/files/download.php?file=) is not within the allowed path(s): (C:/inetpub) in C:\inetpub\wwwrootowncloud\owncloud\lib\helper.php on line 41

I think the problem is the slash and backslash.The simpelst way is to outcomment the open_basedir in php.ini. But in my opinion its not the right way.

Do you have some ideas?

greetz,

Stefan
shadowwarrior
Newbie
 
Posts: 5
Joined: Thu May 03, 2012 7:57 am

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby drhirn » Fri May 04, 2012 9:42 am

Hi Stefan,

I played around a short time with open_basedir until I desided to leave it empty or comment it out.
In my opinion, it has to look like
Code: Select all
open_basedir = "C:\inetpub\wwwroot;C:\Windows\Temp\;D:\OwnCloud\Data"


(everything under C:\inetpub\wwwroot and only C:\Windows\Temp and everything under D:\OwnCloud\Data)

But, as you encountered, it's not working.

Maybe someone else with more knowledge of PHP might have an answer.

Sorry!
Stefan
drhirn
Starter
 
Posts: 92
Joined: Wed Apr 25, 2012 11:50 am

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby DarkSpider » Fri May 04, 2012 5:12 pm

Oh my goodness!
Installation on linux is easier and makes more sense;-)

- no Windows Licenses
- more flexible
- secure - if you know what you're doing
- easier to install and administer
- and guys -> a open plattform !!!

my favorit -> linux !!! ;-)
User avatar
DarkSpider
Beginner
 
Posts: 31
Joined: Sun Apr 15, 2012 2:39 pm

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby drhirn » Fri May 04, 2012 5:49 pm

You're right. Although I'm not sure, if it's really more secure.
Anyhow, that's not the topic here ;)
drhirn
Starter
 
Posts: 92
Joined: Wed Apr 25, 2012 11:50 am

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby br103 » Wed May 09, 2012 10:54 pm

Hi,

I try as well to get it running under Windows 7 (Ultimate) in a vmware environment. So far so good I followed all the necessary steps.
But I am unable to create a ownCloud admin account and there is also no config file written after the admin account installation process. It simply starts always from the beginning.
I tried mySQL, SQLite, the last stable ownCloud version as well the actual developer one. To get at least the "Create an admin account" screen I changed the true to false and also back and tried as well to comment it out:
Code: Select all
// Redirect to installer if not installed
if (!OC_Config::getValue('installed', true) && OC::$SUBURI != '/index.php') {
   $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
   header("Location: $url");
   exit();
}


And here is the debug output:
Passed Tests (6)
  • PHP Version:5.3.12
  • Server Software:(IIS) Microsoft-IIS/7.5
  • php.ini:upload_max_filesize:2M
  • php.ini:post_max_size:8M
  • php.ini:memory_limit:128M
  • File upload limit:Upload files up to 2 MB
Possible Problems (2)
  • File Upload:Please check your settings (see warning below)
  • Config (Writeable):Config is missing. Writeable: Yes
No Critical Issues.

So for me everything looks fine to get the admin account created.
Does anybody have an idea?
br103
Newbie
 
Posts: 3
Joined: Wed May 09, 2012 10:39 pm

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby drhirn » Thu May 10, 2012 8:26 am

Does the database get created?
drhirn
Starter
 
Posts: 92
Joined: Wed Apr 25, 2012 11:50 am

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby br103 » Thu May 10, 2012 10:46 pm

Have a look here:
[Bug?] Problem? Install IIS/Win7 3.0.3 (http://forum.owncloud.org/viewtopic.php?f=3&t=2420)
This helped me a lot now it is working! :D
br103
Newbie
 
Posts: 3
Joined: Wed May 09, 2012 10:39 pm

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby drhirn » Fri May 11, 2012 8:10 am

This is, what I suspected ;)
I already created a bug report concerning this.
drhirn
Starter
 
Posts: 92
Joined: Wed Apr 25, 2012 11:50 am

Re: HowTo: OwnCloud on a Windows Server 2008 R2

Postby mrbell1984 » Fri May 11, 2012 3:12 pm

yey! first time I configured this platform and got it to work with the exact guide. Did have the redirect bug in Safari but cleared that up no problem.

I have incorporated it into a test bed with webDAV / Moodle 2.2! repositories! and it works fully!

Cheers you lot! :D
Last edited by mrbell1984 on Wed Feb 20, 2013 4:21 pm, edited 1 time in total.
mrbell1984
Beginner
 
Posts: 19
Joined: Thu May 10, 2012 7:02 pm

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests