Start a public PHP server using CMD (Windows) - php

How do I start a PHP public server using Command Prompt (I'm using windows).
If I use PHP -S localhost:<port> it runs the server on my own localhost but no one outside my connection can access it, but I want my friend in the US to access it.How do I do that using Command Prompt
I have not yet tried anything yet

You can try use localhost tunneling with ngrok.io or pagekite

You need to modify your router's configuration, ie.:
link internal IP (e.g. 192.168.0.XXX) and port (e.g. 80) to your external/public IP. BTW, better to use non-standard HTTP port on the outside due to security issues. You can find these settings when login to router and go to Settings->NAT Forwarding / Virtual servers.
Your friend can then access http://<YOUR_PUBLIC_IP>:<YOUR_PUBLIC_PORT> from his/her browser. If you are concerned with dynamic IP, you should register with Dynamic DNS Provider (DDNS) for example: https://www.dynu.com/

Related

Running PHP server without port

I have a typo3 folder in /var/www/my_folder, I want to run php server inside my_folder,
I run php -S localhost:8080 but I have problems later with URLs, I want get rid of :8000.
when I try php -S localhost I get
Invalid address: localhost
How can I manage this ?
You can run the PHP web server on on port 80, which is the default for HTTP, like this:
php -S localhost:80
Then you can visit http://localhost in your web browser.
However, it's common practice to use a different port for local development so that you don't have any conflicts between your dev environment and anything else which may be running on your machine. If you're sure you're not using port 80 anywhere else, feel free to use it.
What you can't do is omit the port number like you have in your second example.
Without explicite port usage, browsers use port 80 for HTTP and 443 for HTTPS. So if you want your URLs you use 'later' to not include the port, start the PHP interpreter with the one you need the URLs for.

What is the difference between the IP address needed for ssh, and the IP address that is displayed once inside the server

When I ssh into my server, I issue the following command:
ssh <username>#<ip-of-server>
Then, when I get in, I see the following as my prompt:
<username>#ip-<different-ip-address>:
When I try echo $PS1 in the server, then I see the following:
\[\e]0;\u#\h: \w\a\]${debian_chroot:+($debian_chroot)}\u#\h:\w\$, which tells me that the host must be different. Why are these not the same: ip and host?
The reason I ask is because, I can access the just fine by ssh-ing, but I cannot ping it:
ping <ip-of-server> ... results in 100% losses.
So, I thought maybe I should ping the other ip, however:
ping ip-<different-ip-address> ... also results in 100% losses.
How is it possible to not be able to ping, yet I can still log in?
Private IP is internal to AWS which is 10.x.x.x
You can also check that by invoking
curl http://169.254.169.254/latest/meta-data/local-ipv4
within your instance which gets that info from the metadata server.
Public IP (if assigned) is the external IP. You can get the same from metadata server. Try:
curl http://169.254.169.254/latest/meta-data/
If your shell prompt is an issue, you can set the prompt after querying the public IP.
ip-of-server is probably the public ip of the server. different-ip-address is probably the private ip of the server.
pings will not go through from the outside unless you enable ICMP traffic through the Security group the you've set for your instance.
It's possible to log in because the port used for SSH is open (TCP 22) in the Security group, while ICMP is not open (ICMP).

Access to Rapla through Glype

There is a Rapla event planner running at my work. It is set to be accessible only from computers in our office, though (IP check?). I needed to have an access also from my home, but the administrator won't reconfigure Rapla. However, I have an sftp account at the server (which is the same as the one where Rapla is running - same IP addressess; this server is accessible from Internet at browser's port 80, since we have our homepage running there).
I figured out, that I can upload Glype proxy script to my acoount and run it like this from any IP address: www.mycompany-domain.com/myfolder/glype/index.php. It really works and redirects me to a lot of websites, while showing my company server's IP. However, when I try to connect to a 8051 port (Rapla's port) through Glype, I get the cURL error:
The requested resource could not be loaded. libcurl returned the
error: Failed to connect to /here goes the IP/: Permission denied
Later on, I found a script called Glypeahead, which, according to the author, should fix this issue. I wasn't able to find any info how to use it and being myself just an amateur programmer, I am stuck at this moment.
So, my question is the following: how can I connect, using Glype, to Rapla's port 8051? I am open to any non-Glype solution too :-).

External XAMPP Access With Modem

