Getting following error while stopping apache - php

Stopping XAMPP for Linux 1.8.3-3...
XAMPP: Stopping Apache...fail.
apachectl returned 1.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
fail.
kill returned 1
i am getting the above error while stopping the apache please help me and i am using ubuntu

I had the exact same issue. Since you are getting an error stopping Apache and ProFTP only, you need to delete these two files:
/opt/lampp/logs/httpd.pid
and
/opt/lampp/var/proftpd.pid
When you delete the httpd.pid, Apache is automatically killed. And similar happens when you remove the proftpd.pid.
So now you can go ahead and restart the server and new fresh files will be created. :)

Delete the following files:
$XAMPP_ROOT/logs/httpd.pid
$XAMPP_ROOT/var/mysql/$(hostname).pid
$XAMPP_ROOT/var/proftpd.pid

When runningsudo /opt/lampp/lampp stop I get
Stopping XAMPP for Linux 5.6.30-1…
XAMPP: Stopping Apache…fail.
apachectl returned 1.
XAMPP: Stopping MySQL…ok.
XAMPP: Stopping ProFTPD…ok.
And when I open my browser localhost it’s not working
My solution it’s work for me.
run :
sudo rm -f /opt/lampp/logs/httpd.pid
Now restart xampp. You should not face this problem again.

Looks like the script is trying to stop the ProFTPD service but it is not running. The line:
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Indicates that a kill command was issued with malformed or missing parameters. If you are not using ProFTPD, you can remove all instances of it in the startup and termination scripts.
The script that you are running is not only trying to stop the apache service but rather all the services that are related to XAMPP -
X is the platform - could be windows, linux or mac
A​pache
M​ySql
P​hpMyAdmin
P​hp

Related

Start process in bash script after other process has started up

I'm trying to create a bash script that starts two processes: PHP-FPM and Nginx.
First PHP-FPM should start and once that has finished starting up (port 9000 will then be reachable for example, but there might be other means of checking it has finished starting up) the Nginx server should be started.
My current script looks like this:
#!/usr/bin/env bash
set -e
php-fpm -F &
nginx &
wait -n
But sometimes early on nginx will give me a 502 gateway error because php-fpm is not ready yet.
What's the cleanest/best way of getting this startup in order?
Regards,
Kees.
You can modify your script in this way:
#!/usr/bin/env bash
set -e
php-fpm -F && nginx
wait -n
As you can see in this answer on Unix&Linux, the && operator allows you to run the second command only if the first exited successfully.

Artisan Error: Failed to listen on localhost:8000

I'm having a problem starting my Laravel installation. Whenever I type in the terminal php artisan serve, I get this error:
Failed to listen on localhost:8000 (reason:une tentative d'access un
α socket de maniere interdite par ses autorisation d'access a 0t0
tent0e)
What's the problem, and how can it be fixed?
img problem http://i.imgur.com/rOt3Lat.png
it's working now I just changed the listen port from 8000 to 8888 or any other port your services didn't use it
php artisan serve --port="8888"
Fixing Error: Failed to listen on localhost:8000 (reason: Address already in use)
List processes with php in it
ps -ef | grep php
Example output
501 **9347** 393 0 1:29PM ttys000 0:00.21 php artisan serve
501 9351 **9347** 0 1:29PM ttys000 0:02.01 /usr/local/php5-5.6.14-20151002-085853/bin/php -S localhost:8000 .../laravel/server.php
501 9781 393 0 1:56PM ttys000 0:00.00 grep php
Then kill the process
kill -9 9347
Are there any other services running on port 8000?
You can use this command on Windows:
netstat -aon | more
or on Linux / OSX
sudo netstat -plnt
to see what services are running. Then disable the service that is running on port 8000 or use another port.
List process using ps -ef | grep php
Then below only works for me
kill -9 9347
which is a force kill of the process
501 9347 393 0 1:29PM ttys000 0:00.21 php artisan serve
Option 2:
If above not works, Change the default laravel serve port number if you can, like
php artisan serve --port=8088
8000 is the default port. Use instead of :
php artisan serve --port=8005
It is because something already running on that port and you can change the port by command itself, by running following command
php artisan serve --port 8001
Use killall -9 php and if you want to close other services use killall -9 node or killall -9 mysql
When php artisan serve command given, below mentioned problem occured.
macridmi1109#Ridmis-MacBook-Pro kcnk % php artisan serve
Laravel development server started on http://localhost:8000/
[Thu Aug 6 11:31:10 2020] Failed to listen on localhost:8000 (reason: Address already in use)
Then try this line of code,
macridmi1109#Ridmis-MacBook-Pro project_laravel % ps -ef | grep php
Result will be,
501 66167 1 0 11:24am ttys002 0:00.77 /usr/bin/php -S localhost:8000
/Users/macridmi1109/Documents/Laravel/project_laravel/server.php
501 66268 64261 0 11:31am ttys002 0:00.00 grep php
Finally run the below code and, then again php artisan serve
macridmi1109#Ridmis-MacBook-Pro project_laravel % kill 66167
SOLUTION EXPLAINED BELOW
I use the command, ps -ef | grep php. After that, you will be able to find Process ID. After recognising the correct Process ID, use this command kill 66167 (kill "Process ID"). Then try php artisan serve. This worked for me.
Happy Coding😊
For me, it was silly mistake. I have installed php in new machine but php.ini was missing. So, I have created php.ini file from php.ini-production file and then php artisan serve command worked fine as expected.
for me php -S localhost:8080 from the terminal in vs code will sometimes crash, but still be running in the background.
-9 to force kill did it for me
thanks #hemss
I did
php -S localhost:8080
[Wed Dec 12 13:48:03 2018] Failed to listen on localhost:8080(reason: Address already in use)
then I..
sudo netstat -plnt
find the process running on port 8080
tcp 2 0 127.0.0.1:8080 0.0.0.0:* LISTEN 10312/php
then force kill it..
kill -9 10312
I get
[1] + 10312 killed php -S localhost:8080
then restart...
php -S localhost:8080
best way if you 8000 port is busy or you have more one project running is run your project in new port such as 8088 or another free port.
php artisan serve --port=8088
The solution I found a problem we face several times in Ubuntu.
*Failed to listen on 127.0.0.1:8000 (reason: Address already in use)*
What we do, we change the port, right?
This problem can be solved also in few seconds following below steps.
1. Open Terminal
2. **sudo su**
3. **netstat -plnt**
_find the process running on port 8080_
4. **kill -9 PROCESSNUMBER**
For more details, see my blog, click here
If you have all your configurations ok in the .env file then you should:
Use the answer from mayorsanmayor in this post to kill all php processes.
Then php artisan config:clear
Finally, php artisan serve
Good luck!

Stopping in-built php server on Mac Mavericks - Livecode

I'm developing something in Livecode and I have been experimenting with using Mavericks own in-built php server. I started the server by sending the following command through shell...
php -S localhost:8000
This enabled PHP to run successfully through localhost:8000/
However, I can not work out how to stop/disable PHP now in order to continue testing starting it - when I previously started PHP through the terminal I was able to do ctrl+c to stop php running but since I do not yet know how to do this through my app I get this error instead...
Failed to listen on localhost:8000 (reason: Address already in use)
Anybody know how I can stop it either via the terminal or through my Livecode app? Attempts to stop it through the terminal using just ctrl+c do not work
open a terminal and type:
ps -ef | grep php
it will list the php process with the pid (process id)
something like
$ ps -ef | grep php
501 14263 14133 0 10:25AM ttys001 0:00.21 php -S localhost:8000
501 14355 14265 0 10:25AM ttys002 0:00.00 grep php
The note the number for the line that lists your php process, the second column is your pid
in the example the process id us 14263, kill it:
$ kill 14263
do another ps
$ ps -ef | grep php
501 14358 14265 0 10:26AM ttys002 0:00.00 grep php
$
The process should not be listed anymore

How do you setup MONIT to monitor php5-fpm?

One of the solutions I found is this:
check process php5-fpm with pidfile /var/run/php5-fpm.pid
group php
start program = "/etc/init.d/php5-fpm start"
stop program = "/etc/init.d/php5-fpm stop"
if failed unixsocket /tmp/php-fpm.sock then restart
if 4 restarts within 5 cycles then timeout
depends on nginx
This does not work because the following file does not exist in my system:
/tmp/php-fpm.sock
When I run sudo find / -name *.sock I get:
/run/mysqld/mysqld.sock
/run/fail2ban/fail2ban.sock
/var/lib/php5-fpm/web2.sock
/var/lib/php5-fpm/ispconfig.sock
/var/lib/php5-fpm/apps.sock
If it helps, this is the file I change to configure how php behaves with the particular domain I use : /etc/php5/fpm/pool.d/web2.conf. So MAYBE the right file is `/var/lib/php5-fpm/web2.sock ?
This is a VPS with ubuntu 12.04 and nginx 1.4.4.

Problem with DKIM socket

I have a problem with dkim-milter.
My maillog file is filled with logs
Dec 5 23:59:59 NS1 dkim-filter[31424]: Sendmail DKIM Filter: Unable to bind to port inet:20209#localhost: Address already in use
Dec 5 23:59:59 NS1 dkim-filter[31424]: Sendmail DKIM Filter: Unable to create listening socket on conn inet:20209#localhost
Dec 5 23:59:59 NS1 dkim-filter[31424]: smfi_opensocket() failed
I suspect that the problem is related to Dkim-filter.conf and line:
Socket inet:20209#localhost
It looks like something is allready runing on that port so I can't bind it again.
How can I change this and make DKIM running without errors?
As a note, I found that when I manually stopped and restarted the dkim-milter service, my logs filled up with that message. This was due to the config option "AutoRestart" which defaults to Yes"
With that option on, when the service is stopped using "service dkim-milter stop", it automatically restarts, and when my shell script then ran "service dkim-milter start" a few seconds later, it was duplicating the process and was unable to connect to the port as it was already running.
I am not really experienced enough to know the best was to fix it, but the problem above was tested and repeatable.
In my case, I was running the wrong command. Instead of running
sudo opendkim -x /etc/opendkim.conf -p inet:8891#localhost
I was running:
sudo opendkim -x /etc/opendkim.conf -p init:8891#localhost
Not sure how common this is, but it sure took me a while to track down.
port 20209 is already in use, maybe an old zombie dkim-milter?
netstat -nlp | grep 20209 will help you find out whats blocking the port
I had the same problem so with the help of a friend I followed the steps below:
Show 25 more recent errors from logs (/path/to/file): tail -n 25 /var/log/maillog
Listen to specific port (20209) to see what's blocking it: netstat -nlp | grep 20209
Check status of a service (dkim-milter in this case): service dkim-milter status
Show all proccesses with "filter" in name, because dkim-milter is
running as dkim-filter: ps ax | grep filter
Kill process with pid f.e. 32731: kill 32731
Now the process which produced the errors isn't running.
This is how to restart to dkim-milter and postfix:
service dkim-milter stop
service dkim-milter start
service postfix restart
And everything seemed to work ok now

Categories