I tried to start laravel project on linux - php

Suddenly... my website happens timeout-error.
it seems not process does not work.
How should I restart the project...
php-fpm.conf
$ service apache2 restart
Redirecting to /bin/systemctl restart apache2.service
Failed to restart apache2.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status apache2.service' for details.
[ec2-user#ip-172-31-30-200 laravel6]$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: failed (Result: exit-code) since Mon 2021-04-12 09:12:06 ; 1min 48s ago
Docs: man:httpd.service(8)
Process: 4123 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 4123 (code=exited, status=1/FAILURE)
Status: "Reading configuration..."
.ap-northeast-1.compute.internal systemd[1]: Starting The Apache HTTP Server...
.ap-northeast-1.compute.internal httpd[4123]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
.ap-northeast-1.compute.internal httpd[4123]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
.ap-northeast-1.compute.internal httpd[4123]: no listening sockets available, shutting down
.ap-northeast-1.compute.internal httpd[4123]: AH00015: Unable to open logs
.ap-northeast-1.compute.internal systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
.ap-northeast-1.compute.internal systemd[1]: Failed to start The Apache HTTP Server.
.ap-northeast-1.compute.internal systemd[1]: Unit httpd.service entered failed state.
.ap-northeast-1.compute.internal systemd[1]: httpd.service failed.
$ systemctl restart php7.0-fpm.service
Failed to restart php7.0-fpm.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status php7.0-fpm.service' for details.
$ systemctl stop httpd
Failed to stop httpd.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status httpd.service' for details.

#nuzil answer here,
48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Please edit httpd.conf file.
/usr/local/etc/httpd/httpd.conf
And replace
Listen 80
with
Listen 127.0.0.1:80
Restart apache
sudo apachectl -k restart

Maybe you tried use same port in two configuration files, or 80 port used on other service like nginx. Try sudo lsof -n -i :80 | grep LISTEN to check process that using 80 port.
Also, you missed the sudo command to execute systemctl command. Maybe that is permission problem.

Related

48)Address already in use: AH00072: make_sock: could not bind to address [::]:80

