How to run Laravel 5.4 on port 80 successfully - laravel

I am using a Laravel package to connect to a payment system and this particular package sends and receives data via port 80 (and as I use port 8000 to make payments, I will encounter failures).
As seen here:
How to run laravel 5 on port 80 of localhost?
I decided to give it a try but this error is returned:
Failed to listen on 127.0.0.1:80 (reason: Permission denied)
To discover which program is using port 80, I entered sudo lsof -i :80 and received the following output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 3102 root 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3103 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3104 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3105 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3106 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3107 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3108 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3115 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3116 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
apache2 3117 www-data 4u IPv6 46970 0t0 TCP *:http (LISTEN)
I also tried the command: sudo netstat -nltp | grep -iw "80" and the following is its output:
tcp6 0 0 :::80 :::* LISTEN 3102/apache2
To free port 80 I tried: sudo kill -9 3102, afterwards I ran: sudo netstat -nltp | grep -iw "80" and the output was: tcp6 0 0 :::80 :::* LISTEN 3330/apache2
(the port is re-occupied).
I very much like to know how I can use port 80 to develop my Laravel app on it (I am using Debian 9 Stretch).

Let me guess. I think you are running artisan server in the server. It's not recommended to run it on your production server. artisan server should only used for development environment.
Based on your explanation, port 80 has been used by apache2 server. That's normal. What you need to do is to put your Laravel application to apache DocumentRoot directory. Because apache2 is the real web server. For Debian like distribution, DocumentRoot for apache2 located at /var/www. You may follow this guide for more information.
Hope it helps.

Related

dnsmasq - problem with service status on Apple Silicon M1

