Minikube with PhpStorm and Xdebug - phpstorm

I have developed a PHP based application. This application runs actually in Kubernetes and mainly using minikube on my machine. I am using PhpStorm as IDE and I also use Xdebug for debugging purposes.
What I know from my researches are that when you start PhpStorm with Xdebug, it will start listening on a port (9000 by default). When I connect to my container (in minikube), I am able to reach the IDE at the port 9000 with netcat :
nc <my_ip_adress> 9000
This shows me a message telling that connection is open so I am able to reach the IDE from my container.
Then, when I try to use Xdebug, it is not working and Xdebug doesn't stop at the breakpoint. I was guessing that IDE should also reach the container and that part I am not sure and I don't know how to do it..
Anyone already setup this kind of configuration with minikube and PhpStorm / Xdebug?

For xdebug to work, it only needs to connect to client host. there is no need for client (in this case phpstorm) to connect to your pods as well.
I have the same setup using docker for mac. What i did to make it work:
changed xdebug.client_host configuration to host.docker.internal which is defined automatically in minikube /etc/host and can access host machine resources
made sure I have proper xdebug key defined in php.ini xdebug.idekey
made sure I use the xdebug helper extension and have the same idekey defined there
made sure I use 9003 to listen in phpstorm which is the default port for xdebug 3

If you try to debug a script with xdebug_info() in it, it will tell you exactly what Xdebug tried to do, if anything at all.
You can also make a log file by setting xdebug.log=/tmp/xdebug.log and xdebug.log_level=10, and then this log file will show even greater detail as to what went on.
Please note that although a connection can be open, you might not have the right process. Port 9000 is also used by PHP-FPM, which is why Xdebug 3 now uses 9003 by default.

Related

Unable to run Xdebug in PhpStorm, connections are refused - likely due to port 9000 not being open or not being forwarded

I'm trying to debug my PHP code running on a remote server using PhpStorm's Xdebug feature. A few weeks ago I was able to do this on another computer, but I no longer have that computer. I reinstalled and configured PhpStorm and can run SFTP and SSH with the remote server on the new computer. I tried using PuTTY, and was successfully able to use it to SSH Tunnel between the two computers and run Xdebug. But it wasn't a 'good' as the way I was able to do this on the other computer, which didn't need PuTTY.
I believe that the problem has to do with setting up Port-9000 forwarding. I added a rule for this to my BitDefender BOX2 for the local computer I develop on, but I still get refused. The tech at BitDefender thought that there may be another port that needs to be opened/forwarded in addition to port 9000.
Because the PuTTY method works on the new computer, I'm confused. Why does this work with PuTTY, but not directly with PhpStorm (without the help of PuTTY)?
Xdebug only needs port 9000, so that is the only port that PhpStorm will listen on, and Xdebug needs to connect to. I don't know BitDefender, but perhaps you only allowed outgoing connections, and not the incoming ones that you should allow?
Are the two machines on the same network, or is your machine behind a NAT network to the outside world, where your remote machine lives? In that case, you probably can't get around using your SSH tunnel with PuTTY.
You don't mention any settings, but it is worthwhile to check what shows up in the xdebug log file (when configured with xdebug.remote_log=/tmp/xdebug.log on your remote machine). It will show what Xdebug tries to connect to, and whether (and sometimes even why) the connection failed.

Trying to run Kurento remotely on EC2

I try to run Kurento on a remote EC2 instance, but I can't seem to wrap my head around how do I load the page up.I have opened all UDP ports, I have configured my kurento server to a STUN server and checked that it worked but if I run npm start -- --ws_uri=ws://kms_host:kms_port/kurento it still says that it's running on localhost.
etc/kurento/WebRtcEndpoint.conf.ini
stunServerAddress=74.125.200.127
stunServerPort=19302
; turnURL gives the necessary info to configure TURN for WebRTC.
; 'address' must be an IP (not a domain).
; 'transport' is optional (UDP by default).
; turnURL=user:password#address:port(?transport=[udp|tcp|tls])
;pemCertificate is deprecated. Please use pemCertificateRSA instead
;pemCertificate=<path>
;pemCertificateRSA=<path>
;pemCertificateECDSA=<path>
Now I'm sure I have something wrong with the way I configured it or how I think it's supposed to work. Basically what I want to know is if I want to see the page the kurento hello-world example in the documentation shows but from a remote EC2 instance running kurento, how do I do that because after following their steps
The best way to make kurento work on EC2 is configure coturn server as described in official documentation here
If you don't want it, you must find working STUN servers. In my case, on EC2, this server works fine now:
stunServerAddress=74.125.142.127
stunServerPort=19302

phpstorm debugging mamp but not my remote server

