herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 18 März 2023 22:02 I installed [b]LiteCart 2.5.2[/b] on my BlueHost linux server with no problems - running great - love it. I run PHP on IIS on my local Win10 dev box all the time, have done for years, all my PHP apps run fine -- except for LiteCart. It appears that it cannot resolve my pathing. So I'm looking at the DIR constant declarations in config.inc.php. Here is the original source: (all h-t-t-p-s-colon prefixes replaced with <PROTOCOL>, since this forum thinks it's spam when I'm posting links) define('DOCUMENT_ROOT', str_replace('\\', '/', rtrim(realpath(!empty($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : __DIR__.'/..'), '/'))); define('FS_DIR_APP', str_replace('\\', '/', rtrim(realpath(__DIR__.'/..'), '/')) . '/'); define('FS_DIR_STORAGE', FS_DIR_APP); define('FS_DIR_ADMIN', FS_DIR_APP . BACKEND_ALIAS . '/'); // Web System define('WS_DIR_APP', preg_replace('#^'. preg_quote(DOCUMENT_ROOT, '#') .'#', '', FS_DIR_APP)); define('WS_DIR_STORAGE', WS_DIR_APP); define('WS_DIR_ADMIN', WS_DIR_APP . BACKEND_ALIAS . '/'); And here is what those values resolve to on my BlueHost server: FS_DIR_APP: /home/usaarbit/public_html/SweetDeziBakes/LiteCart/ FS_DIR_STORAGE: /home/usaarbit/public_html/SweetDeziBakes/LiteCart/ FS_DIR_ADMIN: /home/usaarbit/public_html/SweetDeziBakes/LiteCart/admin/ WS_DIR_APP: /LiteCart/ WS_DIR_STORAGE: /LiteCart/ WS_DIR_ADMIN: /LiteCart/admin/ On my local IIS PC, here are my values: FS_DIR_APP: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ FS_DIR_STORAGE: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ FS_DIR_ADMIN: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/admin/ WS_DIR_APP: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ WS_DIR_STORAGE: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ WS_DIR_ADMIN: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/admin/ At least one major problem that is obvious to me is that there are no relative/URL paths, so of course the PHP cannot find things. So I made a hack attempt and changed my local vars thusly: define('DOCUMENT_ROOT', '<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web'); define('FS_DIR_APP', '<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/'); define('FS_DIR_STORAGE', FS_DIR_APP); define('FS_DIR_ADMIN', FS_DIR_APP . BACKEND_ALIAS . '/'); // Web System define('WS_DIR_APP', '/LiteCart/'); define('WS_DIR_STORAGE', '/LiteCart/'); define('WS_DIR_ADMIN', '/LiteCart/admin/'); That was a disaster and just made my page errors even worse: PHP Warning: file_put_contents(): Exclusive locks may only be set for regular files in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 29 PHP Warning: file_put_contents(<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.cache/.modifications): failed to open stream: HTTP wrapper does not support writeable connections in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 33 PHP Warning: file_put_contents(<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.settings): failed to open stream: HTTP wrapper does not support writeable connections in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 37 PHP Warning: filemtime(): stat failed for <PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/ in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 47 PHP Warning: filemtime(): stat failed for <PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.installed in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 57 PHP Warning: filemtime(): stat failed for <PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.settings in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 61 PHP Warning: file(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 71 PHP Warning: file(): Failed to enable crypto in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 71 PHP Warning: file(<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.installed): failed to open stream: operation failed in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 71 PHP Warning: Invalid argument supplied for foreach() in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 71 PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 80 PHP Warning: file_get_contents(): Failed to enable crypto in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 80 PHP Warning: file_get_contents(<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.settings): failed to open stream: operation failed in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 80 PHP Warning: filemtime(): stat failed for <PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.cache/.modifications in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 85 PHP Warning: filemtime(): stat failed for <PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/vmods/.cache/.checked in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 93 PHP Warning: file_put_contents(): Exclusive locks may only be set for regular files in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\library\lib_vmod.inc.php on line 117 PHP Warning: require_once(): <PROTOCOL> wrapper is disabled in the server configuration by allow_url_include=0 in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\app_header.inc.php on line 23 PHP Warning: require_once(<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/includes/compatibility.inc.php): failed to open stream: no suitable wrapper could be found in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\app_header.inc.php on line 23 PHP Fatal error: require_once(): Failed opening required '<PROTOCOL>localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/includes/compatibility.inc.php' (include_path='.;C:\php\pear') in E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart\includes\app_header.inc.php on line 23 I know that the creator recommends XAMP instead of IIS...but PLEASE HAVE MERCY and tell me how to get this working on my IIS dev box. Thanks in advance.
tim Founder Von Sweden Mitglied seit Mai 2013 tim 19 März 2023 09:27 I'm curious to how we can get in rolling with IIS. But why would you put https:// in front of your local file system paths? That tells the system to access a file on an external remote web location rather than the local hard drive. Imagine the performance drain and security flaws that will come from that. This looks right: FS_DIR_APP: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ FS_DIR_STORAGE: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ FS_DIR_ADMIN: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/admin/ WS_DIR_APP: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ WS_DIR_STORAGE: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ WS_DIR_ADMIN: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/admin/``` PLease note we are using forward slashes although we are on windows for this reason: https://stackoverflow.com/questions/26881333/when-to-use-directory-separator-in-php-code/71791252#71791252 C:/inetpub/ is not a relative URL. Are you saying that PHP resolves C:/ as relative to the current working directory rather than an absolute path? I don't know if PHP supports unixified paths /C/inetpub/? What are the errors you are receiving with the default configurations? I don't know if "Programming Projects" is a path that could need encapsulation depending on the component accessing it? I know I had troubles with captcha on windows if the font path had a space character. Try renaming folders with spaces to e.g. "ProgrammingProjects" and see if there is a difference? Is this the mini IIS 6.0 server included in standard Windows installations like Home, and Pro as an optional component? Or is it some other edition like IIS 10?
tim Founder Von Sweden Mitglied seit Mai 2013 tim 19 März 2023 09:33 Oh I spotted the problem I think This is not looking right: DOCUMENT_ROOT: C:/inetpub/wwwroot I believe DOCUMENT_ROOT should be set to "E:/Nathan/Programming Projects/SweetDeziBakes/web/". That is if LiteCart is a subfolder of the web root e.g. https://myhost/LiteCart/. In general DOCUMENT_ROOT is a parameter passed by the web server to PHP and should refelect the internal file system path to the web ROOT folder. Make sure your web server sets DOCUMENT_ROOT properly for all virtual hosts. I have seen this problem in half cooked virtualhost implementations for Apache as well. See how this is accurate in your BlueHosting: FS_DIR_APP: /home/usaarbit/public_html/SweetDeziBakes/LiteCart/ <--- Internal path to https://yourhost/LiteCart/```
herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 19 März 2023 15:41 Tim, thanks for looking at this. I put all those const/var lines back to default, except I hardcoded DOCUMENT_ROOT to 'E:/Nathan/Programming Projects/SweetDeziBakes/web', and now I'm back to the mess that I originally had when I first tried to launch LiteCart on my local PC: [img]https://sweetdezibakes.com/LiteCart/lite-cart-broke.png[/img] In IIS, PHP includes and requires cannot be local/physical OS paths, but must be URL-type pathing, relative to the web server it's on. It seems like LiteCart is trying to resolve PHP script locations using physical pathing, which simply won't work on IIS. That is why I went down the rabbit hole of trying to make all those paths relative. I think if we can figure this out, you can enhance the installer to detect IIS/windows and make a smoother setup process so people don't run into this. I don't think "Programming Projects" with the space is a problem because I have run many PHP apps from this same root path. I'm happy to screenshare or give you any info you need. Thanks again for your assistance.
tim Founder Von Sweden Mitglied seit Mai 2013 tim 19 März 2023 16:39 Ok so the paths are better. Your next step is to emulate those .htaccess directives. <IfModule mod_rewrite.c> RewriteEngine on # Web path to catalog root RewriteBase / # No rewrite logic for physical files RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] RewriteRule ^.*$ index.php?%{QUERY_STRING} [L] </IfModule>``` If you are used to nginx: ``` location / { try_files $uri $uri/ /index.php$is_args$args; } Basically any URL route that doesn't have a destination to a physical file should be sent to index.php. If this is not supported in IIS there is a way to disable URL rewriting in LiteCart. I opened a wiki article where we can write down all instructions for other users who make this journey. You can use the same username and password to login to the wiki site. Feel free to make notes. I can tidy it up. https://wiki.litecart.net/how_to_run_litecart_on_iis
herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 19 März 2023 23:29 Apologies, but now I am very confused. I went into my .htaccess file and changed from this: <IfModule mod_rewrite.c> RewriteEngine on # Tell PHP that the mod_rewrite module is enabled <IfModule mod_env.c> SetEnv MOD_REWRITE On </IfModule> # Force HTTPS (Standard SSL) #RewriteCond %{HTTPS} off #RewriteCond %{REQUEST_METHOD} !=POST #RewriteCond %{REQUEST_URI} !^/\.well-known/ #RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Force HTTPS (CloudFlare Flexi SSL / Load Balancing Servers) #RewriteCond %{HTTPS} off #RewriteCond %{HTTP:X-Forwarded-Proto} =http #RewriteCond %{REQUEST_METHOD} !=POST #RewriteCond %{REQUEST_URI} !^/\.well-known/ #RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Redirect non-www to www #RewriteCond %{HTTP_HOST} !^www\. #RewriteCond %{REQUEST_METHOD} !=POST #RewriteCond %{REQUEST_URI} !^/\.well-known/ #RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Redirect www to non-www #RewriteCond %{HTTP_HOST} ^www\.(.*)$ #RewriteCond %{REQUEST_METHOD} !=POST #RewriteCond %{REQUEST_URI} !^/\.well-known/ #RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] # Redirect from any alias domain to primary domain #RewriteCond %{HTTP_HOST} !^www\.mydomain\.com #RewriteCond %{REQUEST_METHOD} !=POST #RewriteCond %{REQUEST_URI} !^/\.well-known/ #RewriteRule ^ https://www.mydomain.com%{REQUEST_URI} [R=301,L] # Web path to catalog root RewriteBase E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ # No rewrite logic for physical files RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] RewriteRule ^ index.php [QSA,L] </IfModule> ... to this: <IfModule mod_rewrite.c> RewriteEngine on # Web path to catalog root RewriteBase / # No rewrite logic for physical files RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l RewriteRule ^ - [L] RewriteRule ^.*$ index.php?%{QUERY_STRING} [L] </IfModule> ...as per your latest instructions. But that made no change and I still get the scrambled page as in my latest screenshot. And I have no idea what this is or what to do with it: try_files $uri $uri/ /index.php$is_args$args; } This article seems like it would be helpful, but it's beyond me what exactly to do with it: https://learn.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig
herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 20 März 2023 04:29 One more thing, this should help with troubleshooting. I reloaded that LiteCart home page on my local IIS dev box with Chrome Dev Tools open, Network tab, seeing all the docs/pages not found. Here's one example of a CSS page that LiteCart was trying to request: https://localhost/LiteCart/includes/templates/default.catalog/css/variables.css?_=1676521142 That is way wrong. Here is what the URL [i]should [/i]be: https://localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/includes/templates/default.catalog/css/variables.css?_=1676521142 What do I need to do in the pathing vars to make this right?
tim Founder Von Sweden Mitglied seit Mai 2013 tim 20 März 2023 07:38 Changing your .htaccess file doesn't have an effect on Microsoft IIS. .htaccess is for Apache and the other code example is for nginx.conf (another web server). You would need to the same for web.config file in IIS. Try something like this and make sure you have the necessary components installed if rewrite support is not embedded with the core of IIS. <configuration> ... <system.webServer> ... <rewrite> <rules> <rule name="Process any non-physical files in the App (index.php)" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite> <defaultDocument> <files> <remove value="index.php" /> <add value="index.php" /> </files> </defaultDocument> ... </system.webServer> </configuration>```
tim Founder Von Sweden Mitglied seit Mai 2013 tim 20 März 2023 07:53 [quote]Here is what the URL should be: https://localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart/includes/templates/default.catalog/css/variables.css?_=1676521142 What do I need to do in the pathing vars to make this right?[/quote] If https://localhost/ProgrammingProjects/SweetDeziBakes/web/LiteCart is the path to LiteCart then your document root is E:/Nathan/. I don't recommend this kind of setup as all your websites share the same web config and editing this config can conflict one another. I recommend adding a new hostname to you Windows hosts file, and configure it as a standalone virtualhost in IIS. Create a new virtual host: IIS manager -> (Local computer) -> Right-click Web Sites -> New -> Web Site To manage your hosts entries: https://hostsfileeditor.com/
tim Founder Von Sweden Mitglied seit Mai 2013 tim 20 März 2023 10:10 So I created a step by step instruction how to run LiteCart on IIS: https://wiki.litecart.net/how_to_run_litecart_on_iis
herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 22 März 2023 01:04 Tim, I finally had time to go through your instructions: https://wiki.litecart.net/how_to_run_litecart_on_iis I set up everything precisely. When I got to the end, installing the add-on, I downloaded it, but the readme is very unclear. The readme says: Upload the contents of the folder public_html/* to the corresponding path of your LiteCart installation. That makes no sense to me. There is only 1 file in the zip besides the readme: [b]force_rewritten_urls.xml[/b] Should that xml file go in the vmods folder? In the LiteCart root? Instructions don't say. I tried both. Nothing works. I still have exact same results trying to run LiteCart in IIS, as shown by screenshot up above in thread. My new URL: http://sweetdezibakes.litecart.local/ Hosts file entry: 127.0.0.1 sweetdezibakes.litecart.local Physical path mapped in new IIS site: E:\Nathan\Programming Projects\SweetDeziBakes\web\LiteCart
tim Founder Von Sweden Mitglied seit Mai 2013 tim 22 März 2023 08:19 [quote]Should that xml file go in the vmods folder? In the LiteCart root? Instructions don't say. I tried both. Nothing works. I still have exact same results trying to run LiteCart in IIS, as shown by screenshot up above in thread.[/quote] The contents of public_html/* mirrors the LiteCart root. vqmod/ was replaced in version 2.5 with vmods/. It is backwards compatible with the vqmod .xml files, but they now go in vmods/. I uploaded an update of the add-on that have an .xml file that goes in the vmods folder instead. Other than that, are you able to navigate the website now without errors?
herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 22 März 2023 15:09 Tim, after placing your latest [b]force_rewritten_urls.xml[/b] into the [b]vmods [/b]folder, still no difference, as before: [img]https://sweetdezibakes.com/LiteCart/lite-cart-broke.png[/img]
tim Founder Von Sweden Mitglied seit Mai 2013 tim 22 März 2023 18:15 Your Document Root and App Dir are not the same, why? Did you modify config.inc.php and hardcode your paths or are you letting LiteCart find out for itself? Because you say LiteCart is in the root of the domain sweetdezibakes.litecart.local then it should look like this: DOCUMENT_ROOT: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart FS_DIR_APP: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/ FS_DIR_STORAGE: E:/Nathan/Programming Projects/SweetDeziBakes/web/LiteCart/
herrimancoder LiteCart Fan Von United States Mitglied seit März 2023 herrimancoder 22 März 2023 19:08 Bingo! You are right. When I put all those settings in config.inc.php back to shipped defaults, it works. I apologize it didn't occur to me to revisit that file after experimenting with changes early on. Tim, THANK YOU for your perseverance and patience. I can now confirm that your [url=https://wiki.litecart.net/how_to_run_litecart_on_iis]How To Run LiteCart on IIS[/url] worked 100% for me!
tim Founder Von Sweden Mitglied seit Mai 2013 tim 22 März 2023 21:22 Awesome to hear! Wohoo :) I learned something on the way too.