I am trying setup a Centos Server with LAMP installed in it.
I have a laravel project created successfully but still when i am opening a route (/) its showing 500 ERROR i don't know where did the configuration goes wrong.
Here is how my htaccess file looks like:
<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
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
And here is how my /etc/httpd/conf/httpd.conf file looks like:
DocumentRoot "/var/www/html"
#
# Relax access to content within /var/www.
#
<Directory "/var/www">
AllowOverride none
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# 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
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
I have installed all the required plugins as well.
I installed wordpress and it seems to be running smoothly. But i am not sure why its not working with this.
Here is my project URL http://104.199.222.145/demo2/ i just did a basic laravel installation.
I am thinking this as a more .htaccess problem somewhere. But not sure.
Thank you!
Did you set up the permissions to the laravel folders ?
sudo chmod 755 -R demo2
chmod -R o+w demo2/storage
What's the laravel version that you installed on your server?
And what's your server php version? If the requirements are not met laravel throws 500 errors.
Related
I have probably tried all the solution available online. Still dont understand why URL rewrite is not working for me in this Linode Ubuntu 18.04 VPS.
.htaccess
Options -MultiViews
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
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
From apache2.conf
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
/etc/apache2/sites-available/regenucell.com.conf
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster#regenucell.com
ServerName regenucell.com
ServerAlias regenucell.com www.regenucell.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/regenucell.com/public_html/mms/public
# Log file locations
LogLevel warn
ErrorLog /var/www/html/regenucell.com/log/error.log
CustomLog /var/www/html/regenucell.com/log/access.log combined
<Directory "/var/wwwhtml/regenucell.com/public_html/mms/public">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Any clue is highly appreciated.
Please check mod rewrite is enabled first.
Also check directory directive in your virtual host file www and html is missing/ I believe.
This is the first time using CodeIngiter and I have url access issue.
I have to include index.php in the url to access a page.
To solve the issue, I took a reference at here.
I followed all steps.
I have updated at config.php as
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
.htaccess file at root is
RewriteEngine On
RewriteCond $1 !^(index\.php | assets | images | js | css | uploads | favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]
ubuntu#ip-172-31-28-229:/var/www/html/CodeIgniter$ a2enmod rewrite
Module rewrite already enabled
I can't change all AllowOverride None to AllowOverride All. in the /etc/apache2/apache2.conf file. If I do it, I even can't access my root url.
My /etc/apache2/apache2.conf file is as follow.
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
I restarted my apache2 server.
But I still can't access without index.php in my url.
What is still wrong?
My problem was solved using the following mod_rewrite.c:
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
# - - - Use for 1and1 - - -
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hello Everyone I am working on my project which in on Laravel 5.2. I have setup my project on my local machine but its now working without adding index.php in url.
I request with the url :-
http://localhost/project_folder/admin
While I am trying to run without index.php and run my url it gives me following error.
Not Found
The requested URL /project_folder/admin was not found on this server.
For this I did following steps :
1) Give permission (777) to storage and cache folder.
2) I Go to path /etc/apache2/sites-available/000-default.conf and edit it, now it look something like this.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
In my .htaccess file have following code.
<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]
RewriteRule ^(.*)/$ /moduleTesting/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Please suggest me if I forget any requirement or anything else.
please enable mode rewrite.
Please ensure that you have mod rewrite enable on your system.(search for mod_rewrite in info.php having code)
<?php
phpinfo();
?>
in terminal run command:
$ sudo a2enmod rewrite
I know this question has been asked a bunch of times but I'm not finding any answer that helps.
So I have two pages, index.php and refer.php. I put a rule into my httpd.conf that used mod_rewrite to get rid of the .php extension when a user goes to the page. Refer.php worked fine to show up as just refer, but trying to go to index.php gives me a Forbidden error.
Error log shows this:
AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive.
Here's the relevant part of my httpd.conf:
<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# 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 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 All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
The file index.php exists, of course. Any help?
Edit:
The url is just the root url - like domain.com. It should access index.php, which it did fine before I did the mod_rewrite. So I expect the index page to come up, which it doesn't because of the errors that I described above. .htaccess file is just all defaults except for:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
I've created a simple Zend Framework 1.12 test app via the zf.bat on my windows machine (xampp, php5.3): "zf create project testapp"
After that i've created an new controller called 'FoobarController' next to the 'IndexController'.
Now I can switch between these urls:
localhost/projects/testapp/public/
localhost/projects/testapp/public/index
localhost/projects/testapp/public/foobar
Now I have uploaded the whole testapp into the web server directory of my raspberry pi (192.168.1.100, Apache2, PHP5.3, ModRewite On, AllowOverride All).
This urls are working fine when I call the raspberry from the windows machine:
192.168.1.100/sites/testapp/public
192.168.1.100/sites/testapp/public/foobar
This one will display: "The requested URL /sites/testapp/public/index was not found on this server"
192.168.1.100/sites/testapp/public/index
Has someone an idea why the url to the "index" controller wont work properly on my raspberry? (I did nothing more than the explained steps)
/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.htaccess:
RewriteEngine On
RewriteBase /sites/testapp/public
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]