Can I have a subdomain of php application on asp.net application - php

I have an asp.net web application hosted and I would like to add a sub-domain (or sub-directory) and run/host a php application in it.
How would i do this?

A subdomain would be nicer from a technical standpoint:
You could make your DNS route the subdomain.yourdomain.com to a different Server then yourdomain.com
You could add different IIS bindings for subdomain.yourdomain.com and yourdomain.com in IIS.
For a sub-directory you'd have to run php in IIS as well, here is a guide in how to set it up: You can also run an php website in iis.
You could also run php on Apache and dotnet in IIS. The only downside: If you try to run both apps on 1 server, only 1 (IIS or apache) Can listen for http traffic on port 80 (the default port). so you'd have to host 1 on a different port (eg for port 81: yourdomain.com:81) which i wouldn't advice for a production website.
You could make a tiny application which receives every request and forwards the http request to the right application on a different port. This is called a reverse proxy.

Related

HTTP and nodeJS on separate servers

I have two websites:
1)httpwebsite.com where I run my web application which uses APACHE, PHP and MYSQL;
2)wss.com where I run a nodeJS websocket server, used for a multiplayer game;
I want to host the javascript client-side files that communicate with the websocket server, on httpwebsite.com, so I dont have to configure a http server on nodeJS, for many reasons, like security and lack of experience with using nodeJS as HTTP server.
I want to use nodeJS only for the websocket server, for performance and flexibility reasons, among many others.
I've heard that Same-origin policy restricts communication from httpwebsite.com with wss.com , but can this be reconfigured to actually allow communication between two different domains that want to communicate with each other on purpose?
Do I have other options than actually running a HTTP server on the nodeJS server?
You can use CORS for secure requests from one domain to another domain.
http://www.html5rocks.com/en/tutorials/cors/
2 options:
You can add CORS headers to wss.com to allow access to website.com to load it's resources. The link Matt gave should explain how this works and you just need to add this HTTP Header to each Node server you need to access.
You can proxy your requests through your Apache server to the node server. So the web browser thinks it's talking to a service on the same origin. This is often used to only have your web server publically available and your app server (running node) not directly available and protected behind a firewall - though obviously Apache needs to be able to access it.
You can use this config in Apache to achieve option 2 to forward http://website.com/api calls to a service running in wss.com on port 3000.
#send all /api requests to node
ProxyPass /api http://wss.com:3000
#Optionally change all references to wss.com to this domain on return:
ProxyPassReverse /api http://wss.com:3000

Run PHP code on local MacOS Jekyll site, port 4000

I've build a Jekyll website on my localhost (MacOS Mavericks). The website is served at http://localhost:4000/website/ and everything regarding Jekyll is running just fine.
However, I now want to have a contact form in PHP that allows me to receive emails. I placed a contact.php file in the website/ folder and have the form POST to that file. On my remote web server, this is working perfectly. However, on the localhost, the PHP isn't parsed, and plain text is displayed on contact.php. However, PHP is parsed perfectly on localhost/contact.php.
How do I get my localhost (Apache? PHP?) to process PHP files on my local Mac http://localhost:4000/ (without breaking my Jekyll website that listens on the same :4000 port)?
You can't use the same port. The port determines the application endpoint that will handle the request on the IP address. The Jekyll server (WEBrick library) uses port 4000 as a default.
The typical way to handle this problem, is to use a "web service" to add dynamic functionality. For instance, the jekyll docs suggest using something like FormKeep, or SimpleForm.
What you're asking is to setup a "web service" yourself. To do this it would need to be on another port or another IP address. The "service" will simply act as an endpoint to accept and process your form post. In this case you could setup a webserver using Apache/PHP on a different port than Jekyll -- such as the standard port 80 -- then write a PHP script (e.g., webform.php) that in combination with the static form is setup to respond and process your form.
Note: It is possible to configure both Jekyll and Apache to respond to requests on port 4000. However, both applications (aka servers) can't be running at the same time. The ip:port combination determines which application an internet request is sent to.
I realize the post is old but this may help someone...
The answer by Mike Stewart is excellent and describes what needs to be done to accomplish the goal.
To add to that answer, here are the specifics of how I do this type of development on a Mac.
Configure CORS in Apache
Run the Jekyll site on default port 4000
Run MAMP stack on default port 8888
Code goes in MAMP's htdocs folder (htdocs/your_project)
PHP resides in a separete "php" or other folder inside the "your_project" folder
Jekyll watches the "your_project" folder and compiles to _site as normal
The CORS issues you'll experience can be resolved locally during development several ways. Here is a good resource for enabling CORS on Apache: http://enable-cors.org/server_apache.html
Once you have CORS configured you'll be able to make Ajax calls to the PHP on port 8888.
I'm running the PHP built-in web server alongside the Jekyll server. I opened a second Terminal window and navigated to the _site folder. The command is php -S localhost:8000 (or whatever port you want to use that is not 4000).
Note that I'm using viewing localhost:8000 in the browser, but having the Jekyll server running simultaneously is nice because Jekyll keeps the build updated as I make changes to the source code (refresh required).

