yiisoft / docs

Various Yii 3.0 related documentation
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
232 stars 70 forks source link

Running yii3 on subfolder with IIS 10 #141

Closed MasterGHD closed 3 years ago

MasterGHD commented 3 years ago

What steps will reproduce the problem?

Assuming that you're using PHP 8.x with IIS 10.0:

  1. Run composer on command prompt (admin)

  2. Run "cd c:\inetput\wwwroot\projects" (this is my main folder)

  3. Run "composer create-project --prefer-dist --stability=dev yiisoft/app basic"

  4. On IIS, expand the Default Web Site -> projects and right click on this folder "Add virtual directory"

  5. On the alias, type "yii3basic" and folder "C:\inetpub\wwwroot\projects\basic\public".

  6. In IIS, click once on "yii3basic" folder, and select PHP Manager. Make sure it's selected PHP 8.x, and the extensions "fileinfo" and "pdo sqlite" are enabled imagem_2021-10-05_011658

  7. Open the browser and navigate to http://localhost/projects/yii3basic

  8. If the framework shows any warning about runtime folder, make sure the folders have sufficient permissions

What is the expected result?

Navigate to the landing page (index)

What do you get instead?

A 404 error: The page /projects/yii3basic/ not found.

imagem_2021-10-05_011433

Additional info

Q A
Version dev-master
PHP version 8.0.10
Operating system Windows 10
cgsmith commented 3 years ago

This becomes difficult to troubleshoot and isn't necessarily a Yii2 issue IMHO.

https://news-web.php.net/php.internals/110907

I ran into some issues configuring an IIS handler. Admittedly, I am not a IIS expert or even novice.

MasterGHD commented 3 years ago

@cgsmith the app runs smoothly with Yii 2.0 and 1.1 on IIS.

This repo is about the new version: Yii 3.0.

MasterGHD commented 3 years ago

For the install, I used Web Platform Installer from Microsoft, PHP Manager from phpmanager.xyz and Fast CGI.

To enable IIS and Fast CGI, it is necessary to go to Programs and Features (Control Panel) > Turn Windows features on or off. Enable Internet Information Services and expand it. There is an option called CGI that is used also for PHP.

The quickest way to add PHP 8 is installing it manually, and then add via PHP Manager.

roxblnfk commented 3 years ago

Try to set the prefix property manually in the SubFolder middleware to /projects/yii3basic

MasterGHD commented 3 years ago

@roxblnfk I don't know how to implement it.

Can you give an example?

samdark commented 3 years ago

Try adding it to https://github.com/yiisoft/demo/blob/master/config/web/application.php#L22.

MasterGHD commented 3 years ago

@samdark it's almost there. image

How do I adjust the base URL used on CSS and JS files by assets?

rustamwin commented 3 years ago

Try change https://github.com/yiisoft/app/blob/master/config/params.php#L22 to /projects/yii3basic/assets.

roxblnfk commented 3 years ago

Try change https://github.com/yiisoft/app/blob/master/config/params.php#L22 to /projects/yii3basic/assets.

i think this value should be prefixed with @baseUrl: '@baseUrl/assets'

The @baseUrl alias will be changed automatically in the SubFolder middleware

MasterGHD commented 3 years ago

Try change https://github.com/yiisoft/app/blob/master/config/params.php#L22 to /projects/yii3basic/assets.

@rustamwin @roxblnfk yes, this solved the assets issue.

Try change https://github.com/yiisoft/app/blob/master/config/params.php#L22 to /projects/yii3basic/assets.

i think this value should be prefixed with @baseUrl: '@baseUrl/assets'

The @baseUrl alisa will be changed automatically in the SubFolder middleware

@samdark is there a good reason the SubFolder middleware is not included in the web/application config by default?

roxblnfk commented 3 years ago

@samdark is there a good reason the SubFolder middleware is not included in the web/application config by default?

For main template it's OK. But it's strange that it is not included in the yiisoft/demo project.

MasterGHD commented 3 years ago

For main template it's OK.

To beginners in Yii3 (like myself), it's one more step to configure after a fresh install.

But it's strange that it is not included in the yiisoft/demo project.

I agree.

samdark commented 3 years ago

Well, nowadays it's often Docker images and these are always point to the webroot. There's no sub-directoryies. That's why it wasn't done by default.

MasterGHD commented 3 years ago

Well, nowadays it's often Docker images and these are always point to the webroot. There's no sub-directoryies. That's why it wasn't done by default.

I still can't use Docker. For some reason, my Windows shows a BSOD if I try to install Docker or by enabling Hyper-V.

samdark commented 3 years ago

I see. At least we need it documented well.

MasterGHD commented 3 years ago

I see. At least we need it documented well.

@samdark it will help a lot.

Shall we close this issue and open a new one, related to mine? Or keep it opened?

samdark commented 3 years ago

Keep it opened. Open another one.

MasterGHD commented 3 years ago

Keep it opened. Open another one.

Ok. Thank you.

samdark commented 3 years ago

Closing since it's in the default config now.