I am trying to deploy a Laravel 7 application to Elastic BeanStalk but having some problem with the routing.
I have followed the tutorial from the video below and upload the zip archive with all my local files.
I have also fixed the permission issue after having set the root to /public.
Currently, the only page visible is the homepage whereas al the other pages like /login, /register and the other show me a 404
here is the log of the from eb:
2020/05/01 14:19:30 [error] 4091#0: *4 open() "/var/www/html/public/login" failed (2: No such file or directory), client: 82.4.194.3, server: , request: "GET /login HTTP/1.1"
https://www.youtube.com/watch?v=ISVaMijczKc
I suppose you are using Beanstalk PHP platform with Linux in version 2; this version uses Nginx (whereas the previous version uses Apache).
You can see more details in the official documentation: https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP
In that case, you have to configure Nginx for redirection as described in the Laravel documentation: https://laravel.com/docs/7.x/deployment#nginx
Just create the file .platform/nginx/conf.d/elasticbeanstalk/laravel.conf (at the root of your project):
location / {
try_files $uri $uri/ /index.php?$query_string;
}
Feel free to add other configuration for your need.
You will find more details about extending the platform here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
After several attempts, I have it up and running. I had deleted the application and used EB CLI to create it again.
I created an environment config and placed it in .ebextentions and I added AllowOverride All
Here is the content of my 01-environment.config
option_settings:
aws:elasticbeanstalk:container:php:phpini:
document_root: /public
composer_options: --no-dev
aws:elasticbeanstalk:application:environment:
APP_ENV: production
APP_KEY: base64:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
and my .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
AllowOverride All
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Related
I have Laravel 6 running well on my localhost but when I deploy on domainsite.com, it only shows the main page but the rest of links shows 404 page not found. I am using CentOS 7, aaPanel running nginx server. PHP 7.4 MySQL.
I have this config so far.
URL Rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
fileinfo installed
I have removed in Disabled Functions(putenv and symlink) but still I get the error.
Anyone have tried this? Thank you!
I want to upload my local Laravel project on godaddy but I'm having some error
error
[Wed Jul 05 21:16:44.858396 2017]
[autoindex:error] [pid 21796:tid 139689709188864]
[client 99.240.235.234:57754]
AH01276:
Cannot serve directory /home/bugsbunny/public_html/sto.com/:
No matching DirectoryIndex (/home/bugsbunny/public_html/sto.com/public/index.php)
found, and server-generated directory index forbidden by Options directive
.htaccess
DirectoryIndex /home/bugsbunny/public_html/sto.com/public/index.php
<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 ^ /home/bugsbunny/public_html/sto.com/public/index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
steps that I did
I edited the public/.htaccess file
by edited I mean changing the directory on the first line and the line starting by RewriteRule
I cut & paste this file into the root directory
I uploaded the project into godaddy
On Godaddy I find it easier to create/upload a Laravel app with this procedure
1- Create an addon domain or a sub-domain on Godaddy
2- Install a Laravel app (Quick-install) on this domain/sub-domain
3- Download this app on local (my computer) with Filezilla (or other sftp software)
4- On local disk change the .env database access or (create a user+password+database on phpmyadmin/mysql with the information contain in the .env that Godaddy setup for you)
5- finish up the app (Build the webapp project that you want to do).
6- Upload the app to the server (except the .env) with Filezilla
7- upload the database (mysql) from local to Godaddy
So there is no need to change the .htaccess file.
Why you are not using dedicated hosting for laravel. Get your server and [digitaloccean, etc] and do what you want...
Question: how to configure .htaccess in spring boot?
angularjs provides html5Mode, which makes your app use pushstate-based URL instead of hashtags. However this requires server side support, since the generated urls need to be rendered properly as well.
If you're running your angular app on an apache server you can easily add this rule in an .htaccess file.
# Apache .htaccess
# angularjs pushstate (history) support:
# See http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url-routing/
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteCond %{REQUEST_URI} !.*\.(cssĀ¦js|html|png) #Add extra extensions needed.
RewriteRule (.*) index.html [L]
</ifModule>
I've just setup an AMP server on OSX 10.9 and have a bizzare problem which is not present on my live hosting server or my old WAMP server.
I want to redirect any URL that doesn't directly map to a file on the server to index.php. I'm using the following .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# prevent loop
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*)$ /index.php?/$1 [L]
when I try http://example.com/example there is no problem, but when I introduce another slash, for example, http://example.com/example/
I get the a 404 error The requested URL /example.html/ was not found on this server.
Server version: Apache/2.2.26 (Unix)
Looks like your problem is related to enabling of MultiViews here. Turn it off by using this line on top of your .htaccess:
Options -MultiViews
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
I have Apache/2.2.22 (Ubuntu). Site directory:
.htaccess
index.php
catalog.php
When I type in browser:
site.local/about-company - redirect to index.php
site.local/faq - redirect to index.php
site.local/catalog - return 404
**.htaccess**
DirectoryIndex index.php
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php
Ubuntu 14.04 have only Apache/2.4.7
This version Apache with bug in mod_rewrite module.
Now on http://apache.org actually version is 2.4.9. Use this or wait 2.4.9 in Ubuntu Server.