server running IIS and Apache: setting up SSL

One of my clients have a server running both IIS and Apache. IIS is on port 80 and Apache is on port 8081. I am working on an application that will be running on Apache and this application needs to be configure so that it uses SSL.
The client already purchased the SSL certificate from Godaddy but when trying to generate the CSR file, it asks for certain information like the Common Name (fully qualified domain name, or URL, you are securing. I am having from with this particular section: Common Name.
The application's URL is http://apps.patria.com.do:8081/Cobros_Online/. When I use this as the URL, it tells me it is not valid. After doing some research, it looks like it cannot contain port number. How can I fix this? I can't use the default port 80 because IIS is on port 80.
So, for example, http://apps.patria.com.do/, will take you to another application running on IIS.
What can I do to make the URL acceptable?
Thanks in advance!

WAMP server as subdomain on IIS machine

My boss wants me to merge my dev server on to the same server as our live production application.
The problem with this is that the current application is .NET and development is WAMP.
On my local machine this worked fine because I could just tag a port to the URL like :8080 or :81.
But, I have tried to point our testing subdomain to an alternate port, but, I found out this isn't possible with DNS.
How can I successfully leave IIS as the main host (www.domain.com) and serve requests for the subdomain (dev.domain.com) from WAMP?
Since both services are webserver operating on port 80, you simply can't without moving one or another to a different port.
The only "workaround" that comes to mind is to set up a subdomain on IIS with redirect to your WAMP dev server.

Application tool to perform cross browser testing within localhost

I am in the middle of building a website which means it is not uploaded to a server yet. Is there any way I can perform cross browser testing from the localhost and not an actual hosted URL?
Either by running lots of browsers natively (some in a VM), or by using SSH tunnelling to a commercial service like browserling (http://browserling.com/).
Edit to elaborate a bit: An SSH tunnel (a reverse tunnel technically) between your localhost and a server allows you to forward certain ports on the remote host to ports on your localhost, over an encrypted SSH channel. This means the browsers running on browserling's servers can send packets down the tunnel, back to your localhost and your webserver there.
Install PHP on your local machine, this way you can run PHP scripts in command-line or browsers.
http://php.net/manual/en/install.php
Configure your webserver to listen on your network IP and access your website through IP address on your local network.
If it is apache webserver It would be configured using directive:
Listen IP:port
Example 1 (your adapter IP address):
Listen 192.168.1.10:80
Example 2 (global listening on all interfaces) - better for testing
Listen 0.0.0.0:80
Then just simply access your computer from other browsers on other platforms.
Sure. If you're able to configure your local network you could expose port 80 or 443 to the cloud by making changes to your routers firewall. This would make your application as available for testing locally as any on a remote host.
Let me know if your question is about which tools you could use, either as external services or locally installable.

Categories