How to host a react + nodejs app on IIS server? - node.js

I have developed an application using nodejs & react. I want to host my application using the same Port: 3000 on IIS server?

I would just comment, but my reputation is a little low.
The best option for you would be to run IISNode. Supported by MS and available on Github here: https://github.com/Azure/iisnode.

First, you need to install the node on the windows:
https://nodejs.org/en/download/
install IIS by following these steps:
Open control panel
select Programs and Features, click on the link Turn Windows features
on or off.
Click on the Internet Information Services checkbox and select iis
required features.
open the iis manager from the installed application.
https://learn.microsoft.com/en-us/iis/install/installing-iis-85/installing-iis-85-on-windows-server-2012-r2
after installing node and iis open command prompt as administrator and enter to the react js application folder.
example:
my react js application is under the C:\windows\system32\
to go to that path use command:
cd C:\windows\system32\my-app
run react app using :
npm start
check that the application is running properly or not.
then run the command:
npm run build
You can see the build folder in your application folder.
now open iis manager.
select server name from the connection pane.right-click on it and
select add-website:
in add website windows enter details like site name folder path the port number, IP address, hostname, etc
note: select the build folder when you add the site path.
Open site by click on the browse button from the action pane.

Related

Yarn - ARR- URLRewrite - Troubles with web, runnin fine with yarn on localhost:3030 but not on mydomain.com (urlredirect aar to localhost:3030)

Im trying to run a code by KPlaySearch on my IIS Windows webserver 2008 R2 or 2016.
I installed Git, Yarn install and yarn start, now, within my webserver, if I connectto localhost:3030 it runs the web ok and search is done ok.
But if I run externally, the domain web (http://xn--ida.gt/google/play/adsfree/) has configured URLrewrite to redirect to localhost:3030. The same website is shown to me (as if I were on localhost:3030 on webserver) so seems ok, but when I hit on the search box of KPlaySearch (NOT the first one in a iframe, so the bottom one) the search does not work. So something is not working.
What can I do ?
RESOLVED: It was nothing to do with ARR
Issue is that original developer uses ROOT relative paths, and as Im using the code under a webdomain/path1/path2.. it wasn't work. Resolved, changing on index.js the paths "/categories" and "/search" for "categories" and "search"
https://git.kaki87.net/KaKi87/KPlaySearch/issues/19#issuecomment-333

how to use polymer starter kit doc & demo offline?

i have installed polymer starter kit 1.3.0, Using gulp serve i can access index.html located in app folder at localhost:5000.
i have two questions.
1) My question is how to access pre-developed components located at /bower-components/ on web browser?
i have tried to install and serve gulp in /bower-components/,but it still serve the /app/index/
i am not able to access components references on web browser.
2) After complete development how to host it without gulp, ex. on xampp?
You could use Python's HTTP server to serve up the bower_components directory, allowing you to access the subdirectories offline:
Open a terminal into bower_components/
Run: python -m SimpleHTTPServer 8000 to start an http server on port 8000.
Open a browser to http://localhost:8000/{dir}, where {dir} is the directory name of the component you wish to view (e.g., http://localhost:8000/paper-ripple/).
I think in the starter kit, bower_components directory is mapped to the /components url when you use gulp serve. This is the same url as your app/elements directory.
This is designed so that you app-elements can access polymer by a url of ../polymer/polymer.html (and similarly for the other elements)

How can I use (Node) Livereload on a development server in my network

Background: My PHP projects (CakePHP, Wordpress) run on an Ubuntu server in my network, I access them through a development TLD (.dev for example) setup through a local DNS server and I edit the files through a Samba share.
I would like to utilize Livereload for my development, preferably have it running on the server itself. I have basic Node/Gulp knowledge, but haven't been able to get this running.
Livereload (or a middleware server) should proxy the 'real' URLs, making sure all websites run as they would normally and Livereload should be available over the network (so not just localhost, because that runs on the development server)
Desired result:
Livereload runs on my dev server (IP: 10.0.0.1), my project is called helloworld.dev, I browse to 10.0.0.1:3000 on my machine and see helloworld.dev proxied through Livereload. I now edit a CSS file over the Samba share and the CSS is reloaded without a refresh.
I've tried using a few NPM packages, gulp-livereload, livereload, node-livereload, with their provided examples that come with the packages, but haven't been able to get the desired result. They all expect you to run in locally, don't support access to the Livereload URL over the network, cannot proxy the 'real' URLs or require static content.
Can anyone provide an example or 'proof of concept' code of my wish, so I can see where to start?
I found the answer: http://nitoyon.github.io/livereloadx/
This does EXACTLY what I need.
I can run
livereloadx -y http://helloworld.dev -l
open
http://serverip:35729
and I'm ready to roll.
The -y option creates the proxy to the 'real' URL and the -l makes it serve files from local filesystem instead of through its proxy.

