Failed Opening required error. required once - php

I am getting the following error from my website in the error logs:
[Wed Jul 02 07:13:58 2014] [error] [client **.**.**.**]
PHP Fatal error: require_once(): Failed opening required '/var/zpanel/hostdata/
zadmin/core/public_html/loader.php' (include_path='.:/usr/share/pear:/usr/share/php')
in /var/zpanel/hostdata/zadmin/public_html/cmcatering_co_uk/index.php on line 3
In index.php I have the following:
<?php
$code_base = "/var/zpanel/hostdata/zadmin/core";
require_once($code_base . "/public_html/loader.php");
?>
The loader.php file is in the correct place and so I am a bit confused as to why this is happening. I tried putting the core folder in /usr/share/php but this did not fix the problem. Any suggestions?
edit:
I have also just seen this error:
[Wed Jul 02 07:36:58 2014] [error] [client 94.10.110.115] PHP Warning: require_once(/usr/share/php/core/public_html/loader.php): failed to open stream: Operation not permitted in /var/zpanel/hostdata/zadmin/public_html/cmcatering_co_uk/index.php on line 3
httpd.conf:
# ZPanel Apache Include file for CentOS Linux
# Written by Bobby Allen, 15/05/2011
# Set the Zpanel Alias (used for development, sable will eventually use a VHOST)
Alias /zpanel /etc/zpanel/panel
# Setup the directory settings and PHP security flags for the Zpanel application directory.
<Directory /etc/zpanel/panel>
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_value upload_tmp_dir /etc/zpanel/temp
</IfModule>
</Directory>
# Disallow web access to directories that don't need it/that we don't want people looking in!
<Directory /etc/zpanel/panel/cnf>
Order Deny,Allow
Deny from All
</Directory>
# Set server tokens (security??)
ServerTokens Maj
# Now we include the generic VHOST configuration file that holds all the ZPanel user hosted vhost data
Include /etc/zpanel/configs/apache/httpd-vhosts.conf

if you read the error message then you well see:
Operation not permitted
Your webserver process has no permissions to access
/usr/share/php/core/public_html/
In many cases webservers are bound to their root.
/var/zpanel/hostdata/

It looks as though this is a permissions issue due to the operation not permitted error. Look at whether your server is giving php access to the given folder in its configuration. Also just for a sanity check, echo out the filename as it is passed to your require_once.
Would be helpful if you posted your apache site config.

<?php
$code_base = "/var/zpanel/hostdata/zadmin/core";
require_once("<?php echo $code_base; ?>/public_html/loader.php");
?>

Related

localhost 403 Forbidden PHP

Read almost all questions here, but no solution found. This drives me crazy already to do such simple stuff to run PHP on my localhost...
You don't have permission to access this resource.Server unable to
read htaccess file, denying access to be safe
ls -l
-rwxrwxrwx 1 user user 51 sep 27 14:42 .htaccess
ls -l
drwxrwxr-x 2 user user 4096 sep 27 15:17 www
Any help appreciated!
Check if there is an .htaccess file inside the www folder (and its permissions), since Apache looks for one at every directory up to the one where the requested file exists.
I'm coming from an Apache on Windows server background, but in regards to the .htaccess file, you can also put a "AllowOverride None" in your section of your httpd.conf file. At least in Windows, this means nothing can be overridden, therefore no need to look for .htaccess files.
You can also add a line to tell Apache that the "AccessFileName" is blank. Here are the entried I'm speaking of from my config file. I'm running a XAMPP server on Windows.
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
AccessFileName ""

mautic throws error php error during installation on aws ubuntu

mautic throws amazing error during installation :
The site is currently offline due to encountering an error. If the problem persists, please contact the system administrator.
so i went into server log which shows :
PHP Warning: include(): Failed opening '/var/www/myfolder/var/cache/prod/middlewares.cache.php' for inclusion (include_path='.:/usr/share/php') in /var/www/myfolder/app/middlewares/MiddlewareBuilder.php on line 82PHP message: PHP Warning - Invalid argument supplied for foreach() - in file /var/www/mauticwp/app/middlewares/MiddlewareBuilder.php - at line 84PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/mauticwp/app/middlewares/MiddlewareBuilder.php on line 84PHP message: RuntimeException: Unable to create the "cache" directory (/var/www/myfolder/var/cache/prod). - in file /var/www/myfolder/vendor/symfony/http-kernel/Kernel.php - at line 765'
#NameVirtualHost *:8000
<VirtualHost *:8000>
ServerAdmin webmaster#localhost
ServerName somesubdomain.mydomains.com
ServerAlias www.somesubdomain.mydomains.com
DocumentRoot /var/www/some_directory
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mpm_itk_module>
AssignUserId mauticadmin www-data
</IfModule>
<IfModule mod_fastcgi.c>
AddHandler php7.4-fcgi .php
Action php7.4-fcgi /php7.4-fcgi virtual
Alias /php7.4-fcgi /usr/lib/cgi-bin/php7.4-fcgi-somesubdomain.mydomains.com
FastCgiExternalServer /usr/lib/cgi-bin/php7.4-fcgi-test.com -socket /var/run/php/php7.4-fpm-mautic.ndedges.com.sock -pass-header Authorization
</IfModule>
<Directory /var/www/some_directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<FilesMatch .php$>
# 2.4.10+ can proxy to unix socket
SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
within fpm/pool.d/www.mautic.conf. i added
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
php_admin_flag[allow_url_fopen] = off
as I have multiple PHP in the same server. I have Cloudflare configured within WordPress and redirects to HTTPS. but i am unable to use ip and port to use it.
I am completely clueless about what could be the reason.
thx
Most of the time it is Cache and Permission related Issue, In my opinion It has nothing to do with Apache configuration.
Use ps aux to identify which user owns the apache process,
Mostly it is www-data,
Make sure to chown on all directories and sub directories to change ownership to www-data.
Make sure files and directories have proper permissions for www-data, Mautic needs write access to Media, var/cache and var/logs directories.
https://tutorialsjoint.com/install-mautic/ in this tutorial checkout the section "Setting rights and permissions for Mautic Installation".
It'll work the same weather it is nginx or apache as this problem seems to be linux related only.
i also find some error
[mpm_prefork:notice] [pid 1440453] AH00163: Apache/2.4.41 (Ubuntu) mod_fcgid/2.3.9 mpm-itk/2.4.7-04 OpenSSL/1.1.1f configured -- resuming normal operations
<FilesMatch ".php$"> # Apache 2.4.10+ can proxy to unix socket
SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost/"
this one did the job. i removed that fpm configuration but it works like a charm. actually, the same settings did not work for him but it worked for me.
ref: https://askubuntu.com/questions/1317077/apache-sethandler-not-working-with-multiple-php-version
maybe due to the apache2 version. but it has a different problem now i can access it through elastic ip and non SSL port but not with the A record.
now mautic is set with SES but i need to set a bounce endpoint with sns topic. and set a cronjob as www-data.
I was able to access with the IP not using the SSL of Cloudflare proxied A record because it doesn't support other than these ports to trust support.cloudflare.com/hc/en-us/articles/… Cloudflare only accept these ports nothing else. After changing those it was immediately turned into grey and secured. –
https://community.cloudflare.com/t/subdomains-are-not-getting-redirected-to-themselves/279745

