Debugging not starting - php

UPDATE:
I've spent way too much time on this and have decided to ditch it and continue using the clunky NetBeans.
ORIGINAL QUESTION:
I'm having some difficulty getting xdebug to work with sublime text 2.
What I have done so far is install:
LAMP,
php5-xdebug
python2.6
sublime-text-2
sublimexdebug
If I then use sublime to open a php file and press shift+f8, the xdebug menu pops up from which I can add/remove breakpoint and also start debugging.
Some php:
Menu drops down when I press shift+f8:
Debugging started:
In that image it says:
Xdebug: No URL defined in project settings file
Info.sublime-project contains:
{
"folders":
[
{
"path": "/var/www"
}
],
"settings": {
"xdebug": { "url": "http://localhost" }
}
}
As you can see from the 3rd screenshot, I have started debugging and nothing happens, no errors, no browser window opens, nothing. If I manually navigate to localhost/info.php, the page loads as normal. If I manually add ?XDEBUG_SESSION_START=sublime.xdebug to the end of the url so localhost/info.php?XDEBUG_SESSION_START=sublime.xdebug and hit refresh on the browser, the page loads as normal and debugging still doesn't start.
What am I doing wrong?
UPDATE: Some info about ports:
Before trying to start xdebug via sublime text 2
oshirowanen#ubuntu:~$ netstat -antp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 90.190.20.220:54913 90.180.80.70:443 ESTABLISHED 2439/python
tcp 0 0 90.190.20.220:51727 190.40.210.160:443 TIME_WAIT -
tcp 1 0 90.190.20.220:50967 90.180.90.20:80 CLOSE_WAIT 2349/ubuntu-geoip-p
tcp6 0 0 :::80 :::* LISTEN -
oshirowanen#ubuntu:~$
After starting chromium manually and starting xdebug via sublime text 2
oshirowanen#ubuntu:~$ netstat -antp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:17500 0.0.0.0:* LISTEN 2241/dropbox
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:59424 127.0.0.1:80 ESTABLISHED 2924/chromium-brows
tcp 0 0 127.0.0.1:43123 127.0.0.1:9000 ESTABLISHED -
tcp 0 0 127.0.0.1:9000 127.0.0.1:43123 ESTABLISHED 2903/sublime_text
tcp 0 0 90.190.20.220:40809 170.190.40.70:443 ESTABLISHED 2924/chromium-brows
tcp 0 0 90.190.20.220:54913 90.180.80.70:443 ESTABLISHED 2439/python
tcp 0 0 90.190.20.220:43900 170.190.70.90:443 ESTABLISHED 2924/chromium-brows
tcp 0 0 90.190.20.220:35259 170.190.70.100:443 ESTABLISHED 2924/chromium-brows
tcp 0 0 127.0.0.1:59426 127.0.0.1:80 TIME_WAIT -
tcp 0 0 90.190.20.220:37922 170.190.70.90:443 ESTABLISHED 2924/chromium-brows
tcp 1 0 90.190.20.220:50967 90.180.90.20:80 CLOSE_WAIT 2349/ubuntu-geoip-p
tcp 0 0 90.190.20.220:40847 170.190.40.60:80 ESTABLISHED 2924/chromium-brows
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 127.0.0.1:80 127.0.0.1:59423 TIME_WAIT -
tcp6 0 0 127.0.0.1:80 127.0.0.1:59424 ESTABLISHED -
oshirowanen#ubuntu:~$

Some tips:
Check that Xdebug is running checking the information generated by the phpinfo command.
Enable remote debugging in the xdebug configuration (and verify again with the phpinfo command):
xdebug.remote_enable=1
I don't use the xdebug setting in Sublime Text. I think it is not necessary.
Open the console in Sublime Text. Any problem is logged in the console. There are some problems in Ubuntu reported in the pulgin homepage.
I use a browser extension to activate or deactivate the debugging. In Chrome look for "Xdebug Helper for Chrome". You need to configure the cookie name as "sublime.xdebug".

I use Easy xDebug for firefox to kick start the debug session and that works a charm. You need to use "sublime.xdebug" for the idekey.
I presume that you've got some break points in there? Your screenshots imply that you do but make sure that you use the shift+f8 menu to add them.

