- Notifications
You must be signed in to change notification settings - Fork0
hbswift/Laravel-Windows-Server-2012
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
During my time at a contracted job I had to create an internal web application for onboarding/offloading employees. I chose to use the Laravel framework and was provided to host the project on a Windows Server 2012 R2 using IIS as well as MSSQL Server 2012.
- Opening the Server Manager we head over to the top right corner.
Manage -> Add Roles and Features- Skipping the Features Tab
- In Role Services under Application Development check CGI
- Install
You will need to install the extensionURL Rewrite. I'll be using x64 architecture for my project but please select the appropriate version for you.
PHPWe will be using thex64 Non Thread Safe version since we will be running PHP in Fastcgi mode. Unzip this intoC:PHP.
You will need to copy either the production or developmental .ini file and save it toC:Windows. You may need to run your text editor with admin permissions due to the file location
extension_dir = “ext” (enable this if you’re going to use extensions)fastcgi.impersonate = 1 (enable this)cgi.fix_pathinfo=1 (enable this)cgi.force_redirect = 1 (enable this)Extract theMSSQL Drivers for PHP. Look for the file name php_pdo_sqlsrv_7_nts_x64.dll and move it toC:PHP\ext folder. Rename it to php_pdo_sqlsrv.dll.
Install theODBC Driver to make your project work with SQLSRV. Please remember to install the correct one depending on your OS architecture.
Return to the php.ini file to enable the last of the extensions necessary:
php_mbstring.dllphp_openssl.dllphp_odbc.dllphp_pdo_sqlsrv.dll (This one is added manually)If you encounter theVCRUNTIME140.dll is missing error, please download the component fromVisual C++ Redistributable Package.
Head over to and openIIS Manager . At this point you can highlight the entire server to apply the following changes to all websites or you can just highlight a specefic one.Go toHandler Mappings and on the side clickAdd Module Mappings.
Here is how it should look
A prompt will ask if you want to create a FastCGI application:
Click Yes.
InstallComposer . Composer is a dependency manager and with it you will create a new laravel project with just a single command line.
Use composer to create a new project using Laravel.
cdwhere you’d like to store projects then run the following command in the command line:
composer create-project laravel/laravel myproject- Once completed, right-click on the test folder and select Properties. Under the Security tab, add
IIS_IUSRSandIUSRwith the following permissions.
Read & executeList folder contentsReadWrite- Run Notepad as administrator and open
C:Windows\System32\drivers\etc\hosts - Add this line:
127.0.0.1 myproject.dev- Return to IIS and
Add Website
Make sure you point to the public folder.
- Check if the web.config imported the values in .htaccess found in the public folder. If not then manually import from the
.htaccessfile in the public folder. - Open
Default Documentand addindex.php. You should now be able to view the default Laravel home page by visitinghttp://myproject.dev in your browser.
- Open
/config/database.phpfile. Change the default value frommysqltosqlsrv. Add the following connection:
'sqlsrv' => array('driver' => 'sqlsrv','host' => env('DB_HOST', 'localhost'),'database' => env('DB_DATABASE', 'forge'),'username' => env('DB_USERNAME', 'forge'),'password' => env('DB_PASSWORD', ''),'prefix' => '',),- Open the
.envfile and provide your database credentials and information. - Create the database in MSSQL server.
If everything works as they should, you can run thephp artisan migrate command in Command Prompt and it should create the migrations, users, password_resets tables in the database.
Finished!
If viewing your project through Internet Explorer returns aPage cannot be displayed and you know for certain there are no errors in your project or errors being displayed in any logs then be sure that in the internet optionsEnhanced Protected Mode is unchecked!
About
Laravel and Windows Server 2012
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.






