Error AH00124 during Symfony 4 server configuration - symfony

I currently am trying to deploy my Symfony 4 website on a hosted VPS, I did setup everything quite successfully, installed Apache2, PHP 7.2, MySQL server and phpmyadmin.
I then started configuring my server acordingly to host a Symfony 4 website, and before deploying my own application I tried to deploy a smaller one so that I would know that at least some part worked with a no-database no-bundles application.
When I try to access my website nothing happens, the following error log is generated in /var/log/apache2 :
[Wed Jul 11 14:06:08.580654 2018] [core:error] [pid 13404] [client 37.97.69.85:52997] AH00124: Request exceeded the limit of 10 internal redirects due to probable
configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:06:41.901738 2018] [php7:error] [pid 13423] [client 37.97.69.85:44931] PHP Fatal error:
Uncaught Symfony\\Component\\Dotenv\\Exception\\PathException: Unable to read the "/var/www/releases/20180710151554/public/../.env" environment file.
in /var/www/releases/20180710151554/vendor/symfony/dotenv/Dotenv.php:54\nStack trace:\n#0 /var/www/releases/20180710151554/public/index.php(15):
Symfony\\Component\\Dotenv\\Dotenv->load('/var/www/releas...')\n#1 {main}\n thrown in /var/www/releases/20180710151554/vendor/symfony/dotenv/Dotenv.php on line 54
[Wed Jul 11 14:33:33.702774 2018] [core:error] [pid 13442] [client 37.97.69.85:53026] AH00124: Request exceeded the limit of 10 internal redirects
due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:38:07.055940 2018] [core:error] [pid 13642] [client 37.97.69.85:54628] AH00124: Request exceeded the limit of 10 internal redirects
due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jul 11 14:51:50.406171 2018] [php7:error] [pid 13793] [client 37.97.69.85:55651] PHP Fatal error: Uncaught RuntimeException:
APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file. in /var/www/demo/public/index.php:13\nStack trace:\n#0 {main}\n thrown in /var/www/demo/public/index.php on line 13
I believe this comes from the website configuration file looping somewhere, I have seen cases online where the .htaccess and the configuration file were looping but here I do not have an .htaccess file anywhere as I deleted it.
He is my website configuration :
<VirtualHost *:80>
ServerName vps562960.ovh.net
ServerAlias vps562960.ovh.net
DocumentRoot /var/www/releases/20180710151554/public
<Directory /var/www/releases/20180710151554>
AllowOverride None
Require all granted
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeeScript assets
# <Directory /var/www/crvfakeexample.com>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/releases/20180710151554/public/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/vps562960.ovh.net_error.log
CustomLog /var/log/apache2/vps562960.ovh.net_access.log combined
# optionally set the value of the environment variables used in the application
#SetEnv APP_ENV prod
#SetEnv APP_SECRET <app-secret-id>
#SetEnv DATABASE_URL "mysql://db_user:db_pass#host:3306/db_name"
</VirtualHost>
I'm starting to lose hope on deploying that website. Has anyone faced a similar case or do any of you know what I'm doing wrong?
Thanks in advance.

Most probably the problem is that Apache server doesn't set env variables into PHP global array $_SERVER. But symfony tries to find env variables exactly in $_SERVER array. Either update public/index.php and replace all $_SERVER with $_ENV or uncomment SetEnv directives in Apache website conf.

Related

Permission denied on Centos7, Apache, Mod Passenger and Ruby 2.6.3