You have got a problem in your configuration, it is using the wrong syntax (according to Issue #13):
{
"folders":
[
{
"path": "/var/www"
}
],
"settings": { <<<==== problem here
"xdebug": { "url": "http://localhost" }
}
}
Instead it should be:
{
"folders":
[
{
"path": "/var/www"
}
],
"xdebug":
{
"url": "http://localhost"
}
}
This is probably also causing it not working.

I experienced the same issue and submitted bug report here:
https://github.com/Kindari/SublimeXdebug/issues/58
However, it may be socket related bug in XDebug itself:
http://forums.netbeans.org/viewtopic.php?p=141779#141779

Related

Laravel web sockets automatically stopped

I am using beyondcode/laravel-websockets to implement web sockets functionality in Laravel. I am using supervisor in Apache server to run processes for database queues and web sockets. It was working fine until one day I realized that It has stopped working. I haven't made any changes to supervisor.conf file.
This is my supervisor.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/webroot/ROOT/artisan queue:work --tries=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=apache
redirect_stderr=true
stdout_logfile=/var/www/webroot/ROOT/worker.log
stopwaitsecs=3600
startsecs=0
[program:websockets]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/webroot/ROOT/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=apache
When I try to start all supervisor processes using command supervisorctl start all, I get the following output:
laravel-worker:laravel-worker_00: started
websockets:websockets_00: ERROR (spawn error)
Based on this, I manually started the web sockets from my root directory using php artisan websockets:serve and I got below error:
Starting the WebSocket server on port 6001...
RuntimeException
Failed to listen on "tcp://0.0.0.0:6001": Address already in use (EADDRINUSE)
at vendor/react/socket/src/TcpServer.php:184
180▕ // #link https://3v4l.org/3qOBl
181▕ $errno = SocketServer::errno($errstr);
182▕ }
183▕
➜ 184▕ throw new \RuntimeException(
185▕ 'Failed to listen on "' . $uri . '": ' . $errstr . SocketServer::errconst($errno),
186▕ $errno
187▕ );
188▕ }
+17 vendor frames
18 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
As mentioned in the exception, the port I am using for web sockets i.e. 6001 is already in use. I listed the used ports using the command netstat -tulpn and it shows that 6001 port is being used by php. This is the output:
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 23974/php
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::111 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 0.0.0.0:749 0.0.0.0:* -
udp6 0 0 :::111 :::* -
udp6 0 0 :::749 :::* -
I killed the process using kill 23974 but it reopens quickly and uses the same port again automatically. I am not being able to figure what exactly is using this port. I tried reconfiguring, restarting supervisor, redeploying my code etc. but nothing worked. What might be the possible issues here?

Cannot connect to apache server from local machine

I have installed apache and php on a linux server CentOS 6.4. I followed these steps
yum install -y httpd
/sbin/service httpd restart
yum install -y php php-mysql
yum install -y mod_ssl openssl
/sbin/service httpd restart
service iptables stop
I changed the ServerName in /etc/httpd/conf/httpd.conf from
#ServerName www.example.com:80
to
ServerName 172.32.35.14 (ip address of the server)
/sbin/service httpd restart
I have a php sample pas with the following code:
<?php
phpinfo();
?>
But when I try to access the page http://172.32.35.14/info.php from my local machine it says "Problem loading page". Whereas, I get proper response when connected to the page from 172.32.35.15
My ISP doesnt block http requests.
172.* network is a VPN. I connected to the VPN, able to ping the machine, do a ssh connection to the machine using putty. But when I cannot access the php page from my local machine.
What am I missing? Please advice
netstat -tulpn output is:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1235/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 4406/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 4198/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4636/master
tcp 0 0 0.0.0.0:52330 0.0.0.0:* LISTEN 1253/rpc.statd
tcp 0 0 :::111 :::* LISTEN 1235/rpcbind
tcp 0 0 :::80 :::* LISTEN 30170/httpd
tcp 0 0 :::22 :::* LISTEN 4406/sshd
tcp 0 0 ::1:631 :::* LISTEN 4198/cupsd
tcp 0 0 ::1:25 :::* LISTEN 4636/master
tcp 0 0 :::443 :::* LISTEN 30170/httpd
tcp 0 0 :::46690 :::* LISTEN 1253/rpc.statd
udp 0 0 0.0.0.0:1005 0.0.0.0:* 1253/rpc.statd
udp 0 0 0.0.0.0:111 0.0.0.0:* 1235/rpcbind
udp 0 0 0.0.0.0:631 0.0.0.0:* 4198/cupsd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1129/dhclient
udp 0 0 0.0.0.0:986 0.0.0.0:* 1235/rpcbind
udp 0 0 0.0.0.0:39783 0.0.0.0:* 1253/rpc.statd
udp 0 0 :::111 :::* 1235/rpcbind
udp 0 0 :::38152 :::* 1253/rpc.statd
udp 0 0 :::986 :::* 1235/rpcbind
iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Please confirm your server(172.32.35.14) where you have install php and mysql right?
What is your local machine ip?
Please run tracert and nslookup command from your local machine:
tracert 172.32.35.14
nslookup 172.32.35.14
and see where packets drops.

Unable to start laravel development server on linux

