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.
Related
I am running in Google Compute Engine Node on port 80 and Apache httpd on port 81. But when I try to visit port 81 by the url, which is the IP Address, XX.XXX.XXX.XXX:81, the browser redirects the request to 80 which is the node app. How can I make it work?
ports.conf
Listen 81
sites-enabled/000-default.conf
<VirtualHost *:81>
....
</VirtualHost>
What am I missing? Thank you.
When I deploy the Node app, I have run the following command:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
netstat -l
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:3000 [::]:* LISTEN
udp 0 0 instance.c:ntp 0.0.0.0:*
udp 0 0 localhost:ntp 0.0.0.0:*
udp 0 0 0.0.0.0:ntp 0.0.0.0:*
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] SEQPACKET LISTENING 8972 /run/udev/control
unix 2 [ ACC ] STREAM LISTENING 12342 /var/run/mysqld/mysqld.sock
unix 2 [ ACC ] STREAM LISTENING 9021 /run/systemd/fsck.progress
unix 2 [ ACC ] STREAM LISTENING 27705 /home/myuser/.forever/sock/worker.1508373192880gMA.sock
unix 2 [ ACC ] STREAM LISTENING 10413 /run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 8907 /run/systemd/private
unix 2 [ ACC ] STREAM LISTENING 8928 /run/systemd/journal/stdout
unix 2 [ ACC ] STREAM LISTENING 10225 /run/uuidd/request
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
My PHP script opens port using socket like:
$socket = stream_socket_server('tcp://127.0.0.1:' . $this->port, $errno, $errstr);
For example say port is 58889.
I cannot connect to port from telnet (Connection refused).
Here is what 'netstat -plunt' command shows:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:58889 0.0.0.0:* LISTEN 13849/php
tcp 0 0 127.0.0.1:58890 0.0.0.0:* LISTEN 13841/php
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:58891 0.0.0.0:* LISTEN 13857/php
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::25 :::* LISTEN -
There is no special firewall rules on hosting provider. How to fix it?
The issue is that the TCP server is only listening for connections on the localhost IP address.
This will only allow connections from the 'local' machine.
To specify to listen for connections on all the IP addresses on the machine, which will allow connections from external machines, then use an IP Address of '0.0.0.0' (IPv4):
stream_socket_server('tcp://0.0.0.0:' . $this->port, $errno, $errstr);
I am trying to execute xdebug using dbgp client but I cannot establish a connection with the server.
My phpinfo:
xdebug.remote_enable On
xdebug.remote_handler dbgp
xdebug.remote_host localhost
xdebug.remote_mode req
xdebug.remote_port 9001
I run the client first:
[/usr/local/bin]# ./debugclient
Xdebug Simple DBGp client (0.10.0)
Copyright 2002-2007 by Derick Rethans.
- libedit support: enabled
Waiting for debug server to connect.
I run the script:
# export XDEBUG_CONFIG="idekey=netbeans-xdebug"
# php -dxdebug.remote_enable=1 debug_tmp.php
Check the stat:
# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0: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:2082 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2083 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2086 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2087 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:783 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2095 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:2096 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN
tcp 0 0 69.174.52.164:22 111.94.64.239:7531 ESTABLISHED
tcp 0 64 69.174.52.164:22 111.94.64.239:1698 ESTABLISHED
tcp 0 0 127.0.0.1:31750 127.0.0.1:80 TIME_WAIT
tcp 0 0 :::21 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 :::25 :::* LISTEN
tcp 0 0 :::443 :::* LISTEN
tcp 0 0 :::993 :::* LISTEN
tcp 0 0 :::995 :::* LISTEN
tcp 0 0 :::3306 :::* LISTEN
tcp 0 0 :::587 :::* LISTEN
tcp 0 0 :::110 :::* LISTEN
tcp 0 0 :::143 :::* LISTEN
tcp 0 0 :::111 :::* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::465 :::* LISTEN
But still, connection is not established.
Log opened at 2015-01-28 12:22:03
I: Connecting to configured address/port: localhost:9001.
E: Could not connect to client. :-(
Log closed at 2015-01-28 12:22:03
What am I doing wrong?
Nevermind,
the client is set to 9000 for some reason. So I set the xdebug port to 9000, now it's working
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