PHP and node.js on the same server - php

I am using PHP for the backend of my website and I am introducing a node.js chat. I have everything figured out as far as authentication between the two, and my only problem now is switching between port numbers. How is this handled? Ideally I'd like to hide the port number and I've tried virtual hosts for this, but no matter how I configure the virutal host the server does not load and appears to be down. I am using cloudflare if this matter. But hiding the port isn't required. I just want to smoothly link to the chat app on port 2053 from the PHP app on port 443, and have the chat app link back to the PHP site. PHP uses apache. I can't find any easy way to do this. Been at this problem for days.

After much much research, trial and error I've figured out a few things.
My site consists of mainly PHP, I want to use node.js on a separate page as a chat app. I thought this would be easy, but I was mistaken. It's a lot of pain to get both node.js and PHP to work together flawlessly, and if I knew back then what I know now I might have went a different route. But I have things working for the most part and I am happy.
Some useful info:
If you want to link back to 80 or 443 from your node page, use the full URL with http/s.
If you want to use a virtual host it's only possible on Apache 2.4+ because socket.io can't communicate through it without some apaache mods that allow websocket proxing. It's also possible with NGINX from what I hear but I am less familiar with it.
So in the end I am just keeping the port number and allowing hyper links between the two. This is a temporary solution until I upgrade to either Apache 2.4 or NGINX.

Related

Allow someone else to connect to my XAMPP mysql

Good day,
I am making a discord bot that will require MySQL access. I have used XAMPP in the past for other projects, but now that I am working with someone else, I need to allow them to also access my XAMPP MySQL database. I have tried googling solutions, as well as looking up a lot of other stuff for this, but everything just redirects back to localhost/virtualhost stuff.
I have my own DNS that I would like the person to connect to, so example.
I am trying to run this entire thing off my own server, this way I do not have to worry about data limitations or worry about if the project goes inactive for a while that everything will be wiped (remotemysql.com)
Only kind of success I have had so far is allowing another computer on my LAN to connect through my IPv4 address
I have the ports, 3306, 80, and 443 all open as well as allowed through my firewall. I have also tried temp disabling my firewall to test to see if this was the issue, but it wasnt
I don't know if you want to that just for testing, if it is, maybe ngrok could work for you.
It creates tunnels to localhost, but it has no custom domains on the free plan though.
Use ngrok. Alternatively if you want it to be free in terms of use, you can setup your own ngrok like server using expose. Here is the link https://github.com/beyondcode/expose

Gh + Jekyll + LAMP for authentication?

I've spent the entire morning scouring the internet trying to find a solution to this and I haven't found one yet so now I'm here. I have a LAMP server on digital ocean and I want to use it strictly as a database server. I have a Jekyll site on Github that I've got up and running, but I want to know if there is a way to send users over to my LAMP server for authentication, but use my Jekyll site for the rest of the website. Would it be possible to redirect the page to the server and then have the root directory of the virtual host in the url location? I want to implement this all on the same domain, but I want to do it this way to make it fast and efficient.
Would I have to use different two nameservers from different domains and would this cause any problems?
I know you can do a Jekyll-Angular-Firebase stack, but I want something that I can maintain on my own and don't have to pay $50 a month for.
Would it be possible to talk to the database in the form itself so that everything else is static and doesn't have to be processed by the lamp server?
Any help would be greatly appreciated. Thanks you.
Just deploy/upload your static site (the '_site' folder in Jekyll) to your LAMP stack and add some php files for authentication.

Cannot Get Laravel Welcome Page to Show

