I'm trying to set up the /status page of php-fpm on apache, but i'm getting a 404 error and i can't know why. I'm not expert at neither Apache2 or php, and i been struggling with this a couple days, so i'm here for some help.
This is my apache2.conf settings. And i also have another site hosted on apache with a Directory config:
<LocationMatch "/fpm-status">
Order Allow,Deny
Allow from 127.0.0.1
ProxyPass unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/fpm-status
</LocationMatch>
This is my php5.6 settings
listen = /run/php/php5.6-fpm.sock
listen.backlog = 65535
user = www-data
group = www-data
pm.status_path = /fpm_status
When i try to curl over http://localhost/fpm-status this message appears:
File not found.
On apache2 logs this appears when i try to acces that path:
AH01071: Got error 'Primary script unknown\n'
Check this: https://gist.github.com/Jiab77/a9428050ab9bb3f17c5e33343da94fd8
Seems you may be missing an Alias.
I solved it, I made multiple changes and then it worked, i don't know what certainly was, so i listed them.
Changed "fcgi://localhost/fpm-status" to "fcgi://localhost/"
Changed "pm.status_path = /fpm_status" to "pm.status_path = /status"
service apache2 restart
service php5.6-fpm restart
Then curl to http://localhost/status and worked as expected
Related
I'm trying to set a local environment variable to test my PHP app on a windows machine. I added SetEnv API_HOST /foo/bin in the file C:\Apache24\conf\httpd.conf and restarted the server by executing httpd -k restart at the command line.
In my app I check the variable $_SERVER['API_HOST'] and I always get null and it isn't null in the development server since the environment variable is set there.
I also tried to create confs files, set the env variable and include the files in the httpd.conf, but also doesn't work.
I was expecting this to be straight forward, but it seems something is missing. Any idea why it isn't working?
Thanks.
Sorry, forgot to answer earlier. It started working with the following in the httpd.conf:
<VirtualHost *:80>
DocumentRoot "path/to/project-root"
ServerName localhost
SetEnv API_HOST /foo/bin
</VirtualHost>
And restart the apache server by going to the path C:\Apache24\bin on the cmd and execute httpd -k stop and httpd -k start. I tried httpd -k restart several times before and didn't work, don't know why.
Cheers
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
I have tried many php files like huge file, small file but any of them is not working it will load and shows 504 gateway error
I tried test.php file with one line of code it is also showing the same error
<?php echo"Hi working fine"; ?>
I think you have updated php execution time in php config but what about Nginx config?
Try updating your Nginx Config :
Step 1 : Updates for your website test.com
vim /etc/nginx/sites-available/test.com
Step 2 : Updating Execution Time
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 300;
}
Step 3 : Don't forget to reload to reflect changes
service php5-fpm reload
service nginx reload
Hope this helps.
I'd check in the following order:
1) If php5-fpm is running:
sudo service php5-fpm status
if it returns the process number - try telneting it:
telnet 127.0.0.1 9000
2) If telnet returns connected status - I'd start checking the /etc/nginx/sites-enabled if the config of your site is there. If it's there - check that the stuff is set up correspondingly...one of the examples of how to set up nginx with php-fpm is here:
https://www.howtoforge.com/installing-nginx-with-php5-fpm-and-mysql-on-ubuntu-14.04-lts-lemp
3) If that is ok - reload the php5-fpm and nginx and check if permissions in your site dir (typically something like /var/www/html/site.com) are set right for user www-data (the default nginx user).
If that is ok - then I can't think of anything more without seeing configs and having fingertips on machine terminal.
Hopefully this helps a bit.
Had this problem on Ubuntu 16.04 with Apache and PHP 7.0. Tried a dozen solutions, which still gave me errors, and then found https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-04/ which worked for me. With PHP 7.0 and Apache 2 installed, and as superuser:
apt install libapache2-mod-fastcgi php7.0-fpm
a2enmod actions fastcgi alias
Restart Apache.
And then add the following to a copy of /etc/apache2/sites-available/000-default.conf as a child of <VirtualHost>
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
<IfModule mod_fastcgi.c>
SetHandler php7-fcgi.php
Action php7-fcgi /php7-fcgi virtual
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization
</IfModule>
In my case, I used a Sites directory in Home instead of /var/www/ and also had inside :
ServerName localhost
ServerAdmin me#myemail.com
DocumentRoot /home/me/Sites
If using a copy of 000-default.conf make sure to disable it with a2disconf and enable your copy with a2enconf.
In my ubuntu 14.04 OS machine for drupal 7 login not working, may be it is not only login but all post request not working here. For the same filesystem and codebase it works fine in windows 7 machine.
Here is my apache server configuration:
<VirtualHost *:80>
ServerName somedomain.local
DocumentRoot "/home/mycompany/Development/Projects/Drupal/cbb"
<Directory "/home/mycompany/Development/Projects/Drupal/cbb/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
for above configuration when i try to submit data for login it showing..
"NetworkError: 404 Not Found - http://somedomain.local/user".
#UPDATE:
I just find out that login not working only from www.domainname.local/user path but if this login form in homepage sidebar it works fine, for all of drupal sire in ubuntu machine. With this no error message also not display.
I am in trouble for two of my drupal site in Ubuntu machine. Any help will be appreciated.
Check if .htaccess file present in drupal root directory.
Check if you've added your domain to /etc/hosts file
127.0.0.1 domain.name
Domains with 'www' and without it are totally different. Add both to /etc/hosts and to apache's config file to avoid problems.
Clear cache to avoid previous domain name which could be stored in cache.
drush cc all
If you've just added new site to apache's configuration be sure to run:
sudo service apache2 graceful
Your Apache vhost file looks like it has the key components set and I'm assuming that the .htaccess file exists in your document root and hasn't been modified from the Drupal default.
When you click on the login link in the sidebar, does it take you to http://somedomain.local?q=user/login ?
Your #update suggests that even though your Apache environment may be set up for "clean URLs", the feature is not enabled in Drupal at Administer > Configuration > Search and metadata > Clean URLs.
If modifying this compromises your access to Drupal, you can apply/disable this change via Drush (drush vset clean_url 0 --yes) or directly through MySQL (UPDATE variable SET value = 's:1:"0";' WHERE name = 'clean_url';) as per https://www.drupal.org/node/5590.
Also worth mentioning, seeing it on this related question (Very strange Drupal 7 404 behaviour): make sure that Apache modules mod_rewrite and mod_headers are enabled:
sudo a2enmod rewrite
sudo service apache2 restart
I can't seem to configure HHVM and Apache, it keeps giving me a 404 file not found error. My configuration file for the website is saved as www.example.com.conf, it contains:
<VirtualHost *:80>
ServerName website.com
ServerAdmin mail#website.com
DocumentRoot /var/www/website.com/public_html/
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/website.com.com/public_html/$1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Note that I've removed my actual website name, but it's for a subdomain so it's this: subdomain.xyz.com. I've tried looking up how to fix this, but whatever I've tried doesn't seem to work; even the GitHub issues people have posted on the official repository don't seem to work. I also haven't changed the default apache configuration, the only thing I have changed is the root directory of my website which does much up to the directory in the configuration file above.
Any ideas? Thanks.
I know it's been two months already, but maybe it helps someone else (I had a similar issue occur many times when configuring HHVM + Apache2).
Try to enable the vhost if you haven't yet done so. Issue sudo a2ensite www.example.com and reload apache afterwards with sudo service apache2 reload.
If the vhost is ok and you have your browser requests visible in the vhost access log, then it means that it's not Apache2 that's the culprit there.
So if you're still with me and the first two steps didn't help, try the following, although in HHVM 3.7 it shoulnd't be the case anymore (but it might, I just follow the try-and-check method when it comes to configuring HHVM, and it usually works). Open /etc/hhvm/server.ini and append the following line to that file:
hhvm.server.fix_path_info = true
After changing the HHVM's configuration, issue sudo service hhvm restart. Then try to refresh your website. It should be all good.
I had similar issues and back then it was the most common fix on all webservers I configured to work with HHVM. But, after the latest updates, I had to comment that line out of my hhvm server.ini in order for my code to work - I read that they have somehow changed the parameters of the server and this parameter does no good anymore, AFAIK.
I have also tried to put that line in /etc/hhvm/php.ini but as far as I remember, it should go to server.ini because it's a server parameter.
So. Try it and let me know if that helped. If not then please issue the following commands on your webserver and paste the output here, so I can see if you have the necessary modules installed
ls /etc/apache2/mods-available | grep -E 'proxy|alias|fcgi|hhvm'
ls /etc/apache2/mods-enabled | grep -E 'proxy|alias|fcgi|hhvm'
Oh, and please include your full HHVM and Apache2 version output:
hhvm --version
apache2 -v