I have tried many ways to debug my remote server but I am unable to do so. My ftp and sftp and remote db is configures to my phpstorm 9 but I cannot debug my remote server it is connecting to my mamp server and debugging ,y local files but not connecting to server username and password . Basically it fails at mysql_connect but works for mamp.How can I make it deubug with server.Everything else is synced with server but I cannot debug. I really appreciate any help.
Edit: Should I install x-debug on my server(cpanel) also ?
php.ini
[xdebug]
zend_extension="/usr/local/opt/php55-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
Maybe I didn't understand your question/problem. These are the ways you can debug your code
Debug the local code that uses the local database
This is the easiest setup and it probably already works on your system. You have all the files on the local computer and also you have an instance of MySQL running on it. The code connects to localhost:3306, the xdebug extension is installed and it can connect to PhpStorm, everybody is happy.
Debug the local code that uses the remote database
You can have all the PHP files on localhost and use the local mamp stack to debug it; you control the environment, xdebug works and happily collaborates with PhpStorm. You want the code to be able to use the remote (live) database.
In this case you need a way to access the database. Either you create a MySQL user that allows you to connect from the IP address of the local computer (a firewall along the way might prevent this), or start a ssh session that creates a tunnel from the local port 3306 (or any other open port you choose) to port 3306 of the database server (assuming the host where you ssh is allowed to connect to it). You can do this by running
ssh user#remote_host -L 3306:database_host:3306
(replace user, remote_host and database_host with your actual values)
If you have a MySQL server installed and running on localhost then the local port 3306 is not open and ssh cannot use it as the source port of the tunnel. Use another port instead (let's say you use 13306):
ssh user#remote_host -L 13306:database_host:3306
Modify the local configuration files of your application to use localhost as database server and 13306 as database port.
Debug the remote code
If you want to debug the live code (it uses the live database) then you have to upload the code on the web server (the live environment) and make it work there (be able to connect to the database etc).
In order to be able to debug it you need to have the xdebug PHP extension installed on the server and properly configured in the server's php.ini configuration file.
The debugger (the remote xdebug extension) needs to connect to your local computer where PhpStorm is listening on port 9000. This is either impossible or making it happen requires changing configuration here and there in several places (that might be out of your control); we better forget about it.
We can use the ssh tunnel trick: start a ssh connection to the server that creates a tunnel from local port 9000 to the servers port 9000:
ssh user#remote_host -L 9000:localhost:9000
Test if it works
PhpStorm provides a tool that uploads a script on the web server then tries to access it to check if the xdebug extension is properly configured. Depending on the version of PhpStorm you use, you can find it either in the menu (Run -> Web Server Debug Validation, on PhpStorm 9) or somewhere in the Settings (PHP -> Servers or around, on older versions).

Prevent apache to free the port 80

I have installed WAMP2.4 on windows 7 - 64bit. Its working fine and also i am able to connect it from localhost and from outside. Skype, IIS or VMware is not installed on the system. In
"services" the mysql and apache both are set to start automatically and are in started state. All services of WAMP is working and the icon is green.
Now, the problem is, the website goes down very often. When its down, the WAMP icon is still green, mysql and apache are still in "started" state. Then I just click on "Restart all services" every time and it starts working.
When its down, I checked the "Test port 80" of Apache>Services and it says that the port is not being used. Same time when i check port 80 with "netstat" on command prompt it show the process id of apache. If i don't do any action, after some time it start working. Is there any way to set Apache not to free the port 80? Or, any batch command which check the port 80 and if its free, restart the wamp services?
I have heard of this issue before now I come to think of it.
Try adding these 2 parameters to your httpd.conf file.
Put them after this line that should already exists in httpd.conf # EnableSendfile on
# AcceptFilter: Windows, none uses accept () instead of AcceptEx ()
# And do not recycle sockets between connections. This is useful
# Network interfaces for which the pilot is defective, and for
# Some network providers like vpn pilots or filters
# Anti-spam, anti-virus or anti-spyware.
AcceptFilter http none
AcceptFilter https none
With luck this should stop Apache from hanging, which I think is your main problem.

Change port for TeamCity web server

I installed TeamCity and got it working against my project. However, I have since realized that I don't want it the administration page to be configured on port 80. I'm going to have other websites on that server that I want on the default port. How do I change the configured port?
I wandered around the configurations a bit and looked through the administration settings but couldn't figure it out.
The port number can be edited in the <TeamCity home>/conf/server.xml file, line <Connector port="8111" protocol="HTTP/1.1".
from Installing and Configuring the TeamCity server
To add to the answer provided by #sfussenegger you will also need to make sure that your build agents can still connect to the TeamCity server instance on the new port, or else your builds won't run.
To do this, you'll need to change the build agent configuration files to reflect the new serverUrl value. You can find this setting in the C:\TeamCity\buildAgent\conf\buildAgent.properties file.