I get a apache error when I try access to anything folder or file, it returns Http Not found or Forbidden
I am trying restart and start apache
sudo apachectl restart
output:
(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
I am trying stop it
sudo apachectl stop
output
httpd (no pid file) not running
I run sudo lsof -i:80
output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 8904 root 5u IPv6 0x21884d81f1597d8f 0t0 TCP *:http (LISTEN)
httpd 9012 _www 5u IPv6 0x21884d81f1597d8f 0t0 TCP *:http (LISTEN)
httpd 12726 _www 5u IPv6 0x21884d81f1597d8f 0t0 TCP *:http (LISTEN)
httpd 12731 _www 5u IPv6 0x21884d81f1597d8f 0t0 TCP *:http (LISTEN)
httpd 12732 _www 5u IPv6 0x21884d81f1597d8f 0t0 TCP *:http (LISTEN)
Any idea to solve that ?
Useful information:
OS X El Capitan
In my Mac with Mojave (10.14.1) suddenly Apache couldn't give to serve ipv4 anymore, then gave me ERROR 403. I tried to kill all apache (sudo killall httpd)... checking de PID's on (sudo lsof | grep AMP | grep apache)... even didn't work... just ipv6 was available... still ERROR 403.
What works for me: Disable OSX's built-in Apache server.
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
After that:
sudo apachectl -k restart
Be happy :)
This one helped me:
Please edit httpd.conf file.
/usr/local/etc/httpd/httpd.conf
And replace
Listen 80
with
Listen 127.0.0.1:80
Restart apache
sudo apachectl -k restart
One of a couple of things could be happening:
You have a different version of apache running. You can make sure that you're using the correct one by running which apachectl. As an example, I also have two versions of apache /usr/sbin/apachectl and /usr/local/bin/apachectl
You're not running apachectl start as root, although it appears that you are.
You can run sudo lsof -i:80 to see what's binding that port currently
Try
sudo netstat -ltnp | grep ':80'
Output: tcp6 0 0 :::80 :::* LISTEN 1500/apache2
sudo kill 1500
sudo service apache2 restart
this error ocurs because apache server listen by deafult in port 80 so another service or program is using that port and apache canot start.
The solution is identify what program or service is using that port an then close, disable or unistall it.
to identify you can run netstat
sudo netstat -ltnp | grep ':80'
or
sudo lsof -i:80
in my case i have installed nginx and apache at the same time and both uses the port 80.
Temporary Solution: Stop or kill the service, program, etc.
Permanent Solution:
Change the port of apache server in config file
/etc/apache2/apache2.conf
Uninstall the service or program that uses port 80.
in my case I needed both so I decided to temporarily fix it by disabling the service with:
systemctl stop MyServiceName.service
If it is a service otherwise use kill command.
I had my configuration set up this way before as well, and ran into the same problem after I upgraded OSX this last time. I tried to find ANYTHING that was listening on either port 80 or 443 and couldn't find a thing anywhere. It took me a while but finally found another article that described a fix that actually worked. Keep in mind I'm using a homebrew install and have unloaded the default apache2 install that comes with Mac OSX.
Here's what I had before in my httpd.conf:
Listen 80
and I had something similar in ssl.conf
Listen 443 https
I had to alter my httpd.conf file to use a ServerName of localhost and Listen on 0.0.0.0:80, and same for ssl.conf but 0.0.0.0:443 https
httpd.conf:
ServerName localhost
Listen 0.0.0.0:80
and ssl.conf
Listen 0.0.0.0:443 https
Once I tried starting it again, everything was happy. Hope that helps! I would link to the article but I'm having trouble finding it again!
Well, it looks as if httpd is already running. To check run
lsof -i TCP:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 281 root 3u IPv6 19479 0t0 TCP *:80 (LISTEN)
....
So kill httpd and do what you want
If you've recently done a software update and you renamed or removed any of the default files in /etc/httpd/conf.d/ go have a look there. You might have duplicate directives because the package manager re-installed them.
In my case, I prefixed the files with numbers so I could control the load order... but an OS update re-installed the original files so
I had two files with "Listen 443" in them which conflicted and wasn't caught by the syntax check. Removing the os files fixed the issue.
(This time I left them but made them empty so the conflict will be displayed on re-install or update)

Permission denied: httpd: could not open error log file /etc/httpd/logs/error_log