I am using laravel 5 for my project and everything has been working fine but recently I am facing this problem which I done understand.
devboy#devboy-hp ~/sonel_ims_project/ims_eneo $ php artisan serve
Laravel development server started on http://localhost:8000/
[Fri Nov 13 12:00:56 2015] Failed to listen on localhost:8000 (reason: Address already in use)
I have tried devboy#devboy-hp ~ $ sudo netstat -plnt and get
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1840/dnsmasq
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1985/cupsd
tcp 0 0 127.0.0.1:8888 0.0.0.0:* LISTEN 7563/php-5.6.3
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1656/master
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 6966/httpd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 740/smbd
tcp 0 0 127.0.0.1:6942 0.0.0.0:* LISTEN 7442/java
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 6931/php-5.6.3
tcp 0 0 0.0.0.0:6667 0.0.0.0:* LISTEN 1539/ircd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 740/smbd
tcp 0 0 127.0.0.1:63342 0.0.0.0:* LISTEN 7442/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6966/httpd
tcp6 0 0 :::21 :::* LISTEN 7337/proftpd: (acce
tcp6 0 0 ::1:631 :::* LISTEN 1985/cupsd
tcp6 0 0 :::3128 :::* LISTEN 1416/squid3
tcp6 0 0 :::25 :::* LISTEN 1656/master
tcp6 0 0 :::445 :::* LISTEN 740/smbd
tcp6 0 0 :::3306 :::* LISTEN 7343/mysqld
tcp6 0 0 :::139 :::* LISTEN 740/smbd
Then I change port like so php artisan serve --port="8888"
but get similar error like below after a while:
Laravel development server started on http://localhost:8888/
[Fri Nov 13 12:01:02 2015] Failed to listen on localhost:8888 (reason: Address already in use)
The first time it happened, it was java using port 8000, so I killed the process and started the server and it worked. Upon stopping and restarting, I get the same error. What could be the problem (as I said everything has been working fine except now and I have not done any major update)?
Your previous deployment in your local is already running that's why you can't run php artisan serve. You can solve your issue by following this command in your terminal:
ps -ef | grep php you'll see this list:
gujarat 6690 3500 0 05:55 pts/1 00:00:00 php artisan serve
gujarat 6694 6690 0 05:55 pts/1 00:00:00 sh -c '/usr/bin/php5'
-S localhost:8000 '/home/gujarat/WebDevelopment/quickstart-basic'/server.php gujarat 6695 6694 0 05:55 pts/1 00:00:00 /usr/bin/php5 -S localhost:8000
/home/gujarat/WebDevelopment/quickstart-basic/server.php
gujarat 7436 3500 0 06:26 pts/1 00:00:00 grep --color=auto php
Now kill it using: sudo kill 6690 if still exist then use this sudo kill -9 6690 you'll see this result:
[1]+ Killed php artisan serve
Now you can serve your local using php artisan serve again
please restart apache server
sudo apache restart
And once again run your project in another port
php artisan serve --port=2020
This is exactly what I did for the problem.
I exit PHPStorm
sudo netstat -plnt
kill 7563 (Process using port 8888)
kill 6931 (Process using port 8000)
sudo /opt/lampp/lampp restart (Restart my server altogther)
php artisan serve
Launch PhpStorm
Now everything is working fine. What caused the problem anyway?
Using lsof, you can see what is listening on the port.
sudo lsof -i :80
Change the 80 to whichever port you're interested. You need to be root or sudo.
Run this comment
sudo netstat -plnt
The output will show like this
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 14 0 127.0.0.1:8000 0.0.0.0:* LISTEN 3648/php7.3
Then kill the port:8000 using this comment
kill -9 3648
Well the problem might be it didnt stop the expected way previously eg via CTRL+C so what you can do is to check for running php processes and kill them 1 by 1.
i) Run ps -A from the terminal then identify the php process ids (most of the times they are two)
ii) Run sudo kill -9 pid# corresponding to the php pids.
iii) Run php artisan serve and it will work.
This can happen when there is already an app running on 127.0.0.1:8000
You can close that app then it will work or not available on the current host.
OR if you want to run multple apps then use shown below way:
You can use this command to run sudo php artisan serve --port=8082 for Linux
php artisan serve --port=8082 for window

