Laravel 5 blank page - php

I haVE my page hosted in Amazon EC2, it was working well in the root of the apache server (/var/www/html). But i want to have an other page in the same server so i start moving it to a subfolder (/var/www/html/alqip/public) so i can setup the second website in (/var/www/html/page2).
The site is developed in Laravel 5 and it is showing a blank page without login any error in laravel logs and system logs either (syslog, apache logs, php logs).
The permissions of storage folder are 777.
This is my .htaccess in public/ folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And my page.config in /var/apache2/sites-available:
<VirtualHost *:80>
ServerName alqip.com
ServerAlias www.alqip.com
DocumentRoot "/var/www/html/alqip/public"
<Directory "/var/www/html/alqip/public">
AllowOverride All
</Directory>
</VirtualHost>
I think the problem is in Laravel, not in server configuration, what do you think? Thanks!

Verify the firewall is down and if you are on centos check the configuration of the selinux. For default the selinux is enable edit the file /etc/selinux/config
SELINUX=disabled
After disbled you have to reboot you server

after installing Laravel you must create the .env file using the .envexample template.
the next problem you will have is permission issues
Its caused because php is running as another user by default.
so to fix this do
sudo nano /etc/php/7.0/fpm/pool.d/www.conf
then edit the
user = "put user that owns the directories" group = "put user that owns the directories"
then:
sudo systemctl reload php7.0-fpm

Related

Set Root Folder To SubFolder In Apache On LocalHost That Will Also Work On Production Server

I have a project that has a 'public' and 'private' folder structure that sit at the same level inside the main project root folder (see attached image).
I would like so that the local server (in this case MAMP) automatically defaults to the 'public' folder as the domain root. Is it best to do this is in php or in Apache?
Also, when I upload the site to a production server the domain name is going to be set on the 'public' folder, so I'd ideally like a solution that means I when I upload the site this will still be the case - i.e. www.example.com will be the 'project/public' folder.
This is all new to me so am at a bit of loss as to the best way to approach this.
Basically all you need is to create a virtual host configuration file and enable the port in Apache configuration file on which you're application is going to listen to the requests. I've never used MAMP so am giving you an example of vhost configuration on Linux machine
Create a conf file in /etc/httpd/conf.d/
vim /etc/httpd/conf.d/example.conf
This file will tell Apache server what will be the document root for
a specific port. PORT can be any available port other then reserved
Ports (0-1023)
<VirtualHost *:80>
KeepAlive On
DocumentRoot "/var/www/example/public"
<Directory "/var/www/example/public/">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
Allow from all
# enable mod_rewrite
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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
LogLevel Warn
ErrorLog /var/log/httpd/example-error.log
CustomLog /var/log/httpd/example-access.log combined
Add this Port No PORT in Apache conf file
(/etc/httpd/conf/httpd.conf)
Listen PORT
Restart Apache Server
Like XAMP & WAMP, MAMP should also have a GUI to configure the Apache Server. You can locate the location/folder where these vhost configuration are save and you can modify that file directly through any Text Editor
You can refer these too
Configuring Virtual Hosts With MAMP
Adding a virtual host in MAMP for Mac

Running a core php project from apache instead of php -S localhost:4000

I'm trying to run a php project using apache configurations in LAMP but its not working*, whereas when I run it as php -S locahost:4000 its working really great.
Here is the link to the project if you need some info about the files or working of it Project
Here is my apache configuration -
<VirtualHost localhost:4000>
ServerAdmin root#localhost
ServerName localhost
ServerAlias localhost
DocumentRoot /var/www/html/dir
<Directory "/var/www/html/dir">
AllowOverride None
Options None
Require all granted
</Directory>
*not working means - when running it through apache i can only access the index page and when going to some other page of the project like localhost:4000/about It shows The requested URL /department was not found on this server. ie. Error 404.
I think that you expect "index.php" to receive all requests.
Now, Apache is trying to find "about" directory and "department" directory.
In order for Apache to run index.php on any URL, we need to use the Rewrite rule.
Although I have not verified it in detail, I guess it will work with the following rules.
RewriteEngine on
RewriteRule ^/(.*)$ /index.php
It now working after enabling a2enmod rewrite from apache and updating the contents of .htaccess file as follows
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]

Laravel 4 remove Index.php from URL

