how can I 'socket_bind' to port 80?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
paganeli
Forum Newbie
Posts: 1
Joined: Sat May 30, 2009 11:15 am

how can I 'socket_bind' to port 80?

Post by paganeli »

Hello!

I want to bind to port 80 but in order to do this I must run my php script as root. My script runs in cli. If i execute 'sudo php myscript.php' it connects to port 80. What should I do in order not to use sudo?? This script is called from another script by using proc_open. Is there any way to make it run?

Thanks in advance.
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Re: how can I 'socket_bind' to port 80?

Post by SidewinderX »

All ports below 1024 require root permissions. You can either:

1) Add yourself to the sudoers file
2) Install authbind
3) Use port address translation
Post Reply