I never tried working with Cent-OS for hosting my Rails applications. I was using before and now I got a server which is running Cent-OS 7. I installed Apache, Phusion Passenger, RVM, Ruby 2.6.3 and bundle updated the Rails app. Everything was fine up to this.
I added the Virtual-Host and restarted the Apache2 server, I got 403 Forbidden message from the browser.
Also I checked the error_log I got the following errors.
[Tue Feb 11 08:34:14.377938 2020] [core:error] [pid 125490] (13)Permission denied: [client 172.69.78.16:30474] AH00035: access to / denied (filesystem path '/home/santosh/sites') because search permissions are missing on a component of the path
[Tue Feb 11 08:34:14.593925 2020] [core:error] [pid 125490] (13)Permission denied: [client 172.69.78.16:30474] AH00035: access to / denied (filesystem path '/home/santosh/sites') because search permissions are missing on a component of the path
The virtual host:
<VirtualHost *:80>
ServerName domain.com.np
ServerAlias www.domain.com.np
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# ModPagespeed on
# Tell Apache and Passenger where your app's 'public' directory is
DocumentRoot /home/santosh/sites/app/public
PassengerRuby /home/santosh/.rvm/gems/ruby-2.6.3/wrappers/ruby
# Relax Apache security settings
<Directory /home/santosh/sites/app/public>
Allow from all
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
Require all granted
</Directory>
</VirtualHost>
And the permission of the app directory is as:
drwxrwxr-x. 4 santosh santosh 31 May 18 2019 app
I couldn't figure out what I am missing. Please help me.
Have you checked the folder permissions on the server, try running 'ls -l' on your folder.

xModRedirect works differently on apache 2.2 vs. apache 2.4 how to make work on 2.2?

Does anyone know the differences between apache 2.2 mod_rewrite and apache 2.4 rewrite!
I have a web builder app and it works great, but I want to migrate the code from an apache 2.4 server to an apache 2.2 server.
When I do I get a recursive loop on the rewrite rules on the 2.2 server:
Here is the .htaccess code that WORKS on an apache 2.4 server
# Powered by Domainsunder.ca
DirectoryIndex index.php index.cgi index.html
ErrorDocument 401 "Unauthorized"
ErrorDocument 403 "Forbidden"
RewriteEngine On
#### PERSISTENT CONTENT ####
#### PERSISTENT CONTENT END ####
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sitepro/$1 [L,QSA]
#### PERSISTENT CONTENT ####
So when I run it on apache 2.2 it loops infinitely and errors out:
Thu Feb 11 17:04:03 2016] [error] [client x.x.x.x] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.domainsunder.ca/
so I added
RewriteCond %{ENV:REDIRECT_STATUS} 200
on the apache 2.2 .htaccess, but it still has the wrong URL as in http://somedomain.ca/sitepro/mypage instead of http://somedomain.ca/mypage
The error message on the screen NOW is:
The requested URL /sitepro/domain_name_information/ was not found on this server.
The file sitepro/index.php is supposed to render the page and it works on apache 2.4.
The mod_rewrite and .htaccess allow seem to work so this appears to be an apache engine issue.
What do I need to add to make this work?
I also had the same problem trying to get Wordpress to work on this same 2.2 server.
I do not want to run cpanel or recompile apache on this centOS 6.x box .
[SOLVED] The mod_rewrite was working great: the problem was the sub directory's /sitepro/.htaccess was not properly transferred in ftp.

403 Forbidden, Index of / catch 22