My server is on DigitalOcean cloud. I am using Ubuntu with Apache web server. My home computer is running Windows 7. I am using putty for terminal.
Followed all of the directions on https://laracasts.com/series/laravel-5-fundamentals/episodes/1. Made it up to 8:40, where it directs you to run php -S localhost:8888 -t public. I run that, then open a web browser and tried the following:
-http://mywebsite.com:8888
-http://www.mywebsite.com:8888
-http://mywebsite.com/learning-laravel-5/public
-http://mywebsite.com/learning-laravel-5/public/index.php
None of the above work.
In Google Chrome, the first two options where I list the port number, I get a page saying This webpage is not available. ERR_CONNECTION_REFUSED. In IE, I just get a page with big font saying "This page can't be displayed."
For the last two options, I just get a completely blank page. In the console, I get this error: Failed to load resource: the server responded with a status of 500 (Internal Server Error).
I'm trying to pick up a web app framework to broaden my php skill set. Can someone help me out? What am I doing wrong/what is the video tutorial missing that I have to do in order to get Laravel up and running?
php -S localhost:8888 -t public is meant for running a site locally, which is what the video is showing.
If you are using a Digital Ocean droplet with Ubuntu and Apache, you will need to configure Apache to use /public as the document root and have Laravel installed in the /var/www directory.
From there you can visit the droplet's IP address (http://XXX.XXX.XXX.XXX) instead of the domain name (unless you have configured the DNS for that domain name). You won't need the port in the URL either, since Apache will be serving it on the default port 80.
This probably is not the answer you want, but here's my advice based on setting up a few VPSs on Digital Ocean. Step back. Spin a new VPS. Keep your old one around, if you want, but start afresh.
Create a new droplet
Setup your SSH and PuTTY and make sure that works
Setup your FTP (if you're using it)
Setup your DNS
Setup your Apache config files. DO has a very good tutorial on this: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04
Now, work on getting your "Hello world" html page to show when you access your domain www.yourdomain.com, yourdomian.com. Don't fixate on ports at this point, just get a minimal server running. This might help too: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
Make an saved "image" of this basic working setup so you can spin a new VPS if you need to.
Now that you have a server that loads your domain index page, you can start to install your Laravel.
In a nutshell, I'd advise you to establish a stable working server platform before you try to install and launch a more complex technology like Laravel, or Rails, etc.
Tutorials often make complex technologies seem easy, the 10-minute expert, but there is tremendous complexity masked under the hood of these frameworks. Start simple and build on a server one piece at a time. You have to walk before you run.
I use Laravel often, but my experience with servers is more relevant here. Everything you've said indicates an access problem, and knowing how hosting companies work, they probably have that port blocked (along with all other non-standard ports).
You can test this using PuTTY, open it up and enter the host name of your server. Change the port to 80 and change close on window exit to never, then connect. Enter:
GET / HTTP/1.1
Host: yourwebsite.com
Then press enter twice and the server will process the result. It should show you the HTML of your home page.
Now try it again with port 8888 and see if you can even connect. If you can connect then it's not a port issue, but my guess is you'll get a fatal error Network error: Connection refused, which means the port is closed or blocked via firewall.
Even though DigitalOcean give you complete control over the server, the connection probably still runs through their firewall. It's possible that you have your own firewall, but otherwise if the server runs through their firewall and the port is blocked nothing you can do on the server will open that port.
did you try chmod -R 0777 storage ?

Running old site on apache + php and new nginx rails side by side

My current site is running on a dedicated server on apache + php. I am creating my new site in rails and running on nginx.
I want to run both sites together for a while while i slowly redirect all pages SEO rank etc to new site.
My current site has say domain www.mydomain.com and new site will have www.mydomain.com/en infront of everything as will be mulilingual.
My current site is on server A and new site on server B, different locations and i want to figure out the best way to run together.
Can i tell apache on server A to whenever see url www.mydomain.com/en point to server B and nginx on server B with run new rails site? I am not trying to share sessions so that simplifies things i hope!!!
I can then just turn off server A when ready and just have new site running.
If i cant do this i will have to move all my existing site over to server B and run both sites on same server but think that might take ages and dont want to mess with current site much as to lose traffic / seo ranking etc
Any help, experience or opinions would be gratefully received!
thanks alot
rick
You could run nginx on a different port (e.g. 8080) and then use Apache's mod_proxy to send requests to nginx.

Bizarre timeout in Web CMS, ideas?

I know this kind of thing cannot be adequately answered without a link to the live example. Unfortunately, I can't set one up right now as it's a back-end login and creating a safe public login would be too much to do at this point. Sorry. I'm hoping for ideas and input from people who may have experienced something similar in the past.
I am setting up a CMS for a client with a DSL connection in Spain.
The CMS is hosted on a straightforward standard, LAMP based, shared hosting package in a network center in Germany.
It comes with a .com domain.
When my client tries to log in to the CMS using Internet Explorer 7, everything works fine.
When she tries to log in using Firefox, she gets to the login form, submits it - and then the connection times out.
When she logs in using Firefox but using "domain.com" instead of "www.domain.com", everything works fine.
This happens on all computers that are hooked up to that line. One Windows XP, one Windows Vista.
The front-end part of the site, as well as a second, older CMS, work fine in all browsers.
I do not have access to the raw access logs.
I have not been able to reproduce this behaviour on any other connection.
Debugging ideas are welcome. Remote diagnosis is extremely difficult as the line is too slow to set up a proper remote connection.
If you are limited by how you can troubleshoot this, have the client install Fiddler - Web debugging proxy and then run the trace, and send you the logs, Fiddler will analyze the traffic (be it proxy or DNS timeout, etc)
Take a look if you have not used it before:
http://www.fiddler2.com/Fiddler2/version.asp
Check that Firefox and IE are using the same proxy settings.
DNS issues? can you put here your A records to check is everything is ok?

Categories