How the virus got to the WordPress (uniq/load.php -> crypted120med.exe)? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
When I go to the
http:// MY_IP :8080/uniq/load.php
or
http:// MY_DOMAIN :8080/uniq/load.php
But when I go to the
http:// MY_DOMAIN/uniq/load.php
Page 404
Folder /uniq/ on the server does not.
~# find / -name "load.php" -print
/home/site/wp-includes/load.php
Where can I find this file? How do I remove this virus?
UPD:
~# netstat -anop | grep LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1798/sendmail: MTA: off (0.00/0/0)
tcp 0 0 127.0.0.1:9312 0.0.0.0:* LISTEN 1983/searchd off (0.00/0/0)
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1839/mysqld off (0.00/0/0)
tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN 1798/sendmail: MTA: off (0.00/0/0)
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 24312/nginx.conf off (0.00/0/0)
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 17574/ld-linux.so.2 off (0.00/0/0)
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1996/sshd off (0.00/0/0)
tcp6 0 0 :::80 :::* LISTEN 24312/nginx.conf off (0.00/0/0)
tcp6 0 0 :::21 :::* LISTEN 1405/proftpd: (acce off (0.00/0/0)
tcp6 0 0 :::22 :::* LISTEN 1996/sshd off (0.00/0/0)
unix 2 [ ACC ] STREAM LISTENING 1515747955 1364/php-fpm.conf) /var/run/php5-fpm.sock
unix 2 [ ACC ] STREAM LISTENING 1515750299 1839/mysqld /var/run/mysqld/mysqld.sock
unix 2 [ ACC ] STREAM LISTENING 1515748802 1798/sendmail: MTA: /var/run/sendmail/mta/smcontrol
Temporary solution
~# kill 17574
Solution
https://www.debian-administration.org/article/57/Making_/tmp_non-executable
Dealing with a hacked WordPress site can be very difficult if you have no backups.
WordPress often gets compromised via malicious file uploads allowing remote users to add new files to the system among many other things (cron jobs, malicious binaries etc).
Based on the output of netstat -anop that you ran, we are able to see a process running that is listening on port 8080 on your server. The process in question is ld-linux.so.2 which was most likely uploaded to your server, or possibly compiled on your system through a malicious shell. Find this file and get rid of it. If you can find out how it got there by going through access logs, even better. This might reveal the exploitation vector.
I've seen a lot of PHP shell backdoors that get uploaded to servers that attackers can control remotely by sending them HTTP requests.
Step 1: Replace all WordPress files with a freshly downloaded copy of WordPress (just download from http://wordpress.org/latest.zip and upload everything to your WordPress site root. This will make sure any modified WP files are restored.
Step 2: Search for malicious files. This command can be helpful in finding PHP shell scripts: grep -E '(?:(shell_)?exec|system|eval)' /path/to/wordpress/* -R Examine any files it finds and determine if they should be deleted.
Step 3: If step 2 turns up any hits, search your server access logs for requests to those files, and then search the access logs for the IP address that accessed them to see if there is anything else that should be deleted.
Now might be a good time to cycle your logs so you start fresh and can continue to examine them over the coming days to see if they try to strike again.
Step 4: Look for cronjobs that may have been created by the attackers to run scheduled tasks. You only need to look at the cronjobs your website user has permission to access. I've seen these scripts create cron jobs to execute tasks or restart malicious files periodically.
Step 5: ...this is by no means a complete list but a start.
If you don't have WP backups (database and files) it may be a lost cause. If you don't find the exploit, attackers can continue to run code on your site and upload new exploits.

netcat "Connection refused" on localhost

I'm trying to get a value from a netcat connection started at a php file, but it dies with:
localhost [127.0.0.1] 2000 (?) : Connection refused
I don't know why but it works well if I ssh it as apache user (www-data), this is what I've done:
1) Start an endless loop serving a date with a little delay:
$ (while true; do nc -l -p 2000 -c "sleep 5; date"; done)&
2) Check if is working:
$ su www-data
$ nc localhost 2000
Fri Oct 16 21:33:20 COT 2009
3) Create /var/www/test.php as follows:
<pre><?php
exec('nc localhost 2000>>/var/www/dates.txt 2>>/var/www/errors.txt &');
?></pre>
4) Run it on a browser:
http://myserver.com/test.php
5) Finally take a look at both txt's, dates is empty (nothing like the response in #2) and errors has the "Connection refused" error.
The server is a LAMP cluster running Ubuntu Server 9.04 with DRBD and Heartbeat.
What is driving me crazy is that this test.php works well in my laptop (LAMP on Ubuntu Desktop 9.04) and the server seems to have the ports already open and listening:
$ netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4743 0.0.0.0:* LISTEN 2326/openhpid
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3364/mysqld
tcp 0 0 0.0.0.0:2000 0.0.0.0:* LISTEN 9510/nc
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3470/apache2
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2320/sshd
tcp 0 0 127.0.0.1:3551 0.0.0.0:* LISTEN 2354/apcupsd
tcp6 0 0 :::22 :::* LISTEN 2320/sshd
I think that this is a programming related question right?, if not just close it without any comments please.
Thank in advanced!!!
Well, it was a permission problem after all... fixed editing /etc/sudoers with visudo to add:
www-data ALL = NOPASSWD: /bin/nc

Categories