When I want to restart the httpd searvice on centOS 6.7 I have the following error:
/etc/init.d/httpd restart
Stopping httpd: [FAILED]
Starting httpd: (13)Permission denied: httpd: could not open error log file /etc/httpd/logs/error_log.
Unable to open logs
[FAILED]
This is error_log:
ls -Z /etc/httpd/logs/error_log
-rw-r--r--. root root unconfined_u:object_r:var_t:s0 /etc/httpd/logs/error_log
I disabled selinux also.
What is the problem?
httpd probably runs as user apache or user httpd. Your log is owned and only writable by root. Change ownership of your log file to make this work.
This should do the trick:
~# chown apache:apache /etc/httpd/logs/error_log
Probably you should change the group of that forder to apache, it's not recommended to have root as owner of server stuff. Anyway apache should change that on his own after http starts...
From httpd Wiki:
Before we start, we need to be aware that the Apache HTTP server
(httpd) runs as a particular user and group.
On Linux as well as most other Unix-like systems, httpd is started as
the "root" user; UID=root, GID=root. This is necessary because only
this user can bind to port 80 and 443 (anything below 1024 in fact).
After http starts and binds to its ports (defined by the Listen
statments in httpd.conf), it changes user to that specified in
httpd.conf. Typically:
User: apache
Group: apache
Note that Debian based systems, including
Ubuntu, use "www-data" instead.
As a possible solution you should add yourself into the group apache
usermod -a -G apache (username)
Then:
chgrp apache (folderPath)
chmod g+rwxs (folderPath)
Anyway that's weird... tell me if this solved your issue, if it didn't I will edit it as long as you provide me further information :)
In my case i have done below actions post that able to start the httpd service without any error.
Error:
# sudo tail -f /etc/httpd/logs/error_log
Sep 27 09:09:19 MASTERREPOWEB systemd[1]: Starting The Apache HTTP Server...
Sep 27 09:09:20 MASTERREPOWEB httpd[33693]: (13)Permission denied: AH00091: httpd: could not open error log file /etc/httpd/logs/error_log.
Sep 27 09:09:20 MASTERREPOWEB httpd[33693]: AH00015: Unable to open logs
Sep 27 09:09:20 MASTERREPOWEB systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
Solution:
ls -lZ /etc/httpd/logs/error_log
sudo chcon -Rv system_u:object_r:httpd_log_t:s0 /etc/httpd/logs/
sudo systemctl restart httpd
sudo systemctl status httpd
In CentOS 7
Try disabling SElinux and then reboot then
systemctl restart httpd
Note: never leave SElinux disabled. If the problem is solved then enable(enforce) it and then enable httpd in SElinux
https://www.serverlab.ca/tutorials/linux/web-servers-linux/configuring-selinux-policies-for-apache-web-servers/
If you are on RedHat/Fedora/CentOS/RockyLinux then try to execute the following command (14:00 is your time since the error happened):
journalctl -t setroubleshoot --since=14:00
You could see the following errors:
Jun 25 14:21:33 fedora setroubleshoot[1609]: SELinux is preventing httpd from open access on the file /var/log/gitea/error_log. For complete SELinux messages run: sealert -l 5e2bf467-e935-4fa7-a7fd-d0f7f257828e
Jun 25 14:21:33 fedora setroubleshoot[1609]: SELinux is preventing httpd from open access on the file /var/log/gitea/error_log.
***** Plugin catchall (100. confidence) suggests **************************
If you believe that httpd should be allowed open access on the error_log file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'httpd' --raw | audit2allow -M my-httpd
# semodule -X 300 -i my-httpd.pp
It means the lack of permissions is not related to chmod, but rather to SELinux.
In order to fix the issue you need to execute the following command (please adjust the log directory accordinly):
semanage fcontext -a -t httpd_sys_rw_content_t '/var/log/gitea(/.*)?'
restorecon -Rv '/var/log/gitea/'
systemctl restart httpd
The error should disappear. And please never switch off the SELinux permanently (as someone might suggest) because your server could be compromised.
Just run it as super user:
service httpd start
Starting httpd: (13)Permission denied: httpd: could not open error log file /etc/httpd/logs/error_log.
Unable to open logs [FAILED]
sudo service httpd start
Starting httpd: [ OK ]

OSX: Failed to listen on localhost:80 (reason: Permission denied)

I have downloaded PhpStorm and set all the required configuration. When I try to run the project on port 80, I get this error.
Failed to listen on localhost:80 (reason: Permission denied)
And when I try to use any other ports like 8080 ,I get this error.
Failed to listen on localhost:8080 (reason: Address already in use)
I have tried several different random ports. But I get this already in use error all the time.
I have xampp installed. And when I try to run the url in browser with port , it works fine. The problem is that it isn't working on PhpStorm.
I am stuck.
The errors description are very clear:
The error:
Failed to listen on localhost:80 (reason: Permission denied)
You really don't have permission to use this port; so you need to change your user or use sudo to run your application.
and the error:
Failed to listen on localhost:8080 (reason: Address already in use)
The address that you are trying to use localhost:8080 is already in use by other processes/software.
Normally, if you change the port will solve the problem: (eg. 9090).
But, if you want to know which program is using the port 80 in Unix (Mac OSX, Linux), you can use the lsof command:
To do this:
In the terminal, you need to use:
sudo lsof -i :80
That will result something like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 82 root 4u IPv6 0x763617bed21ecc33 0t0 TCP *:http (LISTEN)
httpd 226 _www 4u IPv6 0x763617bed21ecc33 0t0 TCP *:http (LISTEN)
On this result, we can see that the /usr/sbin/httpd is listening on port 80 on my machine, which is the Apache server.
To know the details of the process that is listening on port 80 you can use the ps command:
ps u PID_of_target_process
that will return a result similar to this:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 82 0.0 0.0 2463324 4248 ?? Ss 9:48AM 0:00.93 /usr/sbin/httpd -D FOREGROUND
To kill the process by the PID you can use the kill command, like the following:
sudo kill -KILL PID_of_target_process
After you kill the process the port will be available again.
The PHPStorm / Intellij built-in web server listens on port 63342 by default.
https://confluence.jetbrains.com/display/PhpStorm/Using+the+Built-in+Webserver+in+PhpStorm
You can set the port in the Run/Debug Configurations under PHP Built-in Web Server:
Stop your Apache server from XAMPP.
Run your PHPStorm with ROOT privileges.
If running PHPStorm is showing your the same error saying Failed to listen on localhost:8080 (reason: Address already in use). The ports 80 is used by any other application. Try checking your used ports with a free tools out there. Stop the process using port 80 and try running the phpstorm.
Xampp for Mac
if you find you cannot get apache to run and you have
no apache web server already running!
......in terminal type.....
sudo apachectl stop
......then run......
sudo /Applications/XAMPP/xamppfiles/bin/apachectl start
.....if you have a port not specified you need to go into
applications/xampp/xamppfiles/etc/httpd.conf and on line 52 or 53
you have a ip or localhost you can set.
adding a port number
add :port number example 192.168.64.2:80 or localhost:80
save and run sudo /Applications/XAMPP/xamppfiles/bin/apachectl start }}}}}}}}}}}}}