Mono on Linux plus MVC3: Root directory shows file/folder list on web browser

I'm struggling getting my MVC3 site I developed on Windows to correctly run on Linux (Ubuntu) and Apache using Mono 2.10.5.
When I browse to the site root via my web browser, I see my file/folder structure instead of the home page of the site, which appears to me as though routing is not working. Everything works fine on my development environment on Windows.
When in this view, if I click on Global.asax, for instance, I see the standard ASP.NET "yellow screen of death" (YSOD) with a 500 error stating "Could not load type 'System.ComponentModel.DataAnnotations.KeyAttribute' from assembly 'MyWebSite'.".
On the bottom of the YSOD, I see the following: Version information: Mono Runtime Version: 2.10.5 (Debian 2.10.5-1); ASP.NET Version: 4.0.30319.1
I've followed the instructions for configuring Mono for MVC3 here: http://www.integratedwebsystems.com/2011/06/get-mvc3-razor-running-on-mono/
Does anyone have any clues as to why the file/folder structure is being listed when I visit the site root from my browser?
It turns out that mono was running under port 8080, and I couldn't configure it to run on port 80 due to a conflict with another module. I am able to run things fine on port 8080 now.

How to Run PHP on IIS7.5 Express?

I have Win XP SP3 and have installed IIS7.5 Express and want to run PHP on it.
I am able to run simple HTML code on the server, I am able to start and stop the server by running iisservices.exe, but I am not able to run php scripts on it.
If I have the following PHP file:
<? php
echo "hello world";
?>
<html>HI</html>
The output is HI but the PHP script doesn't run.
I have followed the steps described in this article to install PHP:
http://learn.iis.net/page.aspx/724/install-and-configure-php/
But can't proceed from step 10 onwards because IIS Express doesn't have an IIS Management Console MMC snap-in.
How do I configure IIS Express to run PHP?
Assuming you've carried out steps 1 - 9 in the article you linked to and have your PHP files extracted to c:\php then complete the following steps using a cmd.exe command prompt:
Firstly we need to configure IIS Express and setup a handler for PHP
cd "\Program Files\IIS Express"
appcmd set config -section:system.webServer/fastCgi /+"[fullPath='C:\PHP\php-cgi.exe',arguments='',maxInstances='4',idleTimeout='300',activityTimeout='30',requestTimeout='90',queueLength='1000',instanceMaxRequests='200',protocol='NamedPipe',flushNamedPipe='False',rapidFailsPerMinute='10']" /commit:apphost
appcmd set config -section:system.webServer/handlers /+"[name='PHP-FastCGI',path='*.php',modules='FastCgiModule',verb='*', scriptProcessor='c:\php\php-cgi.exe']" /commit:apphost
Assuming your PHP website resides in c:\MyPHPWeb we create a site in IIS Express that listens on http://localhost:32701:
appcmd add site /name:"MyPHPApp" /bindings:http/*:32701: /physicalPath:"c:\MyPHPWeb"
Next start the site:
iisexpress.exe /site:MyPHPApp
And finally browse to your PHP page:
http://localhost:32701/test.php
Option-1: (From command line)
Go to IIS Express installation folder (%programfiles%\iis express)
Run following two commands
appcmd.exe set config /section:system.webServer/fastCGI /+[fullPath=**'c:{php_installation-folder}\php-cgi.exe'**]
appcmd.exe set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='.php',verb='',modules='FastCgiModule',scriptProcessor='c:{php_installation-folder}\php-cgi.exe',resourceType='Unspecified']
Option-2: (Using UI)
Install WebMatrix (from http://www.microsoft.com/web/webmatrix/)
Start WebMatrix and choose 'Site From Folder' option and select your php file folder and click OK
In the WebMatrix left pan select Settings (bottom of the left pan select 'Site' and on the top of the left pan select 'Settings')
In the settings tab, check the PHP check box, this would install PHP and configure for you.
Click 'Restart' button in WebMatrix to restart IIS Express
In WebMatrix left pan bottom select 'Files' and on the top of the left pan (tree view), you should see your php page and now right click on this page node and select 'Launch in Browser'
Download php installer.
It should let you choose what type of server, so choose IIS and then it should work from there.

Resources