Running PHP server without port - php

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.

Related

Start a public PHP server using CMD (Windows)

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/

How to remove port number from url using apache server?

I have installed Apache, PHP, Mysql in ubuntu system.
I have changed the port of apache server 80 to 802 in httpd.conf file.
I am accessing localhost from the below URL successfully.
http://localhost:802/
But the thing I want to access the localhost without using port number in the URL. Where I need to change for this.
Please suggest.
Where I need to change for this.
In httpd.conf where you set the port number to 802, set it back to 80.
HTTP operates on port 80 by default, and web browsers use that default by convention. Since you have changed that default, you need to specify the port in the address. Otherwise the web browser will attempt to connect to port 80 and won't find your server.

How to make "php -S" to work on local network?

In OS X Mavericks (and newer), start a PHP server from the command line:
cd to/your/directory
php -S localhost:8888
It works, but the server only available on that computer only. Is there a way to test it on other devices within the same LAN?
EDIT:
You will want to launch the server with the command
php -S 0.0.0.0:8888
This will allow you to access the server remotely (see docs http://php.net/manual/en/features.commandline.webserver.php)
After this is done there are 2 ways to view the site on your local network
http://192.168.1.2:8888 where 192.168.1.2 is the IP address of your computer which you can find in your System Preferences under Network.
http://myMac.local:8888 where myMac is your local computer name which you can find in your System Preferences under Sharing.
REMEMBER: Both of these options may require your firewall to allow incoming traffic to port 8888 (or whatever port your script is listening on), if you have that running.
Start with:
php -S 0.0.0.0:8888
otherwise you bind the server to localhost;

Port Redirect on Mac

What is the easiest option to redirect a request to a different host/port?
Here is my entire scenario:
I am making a request using php to a certain ip and port. The response includes another url location, but it is badly configured and instead of including ip and port, it simply includes a server name. Now, if I access the entire url location that I have as response with the server name replaced with the proper ip and port it works.
I've tried editing /etc/hosts setting the server name to the ip address, but how do I workaround the port too?
I am using mac osx 10.9.4, and I've tried some things with ipfw and pf, but neither really worked.
Thanks.
I had a similar problem quite recently on Mavericks (10.9). The way I solved it included 2 steps:
hosts file
Simply added a line similar to this:
127.0.0.1 www.someaddress.com
port forwarding
To set up port forwarding I used ipfw, which worked fine, e.g:
ipfw add 100 fwd 127.0.0.1,9001 tcp from any to any 80 in
In the example above port 9001 is forwarded to port 80. Even though ipfw is deprecated it still works.

apache and mysql ports

I am installing an open source software, which is `vtiger, and that use mysql and php
The first screen in installing that software asks for mysql and apache code,
the installation tools set these values as:
apache port 8888
and mysql port 33307
but when I open my xampp I see different ports like this:
Should I change the values of these ports to the values that I see in the image or not?
Thanks in advance
edit
this is what the installation tool suggest
so should I replace the 8888 with the 8082
and should I replace the 33307 with 3306 ?
Mysql's default port is 3306, and your XAMPP control panel shows that's the one in use, so you don't need to touch anything here.
As per apache webserver, the default http port is 80, which in this case you could access with
http://localhost
but you can use pretty much whatever you want as long as you append the port number to the url
http://localhost:8082
http://localhost:8082/anotherpage.html
Your Apache webserver is listening to both 4430 and 8082. I wonder if http://localhost:4430 would try to open as https, but I believe that is irrelevant at this point.
Long story short: if you aren't planning to use any other app on port 80, just set Apache to listen to port 80 to forget about appending port numbers on your urls.

Categories