can't execute php files after changing default directory - php

I'm new to LAMP and running into some troubles trying to install it on Ubuntu 14.04. I changed the DocumentRoot in 000-default.conf to a new folder instead of var/www and now it can't execute .php files.
Below is my etc/apache2/sites-enabled/000-default.conf file:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot "full path to folder"
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here is the error I get from /var/log/apache2/error.log
[Fri Oct 17 16:43:19.787413 2014] [core:notice] [pid 2433] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 17 16:54:55.754101 2014] [mpm_prefork:notice] [pid 2433] AH00169: caught SIGTERM, shutting down
[Fri Oct 17 16:54:56.851627 2014] [mpm_prefork:notice] [pid 2943] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 configured -- resuming normal operations

Related

Apache 2.4 PHP-FPM TCP configuration yields 503 Service Unavailable and permission denied: AH00957: FCGI: attempt to connect

I have the following configuration in my /etc/opt/remi/php80/php-fpm.d/www.conf file:
[www]
user = apache
group = apache
listen = 127.0.0.1:9040
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660
listen.acl_users = apache
listen.allowed_clients = 127.0.0.1
And the following virtual host in my site configuration for apache:
<VirtualHost *:80>
ServerAdmin admin#site2.sysadmin-uat.co.uk
ServerName site2.sysadmin-uat.co.uk
DocumentRoot /var/www/site2.sysadmin-uat.co.uk
DirectoryIndex info.php
ErrorLog /var/log/httpd/site2.sadmin-uat.co.uk-error.log
CustomLog /var/log/httpd/site2.sysadmin-uat.co.uk-access.log combined
# <IfModule mod_proxy.c>
# ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9040/
# </IfModule>
<IfModule !mod_php8.c>
<FilesMatch \.(php|phar)$>
# SetHandler "proxy:unix:/var/opt/remi/php80/run/php-fpm/www.sock|fcgi://localhost"
SetHandler "proxy:fcgi://127.0.0.1:9040"
</FilesMatch>
</IfModule>
</VirtualHost>
This is yielding 503 Service Unavailable page and the following errors:
[Fri Nov 04 18:00:01.058776 2022] [proxy:error] [pid 10881:tid
139625418974976] (13)Permission denied: AH00957: FCGI: attempt to
connect to 127.0.0.1:9040 (*) failed [Fri Nov 04 18:00:01.058815 2022]
[proxy_fcgi:error] [pid 10881:tid 139625418974976] [client
10.0.2.2:57066] AH01079: failed to make connection to backend: 127.0.0.1
Any idea what it may be?
Switching to Unix socket works as expected.
SetHandler "proxy:unix:/var/opt/remi/php80/run/php-fpm/www.sock|fcgi://localhost"

Trouble configuring custom folder for site (Apache)

I'm trying to configure httpd on fedora, but my two day effort has gotten me nowhere.
I installed httpd and php, added the configuration file for the site, everything is fine. I try to load it and see "access denied." but I have already granted to the apache user and apache group 755 rights (on every folder along the path).
Errors in apache log:
[Mon Jun 06 20:25:18.088420 2022] [negotiation:error] [pid 12656:tid
12758] (13)Permission denied: [client 127.0.0.1:45920] AH00686: cannot
read directory for multi: /home/concasse_master/Desktop/sample/public/
[Mon Jun 06 20:25:18.089421 2022] [proxy_fcgi:error] [pid 12656:tid
12758] [client 127.0.0.1:45920] AH01071: Got error 'Unable to open
primary script: /home/concasse_master/Desktop/sample/public/index.php
(Permission denied)'
localhost.conf:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot /home/concasse_master/Desktop/sample/public
ErrorLog logs/error.log
CustomLog logs/access.log combined
<Directory /home/concasse_master/Desktop/sample/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Http-status-code 401 Errors not logged in Apache error logs

I am setting up Fail2ban on our server. The apache.auth jail fails as unauthorized requests are not being logged in Apache logs. I have changed the log levels, set separate access and error logs for SSL, but to no avail. Only Http 403 are getting logged in error logs. what should I do so that I can see more error details like 401 in logs.
Tried changing the log levels and
configured separate log files for ssl and normal apache logs
default-ssl in Sites- (Enabled, Available)
ErrorLog ${APACHE_LOG_DIR}/ssl_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel error
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
#Alias /doc/ "/usr/share/doc/"
#<Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
#</Directory>
When I try to reach a forbidden page. Other than this, no errors logged in error log.
[Thu Sep 12 15:00:53.276750 2019] [core:crit] [pid 50926] (13)Permission denied: [client 172.16.0.44:57549] AH00529: /var/www/html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/html/' is executable
[Thu Sep 12 15:02:17.713433 2019] [core:crit] [pid 50924] (13)Permission denied: [client 172.16.0.44:57569] AH00529: /var/www/html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/html/' is executable

apache is crashing not working for a php framework

ServerAdmin webmaster#localhost
DocumentRoot /home/sachin/neuu-dashboard/Telemetry_Backend/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/sachin/neuu-dashboard/Telemetry_Backend/www>
Options FollowSymLinks
AllowOverride All
#Order deny,allow
#Allow from all
Require all granted
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
my apache is keep on crashing when am setting up a php framework
apache is working fine when it is pointing to a default var/www/html
after changing the path it asked enmod and rewrite that also i did but still it is crashing
as soon as i restarted on the very 1st request it crashed
the error code is below from error.log
[Sun Dec 09 13:04:31.953572 2018] [mpm_prefork:notice] [pid 24209] AH00169: caught SIGTERM, shutting down
[Sun Dec 09 13:04:32.048381 2018] [mpm_prefork:notice] [pid 24328] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Dec 09 13:04:32.048453 2018] [core:notice] [pid 24328] AH00094: Command line: '/usr/sbin/apache2'
help me out to set up the php framework

PHP not running on VirtualHost after upgrading to OS X Yosemite

Upgraded to OS X Yosemite and now my virtualhosts are spitting out the PHP file contents instead of executing the file.
This works correctly:
http://localhost
This spits out the file contents onto the screen:
http://localhost/~MYUSERNAME
<?php phpinfo();
http://testing.dev spits out the
<?php and the contents of this file (which is WordPress)
apachectl -t
Syntax OK
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName testing.dev
ServerAlias www.testing.dev
DocumentRoot "/Users/*/Sites/testing"
ErrorLog "/private/var/log/apache2/testing.dev-error_log"
<Directory "/Users/*/Sites/testing-env/">
Options Indexes FollowSymLinks
AllowOverride AlL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 testing.dev
Why is it spitting out the PHP file instead of executing it?
running php -v gives me
PHP 5.5.3 (cli) (built: Aug 28 2013 13:28:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans
error log shows:
[Mon Nov 17 17:30:08.338143 2014] [auth_digest:notice] [pid 3633] AH01757: generating secret for digest authentication ...
[Mon Nov 17 17:30:08.339341 2014] [mpm_prefork:notice] [pid 3633] AH00163: Apache/2.4.9 (Unix) PHP/5.5.14 configured -- resuming normal operations
[Mon Nov 17 17:30:08.339391 2014] [core:notice] [pid 3633] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
Upgrading OS X restores the Apache configuration files to their defaults. You’ll need to edit them again. From memory, this includes:
un-commenting the PHP handler so Apache executes files rather than serving them
Setting AllowOverride to All for your web root directory
un-commenting the line that loads the VirtualHosts configuration file
I had the same issue and found there was a missing configuration section in my httpd.conf. After adding the following and restarting Apache PHP files were processed correctly.
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>

Categories