Server Error 500 Centos

Hi i have a Centos 6 64 bit
it has LAMP installed html works php doesnt work
when i try opening a php gamepanel on : http://51.255.199.40/gpanel/ , i get Server Error 500, and in the error_log of apache i get:
[Sat Mar 05 14:45:58 2016] [error] [client 46.99.49.96] Directory index forbidden by Options directive: /var/www/html/
Here is my httpd.conf my php.conf and a file named welcome.conf , php and welcome.conf are in conf.d folder and httpd.conf is in the conf folder:
http://pastebin.com/xSzPrMmi
Im not that good on coding i need help getting this fixed im since 5 days with this problem and still no fix
my email address is : benjaminselmani5#gmail.com if you guys need to contact me i will watch the topic too.
With Respect
Benjamin Selmani
Change AllowOverride None to AllowOverride All inside httpd.conf's block
<Directory "/var/www/html">
AllowOverride All
</Directory>

.htaccess - Restrict allowed file types within subdirectory

Context
I'm trying to create a white list of file types and disable directory listing on a directory named upload by using .htaccess. For security reasons, I do not want to place the .htaccess file within the upload directory. Instead it will be placed one level up in the file hierarchy.
Issue
I'm getting a 500 HTTP response on the entire website.
Contents of .htaccess
<Directory upload>
Options -Indexes
deny from all
<Files ~ “^w+.(gif|jpe?g|png)$”>
order deny,allow
allow from all
</Files>
</Directory>
UPDATE: Here's the apache error log
Error log
[Sun Feb 14 19:31:52 2016] [alert] [client ::1] /Applications/MAMP/htdocs/bombeiros/.htaccess: <Directory not allowed here

On AWS EC2 Linux RHEL all PHP files are executing, except for index.php

I am lost on this one.
I have setup an AWC EC2 RHEL server, and installed php and apache. Everything seems to work except for the fact that the index.php file will not execute. All other *.php files will work if I call them directly.
index.php contains:
<?php echo "test"; ?>
in /etc/httpd/conf/httpd.conf I have the settings:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Although if I remove the index.php still does not work.
I have the permissions on index.php as -rw-r--r-- ec2-user ec2-user
I am not sure what other information would be useful here seeing as all other php files work except for the index.php. (eg: if I call /index.php outputs nothing, if I move index.php to index2.php and call /index2.php outpus test)
Any thoughts as to why this may be happening?
EDIT
I am now realizing there is a 500 internal server error when the index.php file is called checking the access logs.
"GET /index.php HTTP/1.1" 500
Maybe that will help point in the right direction? I am still unclear how to solve this issue. Again, changing the name of the file to anything other than index.php (eg: index2.php) will execute the file correctly.
Also, after enabling error reporting I am getting this error:
PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
PHP Fatal error: Unknown: Failed opening required '/var/www/html/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
I have tried changing permissions to all sorts of variants including 777, 755, 655, 644, 664, etc... even tried changing owner to apache. no luck.
Try to configure selinux in permissive or disabled mode.
I had the same problem. I was trying to install moodle and failed. I got the same error above.
I configured selinux to permissive to see if this is the root cause and indeed I was able to install.
My problem was that I have opened moodle archive (moodle...tar.gz) as a regular user under his home directory and moved it to apache's DocumentRoot. This got the selinux content field to be wrong.
I have enable selinux and opened the tar.gz archive directly under DocumentRoot (/var/www/html). This gave the right content attribute to the files (httpd_sys_content_t). I was able to run moodle with selinux enabled.
Mosh
AWS EC2 RedHat Web Server inner links are not working.
Solution
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Note that "MultiViews" must be named explicitly --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none
new value should change to AllowOverride all
Permissions needs to be set to read by Apache users. Current permissions doesn't allows it to read the file as Apache User.
Also it would be good to check what error you are getting in Apache Logs, it should be "403 Forbidden" if I am not wrong.

Categories