It's start. It's working. But status is unknown.
$ brew services list
Name Status User Plist
dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ ping test90.local
PING test90.local (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.059 ms
$ sudo lsof -nP -iUDP | grep :53
mDNSRespo 208 _mdnsresponder 6u IPv4 0x4316bcf762302a5 0t0 UDP *:5353
mDNSRespo 208 _mdnsresponder 7u IPv6 0x4316bcf7622d70d 0t0 UDP *:5353
Commander 5611 sbaczyk 24u IPv4 0x4316bcf7475f9ed 0t0 UDP *:53671
dnsmasq 19828 nobody 4u IPv4 0x4316bcf7622f705 0t0 UDP 10.0.0.222:53
dnsmasq 19828 nobody 6u IPv4 0x4316bcf7622ffbd 0t0 UDP 127.0.0.1:53
dnsmasq 19828 nobody 8u IPv6 0x4316bcf7622d13d 0t0 UDP [fe80:10::9f5:a4eb:80c7:478a]:53
dnsmasq 19828 nobody 10u IPv6 0x4316bcf7622e87d 0t0 UDP [fe80:f::c6d6:4b39:3453:5eb0]:53
dnsmasq 19828 nobody 12u IPv6 0x4316bcf7622ee4d 0t0 UDP [fe80:e::604c:88ff:feb3:f84d]:53
dnsmasq 19828 nobody 14u IPv6 0x4316bcf7622d9f5 0t0 UDP [fe80:d::604c:88ff:feb3:f84d]:53
dnsmasq 19828 nobody 16u IPv6 0x4316bcf7616a87d 0t0 UDP [fe80🅱️:140c:6b55:cf47:9a25]:53
dnsmasq 19828 nobody 18u IPv6 0x4316bcf76169cdd 0t0 UDP [fe80:5::1c00:62ff:fe3c:4c68]:53
dnsmasq 19828 nobody 20u IPv6 0x4316bcf7616b41d 0t0 UDP [fe80:4::1c00:62ff:fe3c:4c69]:53
dnsmasq 19828 nobody 22u IPv6 0x4316bcf7616ab65 0t0 UDP [fe80:1::1]:53
dnsmasq 19828 nobody 24u IPv6 0x4316bcf7616ae4d 0t0 UDP [::1]:53
I performed the installation using the following commands
brew install dnsmasq
echo 'address=/.local/127.0.0.1' > /opt/homebrew/etc/dnsmasq.conf
sudo brew services start dnsmasq
brew services list
Some debug info.
$ brew config
HOMEBREW_VERSION: 3.0.9
ORIGIN: https://github.com/Homebrew/brew
HEAD: ed87211daa83982a6136e14d181a1550b46a0f17
Last commit: 5 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 02df6b76b81fa4e5ca13d3c7f4336d9a93c776e1
Core tap last commit: 2 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0 build 1200
Git: 2.24.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.2.3-arm64
CLT: 12.4.0.0.1.1610135815
Xcode: N/A
Rosetta 2: false
% brew doctor
Your system is ready to brew.
Anything else I should check?
It would be nice if this status was displayed correctly.
It's because you are running dnsmasq as superuser.
Run sudo brew services list and you'll see the status.

ERR_CONNECTION_REFUSED as accessing to the vagrant guest by browser

I'm encountering a title's problem.
vagrantfile
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder "./", "/var/www/app",
:owner => "vagrant",
:group => "vagrant",
:mount_options => ["dmode=777,fmode=775"]
httpd.conf
DocumentRoot "/var/www/app/public"
<Directory "/var/www/app/public">
...
procedure
> sudo service httpd start
[ OK ]
access https://192.168.33.10/ by host OS browser.
but ERR_CONNECTION_REFUSED occured
/etc/httpd/log/error_log
no logs about this
/etc/httpd/log/access_log
no logs about this
netstat
> netstat -ant | grep 80
tcp 0 0 :::80 :::* LISTEN
lsof
sudo lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 3991 root 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 3994 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 3995 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 3996 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 3997 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 3998 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 4105 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 4107 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
httpd 4108 vagrant 4u IPv6 15275 0t0 TCP *:http (LISTEN)
service
> sudo service httpd status
httpd (pid 3991) is running...
I have no idea about this.
Could you help me??

PhpStorm not receiving Xdebug from Vagrant machine

I've a Vagrant VM for dev with xdebug installed and I want to connect it to PhpStorm.
In my xdebug.ini I have this:
zend_extension=xdebug.so
xdebug.remote_connect_back = 0
xdebug.idekey = "vagrant"
xdebug.remote_enable=on
xdebug.remote_host=192.168.56.1
xdebug.remote_port=9001
xdebug.remote_log=/tmp/xdebug.log
But it doesn't work. I did some debug and I check that in my host machine the 9001 port was open, and it is:
phpstorm 311 jose 41u IPv4 0x2b62c0b107d1be65 0t0 TCP *:9001 (LISTEN)
phpstorm 311 jose 42u IPv4 0x2b62c0b1056e5245 0t0 TCP *:10137 (LISTEN)
phpstorm 311 jose 143u IPv4 0x2b62c0b10ae27e65 0t0 TCP 127.0.0.1:6942 (LISTEN)
phpstorm 311 jose 168u IPv4 0x2b62c0b107cd875d 0t0 TCP *:20080 (LISTEN)
phpstorm 311 jose 342u IPv4 0x2b62c0b110c70245 0t0 TCP 127.0.0.1:63342 (LISTEN)
JuniperSe 497 jose 10u IPv4 0x2b62c0b10696675d 0t0 TCP 127.0.0.1:3333 (LISTEN)
VBoxHeadl 726 jose 24u IPv4 0x2b62c0b1086e6b3d 0t0 TCP 127.0.0.1:2222 (LISTEN)
VBoxHeadl 726 jose 25u IPv4 0x2b62c0b10fe1d435 0t0 TCP *:33060 (LISTEN)
VBoxHeadl 726 jose 26u IPv4 0x2b62c0b108709435 0t0 TCP *:8088 (LISTEN)
But from Vagrant the 9001 port is not accessible:
nc -z -v -w5 192.168.56.1 9001
nc: connect to 192.168.56.1 port 9001 (tcp) timed out: Operation now in progress
And that's the same for all PhpStorm ports. But I can access 8088 or 33060
nc -z -v -w5 192.168.56.1 8088
Connection to 192.168.56.1 8088 port [tcp/omniorb] succeeded!
I've checked the option to accept external connections in PhpStorm for xdebug. I'm using Mac OS.
Ok, very silly problem. I had the external connections blocked for phpstorm, I changed that in System Preferences > Security > Firewall, on the list of apps I searched phpstorm and allow external connections

Find which process is listening on port 8001 on Mac OS X

How can I see which process is listening on port 8001 on Mac OS X?
I have tried several commands:
lsof -i | grep LISTEN
Output:
qbittorre 321 user 26u IPv4 0xc8e6037f28270c31 0t0 TCP *:6881 (LISTEN)
qbittorre 321 user 27u IPv6 0xc8e6037f216348e1 0t0 TCP *:6881 (LISTEN)
mysqld 14131 user 10u IPv4 0xc8e6037f3218da91 0t0 TCP *:mysql (LISTEN)
httpd 14133 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14135 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14136 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14137 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14138 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14139 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14148 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14149 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
httpd 14150 user 16u IPv6 0xc8e6037f216352e1 0t0 TCP *:http (LISTEN)
Skype 14543 user 57u IPv4 0xc8e6037f324f9a91 0t0 TCP *:18666 (LISTEN)
java 24640 user 68u IPv6 0xc8e6037f3295a3e1 0t0 TCP *:http-alt (LISTEN)
java 24640 user 73u IPv6 0xc8e6037f32958fe1 0t0 TCP *:8009 (LISTEN)
java 24640 user 101u IPv6 0xc8e6037f32959ee1 0t0 TCP localhost:8005 (LISTEN)
lsof:
sudo lsof -nPi -sTCP:LISTEN | grep 8001
Nothing found
netstat:
netstat -a | grep 8001
Nothing found
I know that the port is in use by someone, because I am trying to change the Emacs simple-httpd default httpd-port from 8080 (default) to 8001, and it fails:
Warning (initialization): An error occurred while loading `/Users/user/.emacs':
File error: Cannot bind server socket, address already in use
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
How can I resolve it? I tried also to set the port to 8002, with the same problem and didn't find which process is listening on port 8002.
What can be the source of the problem?
Using nmap I discovered that port 8001 is used by vcom-tunnel service and it’s a closed port and that port 8002 is used by teradataordbms and is also closed.
What are these services used for? Can I disable them and use their occupied ports?
You can use lsof to detect who is using the connection as long as there is active traffic on the connection.
Here is a demonstration:
setting a server on a given port fails with the error Address already in use
lsof doesn't report any listener for that port
Here is the shell log demonstrating this:
python -m SimpleHTTPServer 3333 2>&1 | fgrep error
Output:
socket.error: [Errno 48] Address already in use
sudo lsof -i TCP:3333
echo $?
Output:
1
[1] : starting a web server on port 3333 fails with the error Address already in use
[2] : lsof doesn't report port 3333 being used by anyone
Let's generate traffic in order to force lsof to detect the usage of the port: in another terminal open a telnet connection:
telnet localhost 3333
Now back on your previous terminal, you will see that lsof finds your port:
sudo lsof -n -P -i :3333
Output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
telnet 78142 loic 5u IPv4 0x3fa2e8474ece6129 0t0 TCP 127.0.0.1:51855->127.0.0.1:3333 (ESTABLISHED)
There is traffic going on, but according to the OS, only one end of the connection is there, the initiator, there still isn’t any `LISTENER`!
Note: in my case, OS is macOS v10.13.3 (High Sierra), but I had that with previous versions of macOS/OSX too

Cannot connect to apache server locally

I am trying to access an Apache server on my local machine, but can't get it to work. I had it working last week, but then it randomly stopped working. I have edited the httpd.conf file to update the port to 9876. I also added the ExecCGI directive in the HTDocs directory.
I usually see the index.html page I created by visiting localhost:9876, but now I just see an erroneous page. When I just run localhost:80, I see the it works page! How is something still showing up on port 80 when I clearly changed it to another port? I read more about this and found out it has to do with the sharing settings on OSX. These settings were never enabled to begin with. Why am I still seeing a page on port 80, and why is the designated port I chose not showing any content?
Things I have done:
I have tried stopping and restarting the server multiple times(with
sudo)
I use the web browser or netcat to connect to apache, but I get no response.
I ran lsof -i4TCP:9876 and get the following output:
launchd 1 root 25u IPv6 0xee69429dde6f1b6f 0t0 TCP localhost:ipp (LISTEN)
launchd 1 root 26u IPv4 0xee69429dde6f2b77 0t0 TCP localhost:ipp (LISTEN)
LogMeIn 82 root 5u IPv4 0xee69429dde6f238f 0t0 TCP *:globe (LISTEN)
vpnagentd 83 root 6u IPv4 0xee69429de115bb77 0t0 TCP localhost:29754 (LISTEN)
GitHub 201 kamranpirwani 6u IPv4 0xee69429de35f4b77 0t0 TCP localhost:25035 (LISTEN)
GitHub 201 kamranpirwani 7u IPv6 0xee69429dde6f0eaf 0t0 TCP localhost:25035 (LISTEN)
mysqld 412 _mysql 14u IPv6 0xee69429dde6efdaf 0t0 TCP *:mysql (LISTEN)
Coda\x202 726 kamranpirwani 5u IPv4 0xee69429deb25fb77 0t0 TCP *:6942 (LISTEN)
Coda\x202 726 kamranpirwani 7u IPv6 0xee69429dde6f12ef 0t0 TCP *:6942 (LISTEN)
Coda\x202 726 kamranpirwani 10u IPv4 0xee69429deb47438f 0t0 TCP *:50490 (LISTEN)
Coda\x202 726 kamranpirwani 11u IPv6 0xee69429dde6f062f 0t0 TCP *:50490 (LISTEN)
Coda\x202 726 kamranpirwani 12u IPv4 0xee69429dea898b77 0t0 TCP *:50491 (LISTEN)
Coda\x202 726 kamranpirwani 13u IPv6 0xee69429dde6ef96f 0t0 TCP *:50491 (LISTEN)
httpd 1879 root 5u IPv6 0xee69429dde6f172f 0t0 TCP *:http (LISTEN)
httpd 1880 _www 5u IPv6 0xee69429dde6f172f 0t0 TCP *:http (LISTEN)
httpd 1920 _www 5u IPv6 0xee69429dde6f172f 0t0 TCP *:http (LISTEN)
This leads me to believe the my apache web server is listening for requests on this port. Why can't the browser or netcat connect to it?
Edit:
Log file(with personal email removed) http://pastebin.com/84RcB2Er
First you say (emphasis mine):
I am trying to access an Apache server on my local machine, but
can't get it to work.
But then you say (again, emphasis mine):
When I just run on localhost, I see the it works page!
So unclear what the problem is.When you say you edited the .conf which one? Apache by default can handle virtual hosts so it’s possible you are running two virtual hosts on your machine with different document roots: One responding on port 80 & the other on port 9876. Can you exact details of the contents of the file you changed?
EDIT: The original poster indicates they are editing the httpd.conf in this location:
~/apache/conf/httpd.conf
When the systemwide Apache config is in this location:
/etc/apache2/httpd.conf

Resources