I am trying to migrated my application in ebs because it was deprecated, my previous platform was:
PHP 5.6 running on 64bit Amazon Linux / 2.9.8
now i'm migrating to:
PHP 7.4 running on 64bit Amazon Linux 2 / 3.0.3
This platform uses the Nginx server instead of Apache.
I was able to deploy my application but the problem is that my .htaccess configuration file was deprecated as was my .ebextensions configuration file. so I have lost the settings I had for example to get clean urls and redirects from http to https.
I have tried to transform the apache configurations to Nginx by putting the respective configuration file but apparently they have no effect.
I have tried many test configurations and I have come to the conclusion that the platform is not reading the configurations that I put.
I have tried to try for example with this little configuration, which should allow me to list the "views" directory:
cleanurl.config
server {
location / views / {
autoindex on;
}
}
I have tried putting it in the following folders.
".ebextensions / cleanurl.config"
files:
"/etc/nginx/conf.d/cleanurl.conf":
mode: "000644"
owner: root
group: root
content: |
server {
location / views / {
autoindex on;
}
}
".platform / nginx / conf.d / cleanurl.config"
server {
location / views / {
autoindex on;
}
}
But I don't get results. I always get 403 Forbidden when I point to a folder. Please help.
Thanks in advance
After trying and trying I was able to solve it in the following way:
I put the file in this location
.platform/nginx/conf.d/elasticbeanstalk/cleanurl.conf
change my config file like this
location/views/ {
autoindex on;
}
and now everything works.
I have tried many test configurations and I have come to the conclusion that the platform is not reading the configurations that I put.
In the first case this is because the configuration files that you use are for Amazon Linux 1 (AL1). However, you environment is PHP 7.4 running on 64bit Amazon Linux 2 (AL2).
In your second attempt, you are using the config files in .platform/nginx/conf.d/ as you should. However, you are using *.config extension. This wrong extension and it should be:
cleanurl.conf
You still may have other issues, but the wrong extension could explain why the files are being ignored.
I have a very simple httpd 2.4 configuration on AWS AMI 2 running on EC2.
My application is in /var/www/html/ with an index.php
Reaching ec2-domain.amazonaws.com/ serves index.php without any issue. So does ec2-domain.amazonaws.com/index.php
However, ec2-domain.amazonaws.com/endpoint returns 404, whereas ec2-domain.amazonaws.com/index.php/endpoint serves the expect page.
My httpd config is extremely basic.
All files in /var/www/html/ are owned by apache:apache.
Any ideas anyone?
Under apache2.conf or httpd.conf
Change DirectoryIndex from index.html to index.php
I have an apache server and my projects are inside /var/www/html/
Inside there I created a new project using composer like composer create-project symfony/website-skeleton myproject.
Then inside my project I ran the command composer require symfony/apache-pack which added an .htaccess file inside public folder containing the default .htaccess of symfony.
When I accessed my server like http://192.168.0.2/myproject I got the folder list that apache serves if it doesn't find an index.php file because it accessed the default symfony folder in /var/www/html/myproject and not the public folder.
So inside the folder /var/www/html/myproject which is a symfony project I added the following .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myproject/
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
No I when I visit http://192.168.0.2/myproject I get an error that No route found for "GET /myproject/" which means that symfony now considers /myproject as part of a route.
Is there a solution for this. I suggested solution that I got from symfony slack would be to have the project inside another folder and symlink only the public folder.
Something like:
lrwxrwxrwx 1 root root 59 gmponos 9 19:26 myproject -> /home/gmponos/Projects/myproject/public/
This is a solution but I really need to have the whole project under /var/www/html/ and not symlink the public folder.
Also another solution according to the official documentation is editing the apache config and change the document root from /var/www/html/myproject to /var/www/html/myproject/public but I need the configuration to stay inside the project and not change the apache config.
Is there any solution?
Is there any solution?
No Solution for what you are requesting :
You must have the rights to configure Apache to adjust the document root to either :
/var/www/html/myproject,
or /var/www/html/myproject/public
and set according access permissions in apache config file
Putting whole code in code in /var/www/html directory, and give free remote access through Web (Apache) is very risky, for production environments.
I have deployed my laravel 5.4 app on Heroku. The problem is, I am getting this error message:
Forbidden
You don't have permission to access / on this server
My Procfile:
web: vendor/bin/heroku-php-apache2 public/
Looking into the log, I find that it has been trying 'app/' instead of '/'.
My log, snipped for readability.
2017-12-03T14:18:45.747195+00:00 app[web.1]: [Sun Dec 03 14:18:45.746749 2017] [autoindex:error] [pid 122:tid 140692458305280] [client 10.140.221.43:41026] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
My .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteC
I can't figure out where i might be saying it to look into 'app/' instead of '/'. If that is the cause for this error.
I don't know why the server thinks your root is at /app but this error occurs because of the permission of the public/ directory from which Heroku is supposed to serve your application.
To resolve this issue, simply add the following to the script section of your composer.json
"post-install-cmd": [
"php artisan clear-compiled",
"chmod -R 777 public/"
]
Note the change in permission of the public/ directory.
EDIT:
While you are at it, check your Procfile make sure it is spelled correctly and starts with an uppercase P.
PS: I know some people are really nitpicky and would say the permission is too lax. Yes, I agree with you. You can change it to something else like 775 let's just get the juice flowing.
Inside the Laravel Root folder, make a file called Procfile.
Write the following line inside the Procfile.
web: vendor/bin/heroku-php-nginx public/
Then deploy it again!
Src and more here https://appdividend.com/2018/04/17/how-to-deploy-laravel-project-on-heroku/
Hope this was helpful =)
SOLUTION STEPS:
Clone your project to your PC:
heroku git:clone -a your-app-name
Create a file name: Procfile
Then save following lin of code in this Procfile: web: vendor/bin/heroku-php-apache2 public/
Deploy your project back to heroku using commed:
$ git add .
$ git commit -am "make it better"
$ git push heroku master
I hope now no problem run your Laravel App!
/app is the absolute path on the file system, where you app resides. The error indicates that your Procfile does not actually contain what you claim it does. You probably haven't added and committed it to Git. Apache is trying to serve from the "root" right now, not from the public/ subdirectory.
Create and put this .htaccess file in your laravel installation folder.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
solution is Here:enter link description here
I was having the same issue today, and have found an easy solution to it. I'm running a Laravel 6 app on Heroku.
The issue started after I setup an HTTPS redirect, by adding an apache configuration file, and loading it using the -C option in the Heroku Procfile:
web: vendor/bin/heroku-php-apache2 -C apache.conf public/
The error I was receiving:
2020-01-13T03:55:29.272349+00:00 app[web.1]: [Mon Jan 13 03:55:29.271704 2020] [autoindex:error] [pid 127:tid 140227477751552] [client 10.213.231.122:26179] AH01276: Cannot serve directory /app/public/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
So the same issue as you were having. What I found was that when you start apache with a custom configuration on Heroku, it starts looking for an index.html file, instead of an index.php file.
To fix this, I added the following line to my apache configuration file:
DirectoryIndex index.php
This directs apache to look for index.php, and fixes the issue.
I removed the quotation mark that surrounded the text of the procfile file and it works
Edit the Procfile
from
"web: vendor/bin/heroku-php-apache2 public/"
to
web: vendor/bin/heroku-php-apache2 public/
This error persist even though i have followed the answer which is marked correct
(even i have run heroku run bash to ls -l to see the file permission)
but i was still getting this error and may be this is because i was using different local branch rather than the local master branch so my advice is to always deploy from your local master branch and also when i deploy from another branch i get this log when pushing the code to heroku
NOTICE: No Procfile, using 'web: heroku-php-apache2'
I faced the same problem when deploying my Laravel app on Heroku. I tried to change permissions in/of my composer file, but that didn't help. Instead, I added this to my htaccess file:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Pushing this to Heroku fixed the problem.
I created Procfile using echo "web: vendor/bin/heroku-php-apache2 public/" > Procfile command just like the docs told me to, but then it generated the Procfile command inside a quotation mark. That's why, I still get the 403 forbidden error even though I've modified my composer.json file just like the other user suggested to.
So guys, make sure the command inside your Procfile isn't surrounded by quotation mark. Then, modify the composer.json just like the approved answer suggested to and re-deploy your site.
If anyone is still having this issue, ensure that the procfile is named Procfile with the capital P.
I have a symfony project with a lot of requests and users, so I decided to use nginx + php-fpm to get a bit more performance.
But my client wants to have plesk for server administration. So, I installed everything whats required (nginx, fpm, apache) and created the host instance in plesk. Now, the start page of the website works fine - but some child pages gives me a 404 error code directly from nginx, other child pages works.
All urls are rewritten (symfony default). I only renamed the symfony default index file of the web folder app.php to index.php.
My additional configuration in plesk is: nothing
edit: I use nginx 1.9.4 (delivered with ubuntu or plesk) and symfony 2.8
Try to add a following lines in "Apache & Nginx settings" > "Additional nginx directives" to your domain in Plesk:
if (!-f $request_filename) {
rewrite ^/(.*)$ /index.php last;
}