Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running yii3 on subfolder with IIS 10 #141

Closed
MasterGHD opened this issue Oct 5, 2021 · 19 comments
Closed

Running yii3 on subfolder with IIS 10 #141

MasterGHD opened this issue Oct 5, 2021 · 19 comments

Comments

@MasterGHD
Copy link

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
Copy link

cgsmith commented Oct 5, 2021

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
Copy link
Author

@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
Copy link
Author

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
Copy link
Member

roxblnfk commented Oct 5, 2021

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

@MasterGHD
Copy link
Author

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

Can you give an example?

@samdark
Copy link
Member

samdark commented Oct 5, 2021

@MasterGHD
Copy link
Author

MasterGHD commented Oct 5, 2021

@samdark it's almost there.
image

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

@rustamwin
Copy link
Member

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

@roxblnfk
Copy link
Member

roxblnfk commented Oct 5, 2021

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
Copy link
Author

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
Copy link
Member

roxblnfk commented Oct 6, 2021

@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
Copy link
Author

MasterGHD commented Oct 6, 2021

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
Copy link
Member

samdark commented Oct 6, 2021

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
Copy link
Author

MasterGHD commented Oct 6, 2021

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
Copy link
Member

samdark commented Oct 6, 2021

I see. At least we need it documented well.

@MasterGHD
Copy link
Author

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
Copy link
Member

samdark commented Oct 7, 2021

Keep it opened. Open another one.

@MasterGHD
Copy link
Author

Keep it opened. Open another one.

Ok. Thank you.

@samdark samdark transferred this issue from yiisoft/app Oct 18, 2021
@samdark
Copy link
Member

samdark commented Oct 18, 2021

Closing since it's in the default config now.

@samdark samdark closed this as completed Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants