I recieve a file instead of access PhpMyAdmin page - php

When I installed Php, PhpMyAdmin and Nginx, I recievied this file with these code file instead of access to
http://localhost:80/phpmyadmin
<?php
declare(strict_types=1);
use PhpMyAdmin\Routing;
if (! defined('ROOT_PATH')) {
// phpcs:disable PSR1.Files.SideEffects
define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
// phpcs:enable
}
global $route, $containerBuilder;
require_once ROOT_PATH . 'libraries/common.inc.php';
$dispatcher = Routing::getDispatcher();
Routing::callControllerForRoute($route, $dispatcher, $containerBuilder);
I've done like this
phpmyadmin 404 error in nginx
to fix the 404 error but after that I've received error above.
Sorry for my bad English.

Step 1: you need to check status of nginx server with command line:
sudo service nginx status
If nginx server not active,try to restart nginx server with command line sudo service nginx restart
If you see failed, let's check what program is running on port 80 (let's me know in the comment). The common error is caused by the apache2 server running on port 80 (If this is true, go to the next step).
Step 2: The are two solution for you
1, Stop server apache2 with this commana line:
sudo service apache2 stop
Restart nginx server:
sudo service nginx restart
Check status nginx server again, it's should be ok right now.
2, Change port apache2
You need to change two file /etc/httpd/conf/httpd.conf and /etc/apache2/ports.conf
For example, I change port apache2 from 80 to 8888:
sudo nano /etc/apache2/ports.conf and change Listen 80 to Listen 8888
sudo nano /etc/apache2/ports.conf and change <VirtualHost: *:80> to <VirtualHost: *:8080>
After that, restart the apache2 server and nginx server:
Restart apache2 server: sudo service apache2 restart
Restart nginx server: sudo service nginx restart
Please leave comment if anything you want to ask.

Related

Missing /var/run/php-fpm/php7.4-fpm.sock or /var/run/php-fpm/

Using: Ubuntu 20.04
PHP starts failed because missing /var/run/php-fpm/php7.4-fpm.sock & /var/run/php-fpm/php7.4-fpm.pid.
Heres the details: (feedback from systemctl status php7.4-fpm.service)
● php-fpm7.4[3465899]:ERROR: unable to bind
listening socket for address '/var/run/php-fpm/php7.5-fpm.sock': No such
file or directory (2)
● php-fpm7.4[3465899]:ERROR: unable to bind
listening socket for address '/run/php-fpm/php7.5-fpm.pid': No such
file or directory (2)
I checked "/etc/php/7.4/fpm/pool.d/www.conf", but there is the following code in the file:
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php7.4-fpm.sock
Type in:
cd /run
sudo mkdir php
sudo mkdir php7.4-fpm
cd /etc/php/7.4/fpm/pool.d/
cp www.conf www.conf.backup
vi www.conf
Find following code:
line 36:
listen = /run/php/php7.4-fpm.sock
change it to:
listen = 127.0.0.1:9000
line 133:
listen = /var/run/php-fpm/php7.4-fpm.sock
Remove that line, save that file, and type in:
sudo service php7.4-fpm stop
sudo service php7.4-fpm start
Thanks:
#tkausl
#dai007uk

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)

Could not reliably determine the server's fully qualified domain name for MacBook

First time got a new MBP 2016. Trying to setup PHP,MySQL & Apache. Started Apache by using command
sudo apachectl restart
Then installed PHP by
brew install php71 --with-httpd24
Also did following changes...
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
DirectoryIndex index.html index.php
SetHandler application/x-httpd-php
ServerName dev-server
Also, updated the same in host file /etc/hosts/
But, whenever I'm trying to Stop/Restart my apache by using command sudo apachectl restart or sudo apachectl stop I'm getting following errors.
AH00557: httpd: apr_sockaddr_info_get() failed for Sureshs-MacBook-Pro.local
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
httpd not running, trying to start
But, strangely when I'm executing any PHP file from my browser http://localhost/index.php it's working fine. As in my index.php file I'm using code <?php phpinfo(); ?> It's showing PHP version PHP Version 7.1.4 loaded.
Tried a lot but no clude what's going wrong at where.
---UPDATE---
After updating 127.0.0.1 Sureshs-MacBook-Pro.local in my /private/etc/hosts file, one error solved. Now I'm getting only one below error.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Sureshs-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
Finally, I solved this by updating ServerName localhost:8080 on file /usr/local/etc/apache2/2.4/httpd.conf. It was a differnt httpd.conf file which I didn't knew about it.
Also, for Apache start/restart/stop following command sudo /usr/sbin/apachectl start works for me.
As per message:
Set the 'ServerName' directive globally to suppress this message.
You need to identify httpd.conf Apache configuration file by:
apachectl -t -D DUMP_INCLUDES
then edit it and uncomment the line with ServerName (make sure it has the valid server name). E.g.
ServerName localhost
open file httpd.conf
vi /etc/httpd/conf/httpd.conf
add to first line
ServerName localhost
systemctl restart httpd
I resolved this issue changing the port address in the httpd.conf file in windows.
This problem arises due to the port already listening, which we use in the conf file.
To view the port listening, use the command "netview /a"
if the port used in the conf file already listening, change to different one(e.g, 8080)
set servername to "localhost" or 127.0.0.1
Now start the apache server "httpd.exe -k start"
it will work fine.
On macOS Catalina...
Edit the Apache config file
sudo vi /etc/apache2/httpd.conf
Find the ServerName entry by typing a / followed by ServerName and hit enter
Press n to go to the next occurrence until you are on #ServerName www.example.com:80 (keep pressing n if you go past it)
Add a newline by typing an o
Type the following: ServerName localhost
Save and exit by typing !wq then hit enter (or type ZZ which is capital Z twice)
Restart Apache
sudo apachectl restart

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

nginx 502 bad gateway

I get a 502 Bad Gateway with nginx when using spawn fcgi to spawn php5-cgi.
I use this to span an instance on server start using the following line in rc.local
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid
presumably I'm getting the error because the spawn-fcgi / php5-cgi dies and there is nothing listening there anymore to parse php.
I get nothing in the logs that I can see anywhere, I'm out of ideas (and new to this setup with nginx)
I executed my localhost and the page displayed the 502 bad gateway message. This helped me:
Edit /etc/php5/fpm/pool.d/www.conf
Change listen = /var/run/php5-fpm.sock to listen = 127.0.0.1:9000
Ensure the location is set properly in nginx.conf.
Run sudo service php5-fpm restart
Maybe it will help you.
Source from: http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm
The 502 error appears because nginx cannot hand off to php5-cgi. You can try reconfiguring php5-cgi to use unix sockets as opposed to tcp .. then adjust the server config to point to the socket instead of the tcp ...
ps auxww | grep php5-cgi #-- is the process running?
netstat -an | grep 9000 # is the port open?
Go to /etc/php5/fpm/pool.d/www.conf and if you are using sockets or this line is uncommented
listen = /var/run/php5-fpm.sock
Set couple of other values too:-
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
Don't forget to restart php-fpm and nginx. Make sure you are using the same nginx owner and group name.
You have to match the settings for PHP-FPM and Nginx to communicate over sockets or TCP.
So go to /etc/php5/fpm/pool.d/www.conf and look for this line:
listen = /var/run/php5-fpm.sock
Then go to /etc/nginx/nginx.conf
Look for this:
upstream php {
server unix:/var/run/php5-fpm.socket;
}
Match those values and you should be all set.
If running a linux server, make sure that your IPTABLES configuration is correct.
Execute sudo iptables -L -n , you will recieve a listing of your open ports. If there is not an Iptables Rule to open the port serving the fcgi script you will receive a 502 error. The Iptables Rule which opens the correct port must be listed before any rule which categorically rejects all packets (i.e. a rule of the form "REJECT ALL -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable or similar)
On my configuration, to properly open the port, I had to execute this command (assume my fcgi server is running at port 4567):
sudo iptables -I INPUT 1 -p tcp --dport 4567 -j ACCEPT
WARNING: This will open port 4567 to the whole world.
So it might be better to do something like this:
sudo iptables-save >> backup.iptables
sudo iptables -D INPUT 1 #Delete the previously entered rule
sudo iptables -I INPUT 1 -p tcp --dport 8080 -s localhost -j ACCEPT # Add new rule
Doing this removed the 502 error for me.
change
fastcgi_pass unix:/var/run/php-fpm.sock;
to
fastcgi_pass unix:/var/run/php5-fpm.sock;
When I did sudo /etc/init.d/php-fpm start I got the following error:
Starting php-fpm: [28-Mar-2013 16:18:16] ERROR: [pool www] cannot get uid for user 'apache'
I guess /etc/php-fpm.d/www.conf needs to know the user that the webserver is running as and assumes it's apache when, for nginx, it's actually nginx, and needs to be changed.
You can make nginx ignore client aborts using:
location / {
proxy_ignore_client_abort on;
}
I had the same problem while setting up an Ubuntu server. Turns out I was having the problem due to incorrect permissions on socket file.
If you are having the problem due to a permission problem, you can uncomment the following lines from: /etc/php5/fpm/pool.d/www.conf
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
Alternatively, although I wouldn't recommend, you can give read and write permissions to all groups by using the following command.
sudo chmod go+rw /var/run/php5-fpm.sock
Try disabling the xcache or apc modules. Seems to cause a problem with some versions are saving objects to a session variable.
Hope this tip will save someone else's life. In my case the problem was that I ran out of memory, but only slightly, was hard to think about it. Wasted 3hrs on that. I recommend running:
sudo htop
or
sudo free -m
...along with running problematic requests on the server to see if your memory doesn't run out. And if it does like in my case, you need to create a swap file (unless you already have one).
I have followed this tutorial to create swap file on Ubuntu Server 14.04 and it worked just fine:
http://www.cyberciti.biz/faq/ubuntu-linux-create-add-swap-file/
If you're on Ubuntu, and all of the above has failed you, AppArmor is most likely to blame.
Here is a good guide how to fix it: https://www.digitalocean.com/community/tutorials/how-to-create-an-apparmor-profile-for-nginx-on-ubuntu-14-04
Long story short:
vi /etc/apparmor.d/nginx
Or
sudo aa-complain nginx
sudo service nginx restart
See everything working nicely... then
sudo aa-logprof
I still had problems with Nginx not being able to read error.log, even though it had all the permissions possible, including in Apparomor. I'm guessing it's got something to do with the order of the entries, or some interaction with Passenger or PHP-Fpm... I've run out of time to troubleshoot this and have gone back to Apache for now. (Apache performs much better too FYI.)
AppArmor just lets Nginx do whatever it wants if you just remove the profile:
rm /etc/apparmor.d/nginx
service apparmor reload
Shockingly, but hardly surprising, a lot of posts on fixing Nginx errors resorts to completely disabling SELinux or removing AppArmor. That's a bad idea because you lose protection from a whole lot of software. Just removing the Nginx profile is a better way to troubleshoot your config files. Once you know that the problem isn't in your Nginx config files, you can take the time to create a proper AppArmor profile.
Without an AppArmor profile, especially if you run something like Passenger too, I give your server about a month to get backdoored.
For me the error was in default file of Nginx
located at /etc/nginx/sites-available/default
I noticed the version of php-fpm used was 7.0 and the php version i downloaded was 7.2
I simply changed the version to 7.2 and it worked.
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
Similar setup here and looks like it was just a bug in my code. At the start of my app I looked for the offending URL and this worked: echo '<html>test</html>'; exit();
In my case, turns out the problem was an uninitialized variable that only failed under peculiar circumstances.

Categories