I need some help with laravel 4 application i need to remove Index.php from url i have tried the solution that has been mentioned in laravel documentation
Pretty URLs
Apache
The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.
If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
any Suggestions :) ?
FOR LAMP SERVER
Try the following steps,
Activate the mod_rewrite module with,
sudo a2enmod rewrite
and restart the apache
sudo service apache2 restart
To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html">`
AllowOverride All
</Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER.
Restart the server again:
sudo service apache2 restart
this worked for me
<Directory "/var/www/html">`
AllowOverride All
</Directory>
uncomment 'LoadModule rewrite_module modules/mod_rewrite.so' in apache httpd.conf
in 'public' folder check .htaccess file (created by default)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have read long posts and threads but nothing works then i found this and it works for me.
The easiest way to do this (and the way I always use) is to open up your Command prompt or Terminal and cd into the main directory of your project then run "php artisan serve". That's it. You're done. Don't believe me? Check out http://localhost:8000 and admire your Laravel work.
http://michaelbrooks.co.uk/post/laravel-localhost-removing-public-index-php
just go to your apache settings folder, i use wamp so myne is
C:/wamp/bin/apache/apache2.4.9/conf/httpd.conf - file
// located on line 154 precisely...
#LoadModule rewrite_module modules/mod_rewrite.so
// to
LoadModule rewrite_module modules/mod_rewrite.so
restart WAMP and BOOM!.. it works.
mod_rewrite apache module may not be enabled by default. enable it and retry.
Try this:
a2enmod rewrite
And it will works

Laravel 4 - 403 Permissions error when trying to access css/js files

I'm running on an Ubuntu 13.10 dev environment with Apache2 and after hours of trying to figure out permission errors to access routes, I was able to fix it. Now I can successfully browse through my application, but the problem that now exists is that I cannot access my css/js files within my public directory - it kicks back with a 403.
I've tried modifying the .htaccess file, the virtual host config file, and ran chmod on the entire site directory.
Here's a copy of my .htaccess file within the Public folder:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And here's a copy of my virtual host file:
<VirtualHost *:80>
DocumentRoot "/home/casey/Sites/caseyhoffmann.me/public"
ServerName caseyhoffmann.me.dev
<Directory "/home/casey/Sites/caseyhoffmann.me/public/">
AllowOverride all
Require all granted
DirectoryIndex index.php index.html
Options -MultiViews
</Directory>
</VirtualHost>
Any ideas?
Solved. Reapplied chown and redid chmod on the directory. File system permissions issue and had nothing to do with Apache.
Solution 1: (Recommended)
use absolute path in your css, js, images files rather than a relative one. Which means you have to make sure path of these files start either with http:// or a slash /.
Solution 2:
You can try adding this in your page's header:
<base href="/" />

web/app.php is not removing in symfony2

i have created first Symfony application but the url is so large
http:// ip address/repair/web/app_dev.php/home
http:// ip address/repair/web/app.php/home
i want to make it as http:// ip address/repair/home
here is httpd.conf of apache2
NameVirtualHost something ip address
ServerName "repair"
DocumentRoot "/var/www/repair/web"
<Directory "/var/www/repair/web">
DirectoryIndex app.php
AllowOverride None
Order allow,deny
Allow from All
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
RedirectMatch permanent ^/app\.php/(.*) /$1
</Directory>
my .htaccess of in web folder of symfony contains
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^app.php - [L]
RewriteRule ^app.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
i have reloded the mod-Rewrite of apache2 too
iam getting error
The requested URL /repair/home was not found on this server.
Apache/2.2.20 (Ubuntu) Server at ip address Port 80
If you want to access site by ip you need to copy your code to "localhost" directory (/var/www, e.g.)
The AllowOverride None line in your Apache config is causing the .htaccess file to be ignored.
If you replace it with AllowOverride All Apache will follow the directives in your .htaccess file.
You can find more information about AllowOverride here
Double-check that you actually have mod-rewrite loaded for Apache. On a Debian 6 install with Apache 2, the module was available, but it wasn't loaded. In order to load it, you can add a symlink in the mods-enabled directory to the module in the mods-available directory like this:
root#server:/etc/apache2/mods-enabled# ln -s ../mods-available/rewrite.load ./rewrite.load
Then you'll need to restart Apache2 to get it to reload its configuration. On Debian that would be sudo service apache2 restart

Categories