I'm trying to create a live web server on my Windows 8.1 computer.
I am connected directly to my modem using ethernet (I do have a wireless router) but I am not connected to it on this computer (desktop).
I have XAMPP working and my website appears at http://localhost/home
However, if I put in my IP from www.whatismyip.com it does not load my web server.
What am I missing?
You need to create a Port Forwarding for Port 80 to your Computers local IP Address. There should be a Admin Panel for your Router (normally the Gateway - check out with Start - Run - cmd -> then insert "ipconfig" and check out the Gateway.
And i guess in XAMPP the Internet Access is blocked. But this is a simple Apache Server, so you need to open your httpd.conf File (Should be: “c:\xampp\apache\conf\extra\httpd-xampp.conf)
Search here for:
There should be a "Deny from all" - add a # in Front to deactivate that rule.
Restart your Xampp and it should work.
Here you find more Information about Port-Forwarding:
https://managewp.com/how-to-access-a-local-website-from-internet-with-port-forwarding
Any maybe you will also need to activate Port 80 on your Firewall (depends on your Configuration)
You need a method of telling request sent to your public ip to be forwarded to the private ip of the web server. Try logging into you device (router etc) and setting this up.

PHP connect via SSH tunnel to LDAP in other network

I'm developing website for my school. In that school we authenticate users via LDAP, so there was an idea to do the same via school-site. On that site everything is working perfectly, but during developing I need very often to test if such solution works, of not. In order not to commit my changes so often I want to test this site on my local computer, but for connecting with LDAP i want to use ssh tunnel. In school network we have one server through witch we are connecting with inside of our school network. It's address is phoenix.lo5.bielsko.pl. Inside this network we have LDAP server with opened 389 and 636 ports. It's address is auth.lo5. I don't have access to auth.lo5 via SSH, I can only connect with it to get some LDAP entries. So, I've tried to run SSH tunnel by running:
ssh -L 636:auth.lo5:636 hfaua#phoenix.lo5.bielsko.pl
Then, I've set in my /etc/hosts that auth.lo5 is pointing to 127.0.0.1. I'm connecting to LDAP in PHP in such a way:
ldap_connect('ldaps://auth.lo5', 636);
But I'm getting error Can't contact LDAP server. I think, that problem might be on phoenix.lo5.bielsko.pl in its SSH daemon config or in arguments passed to ldap_connect() function. Can you tell me, what should I set in sshd_config or in arguments passed to ldap_connect to get it working?
I posted the same question in similar thread, but no one has answered my question.
P.S. In my /etc/ssh/sshd_config I have line AllowTcpForwarding yes
If I got it right phoenix.lo5 and auth.lo5 are 2 different machines.
If so you have to create a tunnel to the ssh machine, and then send the ldap queries to the right machine.
Your command: ssh -L 636:auth.lo5:636 hfaua#phoenix.lo5.bielsko.pl is right if phoenix.lo5.bielsko.pl can resolve auth.lo5 via DNS or /etc/hosts, if not you need to use its internal ip address.
Also if you want to use port 636 on your pc, you need to run your command as superuser (root or with sudo) else you need to use an high port (above 1024) as stated by Borealid
Once the tunnel is up you have to point to localhost to do the queries
I ran into this same issue. Running with -d1 showed me this error:
TLS: hostname (mylaptop.local) does not match common name in certificate (*.mydomain.com).
TLS reverse lookup of 'localhost' is 'mylaptop.local', checking if that matches the certificate common name
Could be you're hitting a similar problem.
I was able to fake it out by running:
sudo hostname someserver.mydomain.com
which caused SSL to assume it was talking to the right host.
I was also getting the error hostname (mylaptop.local) does not match common name in certificate (*.mydomain.com). However I did not want to edit the hostname of my machine to match that of the LDAP server. Instead I edited the hosts file (etc/hosts on linux) file to add a line that would intercept requests to the LDAP server eg:
127.0.0.1 ldap.server.com
This has the added benefit of not requiring you to change which server name you are trying to connect to in your code, you only need to change the port number if you chose a different port.
Try replacing all instances of auth.lo5 with localhost:
ssh -L 636:localhost:636 hfaua#phoenix.lo5.bielsko.pl
and
ldap_connect('ldaps://localhost', 636);
If that doesn't work, try turning off SSL to see if that works:
ssh -L 389:localhost:389 hfaua#phoenix.lo5.bielsko.pl
and
ldap_connect('localhost', 389);

Categories