I'm having a really rough time on this one and have tried a ton of solutions which have worked for certain people but not for me. Firstly my set up:
Ubuntu 14.04.2
Apache 2.4.7
I'm currently migrating my site to wordpress into the folder structure /var/www/dev which is set up as a virtual host - dev.conf looks like:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
ServerAdmin ubuntu#12.345.678.90
DocumentRoot /var/www/dev
ServerName dev.mysite.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/dev/>
Options -Indexes +FollowSymLinks
AllowOverride All
#Require all granted
Order allow,deny
allow from all
</Directory>
</VirtualHost>
My problem is that when I access my home page in a browser for the first time dev.mysite.com it directs me to a 403 page:
Forbidden
You don't have permission to access / on this server.
I also have an .htaccess file in my root folder that looks like this currently:
DirectoryIndex index.php index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I followed 2 different sets of advice so far - one saying to change my config Option to:
Options +Indexes
However when i navigate to my home page it gives me the physical folder "Index of /" with a list of all my files and folders - which I don't want. So I've left it as
Options -Indexes
Another set of advice said add this to the htaccess file:
DirectoryIndex index.php index.html
I've also checked my folder permissions, all owned by my apache user admin ubuntu:ubuntu and all follow the standard wordpress folder permissions e.g. all folders are 755 all files are 644 (rough rule of thumb).
I've also tried as you can see (commented out above) using the new apache 2.4 standard
Require all granted
instead of
Order allow,deny
allow from all
I'm also restarting the server every time I make a change so nothing silly like that. What am I doing in the above config that's not letting me load my site?
Specifically my homepage goes to 403 Forbidden, any other page e.g. dev.mysite.com/features loads this error message:
User-agent: *
Disallow: /wp-admin/
EDIT:
The above issues only occur when the url is loaded initially - if I refresh the page it loads as it should.
Here's my file ownership structure - perhaps this may provide useful:
-rw-rw-r-- 1 ubuntu ubuntu 350 Sep 26 19:35 .htaccess
-rw-rw-r-- 1 ubuntu ubuntu 4951 Sep 9 13:21 wp-activate.php
drwxrwxr-x 9 ubuntu ubuntu 4096 Sep 9 13:21 wp-admin
-rw-rw-r-- 1 ubuntu ubuntu 271 Sep 9 13:21 wp-blog-header.php
-rw-rw-r-- 1 ubuntu ubuntu 5007 Sep 9 13:21 wp-comments-post.php
-rw-rw-r-- 1 ubuntu ubuntu 3130 Sep 24 10:32 wp-config.php
-rw-rw-r-- 1 ubuntu ubuntu 2764 Sep 16 17:23 wp-config-sample.php
drwxrwxr-x 6 ubuntu ubuntu 4096 Sep 24 10:46 wp-content
-rw-rw-r-- 1 ubuntu ubuntu 3286 Sep 16 17:23 wp-cron.php
drwxrwxr-x 12 ubuntu ubuntu 4096 Sep 9 13:21 wp-includes
-rw-rw-r-- 1 ubuntu ubuntu 2380 Sep 9 13:21 wp-links-opml.php
-rw-rw-r-- 1 ubuntu ubuntu 3123 Sep 9 13:21 wp-load.php
-rw-rw-r-- 1 ubuntu ubuntu 34669 Sep 16 17:23 wp-login.php
-rw-rw-r-- 1 ubuntu ubuntu 8252 Sep 9 13:21 wp-mail.php
-rw-rw-r-- 1 ubuntu ubuntu 11062 Sep 16 17:23 wp-settings.php
-rw-rw-r-- 1 ubuntu ubuntu 25124 Sep 16 17:23 wp-signup.php
-rw-rw-r-- 1 ubuntu ubuntu 4035 Sep 9 13:21 wp-trackback.php
-rw-rw-r-- 1 ubuntu ubuntu 3055 Sep 16 17:23 xmlrpc.php
Forbidden 403 simply means that there is some problem with permissions. When server is trying to access the requested resource then it is being restricted due to permission issues, so those who were advising on modifying Indexes weren't even close because Indexes option is to control the directory listing. Below is excerpt about Indexes option from Apache
If a URL which maps to a directory is requested and there is no
DirectoryIndex (e.g., index.html) in that directory, then
mod_autoindex will return a formatted listing of the directory.
Clearly root cause of your issue is "permissions".
Now, for the solution part - since I don't know your all the content of your .htaccess and dev.conf, so below your be my step by step approach:
Try below code snippet. I am trying to disable your .htaccess files effect and see if that's root cause. If it works then you to review all the content of your .htaccess for possible issue.
<Directory /var/www/dev/>
Options -Indexes +FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
Try below code snippet. Default Apache access for Directory is Allow from All, so I am removing it and let default take effect and no ordering .. Anyways you were also trying same thing ..
<Directory /var/www/dev/>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
On a side note, I would suggest that first try to do chmod 777 for your web app directories and files, because in most cases permission issue is because of UNIX permissions and not Apache permissions.
Followup edit:
For further debugging we will need server error info, can you enable maximum debugging and get the content from error.log and access.log (if HTTPS access then from ssl log). Reference
Also, could you please provide context of DirectoryIndex directive and URL you are using.
All odds are that you have permission issue, may be because of Apache or UNIX.
So, lets first comprehensively rule out UNIX permissions issue, so momentarily try out chmod 777 for your web app resource, if it works we know it is UNIX permission issue and we will see what to do next.
I am getting skeptical about RewriteBase / and RewriteRule . /index.php [L] in your .htaccess file .
Give a try to RewriteBase /var/www/dev or whatever you think could be more relevant but NOT /
Also, try to play around with RewriteRule, so instead try absolute path of index.php, so use RewriteRule . /var/www/dev/<<XYZ>>/index.php
Give a try using exact below, if you don't have mod_cgi module included then you may need to.
<Directory "/home/domain/www">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Final solution:
For those who are looking for solution - once OP recursively granted permission using chmod -R www:data, he could solve this issue. So, to conclude - this issue was not because of Apache configuration but because of UNIX permissions. Read OP's comments below for more details.

How to write .htaccess rewrite rule

I installed a online website onto my ubuntu machine for development purposes.
Everything is working except for one section of the site. When I point the browser to http://localhost.000-wordpress.co/app I get the below error in my apache2 error log:
[Fri Jan 17 16:57:03 2014] [error] [client 127.0.0.1] File does not exist: /var/www/app, referer: http://localhost.000-wordpress/
The server is looking for the app folder in the wrong location on my file system. So I have created a .htaccess file but I don't know how to write a rewrite rule for this.
How should I code a rewrite rule to tell the server to go to /home/ross/public_html/000-wordpress/public/app instead of /var/www/app?
This is my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Update
After following Covner's advice I updated my apache2.conf file with:
Alias /app /home/ross/public_html/000-wordpress/public/app
<Directory /home/ross/public_html/000-wordpress/public/app>
Order deny,allow
</Directory>
But this has thrown back two different errors:
[Sat Jan 18 23:35:55 2014] [error] [client 127.0.0.1] PHP Warning: require_once(/home/ross/public_html/000-wordpress/public/app/../vendors/yii/framework/yii.php): failed to open stream: No such file or directory in /home/ross/public_html/000-wordpress/public/app/index.php on line 12, referer: http://localhost.000-wordpress/
[Sat Jan 18 23:35:55 2014] [error] [client 127.0.0.1] PHP Fatal error: require_once(): Failed opening required '/home/ross/public_html/000-wordpress/public/app/../vendors/yii/framework/yii.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ross/public_html/000-wordpress/public/app/index.php on line 12, referer: http://localhost.000-wordpress/
You don't want to do anything in htaccess, just use the normal configuration file (they're all created equal)
Alias /app /home/ross/public_html/000-wordpress/public/app
<Directory /home/ross/public_html/000-wordpress/public/app>
Order deny,allow
</Directory>

Wordpress Apache Config Errors

I have installed Wordpress on Apache. It appears to work fine, i get the homepage and have created pages on the admin.
I can access the home[page fine. But when i try access the pages. I get 404s.
http://mysite.com/ works fine
http://mysite.com/news throughs a 404.
In the log files, I have the following error:
[Fri Dec 14 10:21:58 2012] [error] [client 127.0.0.1] File does not exist: /home/wordpress/mysite/news, referer: http://mysite.com/
I am using NameBasedVirtual hosting in Apache.
<VirtualHost *:8080>
ServerName mysite.com
DocumentRoot /home/wordpress/mysite/
ErrorLog /var/log/www/mysite-error.log
CustomLog /var/log/www/mysite-access.log combined
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
<Directory /home/wordpress/mysite>
AllowOverride FileInfo Options
Allow from all
DirectoryIndex index.php
</Directory>
<Location /wp-admin/>
Header set Cache-Control no-cache
</Location>
</VirtualHost>
I looked at .htaccess.
It says .
But Apache doesnt have mod_rewrite installed by default on Ubuntu. So it didnt work and didnt through a nice error.
Just add in mod_rewrite to fix this

Resources