Apache 2 error and phpmyadmin not working after installation on Ubuntu 14.04

I installed PHPMyAdmin via apt-get on my Ubuntu and I set the directory in apache2.conf, but when starting the server, nothing happens when http://127.0.0.1/phpmyadmin access and the following message appears I my console:
juninho-desktop:~$ /etc/init.d/apache2 restart
* Restarting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
[fail]
* The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
This is my /etc/apache2/apache2.conf file:
http://pastebin.com/yafW00S6
you could type:
netstat -lnptu
in your terminal. Then look for a programm that is blocking the Port 80.
This programm needs to be closed or must use another port :)
Permission problems, try to restart apache2 using root priviliges:
sudo /etc/init.d/apache2 restart

PHP Redis Error: Uncaught exception ‘RedisException’

I use Redis to build a IOS SNS App (for restful api). As more user use it, errors happened.
It throws out :
Uncaught exception 'RedisException' with message 'read error on connection'
in /data1/www/htdocs/11/iossns/Model/Core/Redis.php
I don't know how to solve the problem.
Can you help?
Thank you!
What PHP-to-Redis library are you using? Here’s the official list from Redis. What is your webserver? (Apache, nginx, etc) How is PHP running? (CGI, FPM, mod_php, etc)
Here’s a thread for the same exception message in phpredis. It turns out phpredis does not currently support persistent connections with php-fpm. Version 2.2.3 of phpredis has some connection handling changes that might decrease the frequency of your issues.
I recommend checking your Redis connector configuration to…
disable persistent connections
enable connection retries
increase log verbosity
You might also consider adjustments to (generally increasing) default_socket_timeout in php.ini.
It's a redis 6 bug.
You can do this:
sudo nano /etc/systemd/system/redis.service
# ADD THIS TO [Service] SECTION
ExecStartPost=/bin/sh -c "echo $MAINPID > /var/run/redis/redis.pid"
sudo systemctl daemon-reload && sudo systemctl restart redis-server
In my case in Ubuntu 20.04 I discovered systemctl was trying to restart service because it couldn't find the /run/redis/redis-server.pid
redis-server.service: Failed with result 'timeout'.
Feb 25 17:51:09 artamredis systemd[1]: Failed to start Advanced key-value store.
Feb 25 17:51:09 artamredis systemd[1]: redis-server.service: Scheduled restart job, restart counter is at 18.
Feb 25 17:51:09 artamredis systemd[1]: Stopped Advanced key-value store.
Feb 25 17:51:09 artamredis systemd[1]: Starting Advanced key-value store...
Feb 25 17:51:09 artamredis systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid (yet?) after start: Operation not permitted
In order to solve it in /etc/redis/redis.conf file find
pidfile /var/run/redis_6379.pid
and change to
pidfile /run/redis/redis-server.pid

Categories