Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Laravel and Windows Server 2012

NotificationsYou must be signed in to change notification settings

hbswift/Laravel-Windows-Server-2012

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

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.

What you'll need

IIS (Internet Information Services) Setup

  • 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.

PHP

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)

Troubleshooting

If you encounter theVCRUNTIME140.dll is missing error, please download the component fromVisual C++ Redistributable Package.

Configure Handler Mapping

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.

Composer

InstallComposer . Composer is a dependency manager and with it you will create a new laravel project with just a single command line.

Creating a New Laravel Project

Use composer to create a new project using Laravel.

  • cd where 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, addIIS_IUSRS andIUSR with the following permissions.
Read & executeList folder contentsReadWrite
  • Run Notepad as administrator and openC:Windows\System32\drivers\etc\hosts
  • Add this line:
127.0.0.1                 myproject.dev
  • Return to IIS andAdd 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.htaccess file in the public folder.
  • OpenDefault Document and addindex.php. You should now be able to view the default Laravel home page by visitinghttp://myproject.dev in your browser.

Connecting to MSSQL Server 2012

  • Open/config/database.php file. Change the default value frommysql tosqlsrv. 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.env file 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!

Troubleshooting

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp