I know there are questions with similar titles here but none seem to work for me hence the reason to create a new question.
So here's the problem, i have a site that works perfectly on localhost where i am sure has PDO support but after uploading on my shared hosting i get the
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Class 'PDO' not found
the solutions here all involve editing php.ini and installing PDO however, i am on a shared hosting without access to php.ini file or ssh.
I am using laravel 5.5, php version 7.2 with a voyager backend.
here's what my .htaccess looks like
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
<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]
</IfModule>
<IfModule mime_module>
AddType application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
Any help will be appreciated. Thanks.
Contact your Hosting support and let them enable PDO for you.
In some hosting you can overwrite php.ini by creating php.ini file in your hosting root. These are the extensions you need to enable in php.ini if you are in windows hosting.
extension=php_pdo.dll
extension=php_pdo_mysql.dll
Edit:
Check if PDO is already installed by your hosting provider.
Create index.php file or any other file which you can access. The content must have
<?php
phpinfo();
?>
If PDO is installed already, the next thing to do is running composer install (SSH access required). You must delete your vendor folder beforehand. Assuming that your public folder is /var/www/html. go to the html directory and run
composer install
It's late but i here is my solution. i was facing the same problem in Laravel 5.6 and i didn't have SSH access for some reason. but when i change my PHP version from 7.2 to 7.1 it works for me.
Hope this will work with someone who doesn't have shell access.
Related
A project, which is prepared with Laravel Framework, has handed over to me. Previous developer has not used git, some composer commands and Laravel's .gitignore file(also removed it). On the other hand he has prepared the project on the production server.
Anyway. Firstly I've found a gitignore for laravel and pushed the project to my repository. Then I wanted to pull it to my local. All folders and files pulled except of vendor folder.
Then I executed:
composer install
Gave me this error:
Class 'Maatwebsite\Excel\Excel' not found
Then I fixed it by the method here.
Then retried composer install, gave me this error:
Undefined index: name
Then fixed it by the method here.
Then retried composer install, and succeeded. Then I cleared cache with php artisan cache:clear
I've configured .env file and tried to enter to homepage. It redirected me to login page and gave 404. I've checked the .htaccess, there was redirection like that:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://example.com/app/$1 [R=301,L]
# 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]
</IfModule>
# php -- BEGIN cPanel-generated handler, do not edit
<IfModule mime_module>
AddType application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Changed the example.com to my localhost. But still gives me 404.
Is there anything that I'm missing?
Note: Called the previous developer, and he said me "directly copy and paste the all folders". Hi from 90s :(
OP Said this worked for him so I'm moving it from comments to an answer:
Let's go over what should be there for the pages to return correctly: First you need a routes folder with with all the routes in files inside of it. Second you need the Controller folder (found in /app/Http). Third you need the resources folder with the actual views. Fourth you need the public folder with the CSS/JS, etc.
Since OP stated that all the views work except for the login view:
First find out what the login view page is called, then go to your routes and make sure there's a line such as
Route::get('/login', 'SomeController#somefunction')->name('login.path');
Then go to the controller that is referenced in that route, and make sure that the function returns the view of the login page
Have you tried to generate you laravel application key using php artisan key:generate.
If that also doesn't work then try to remove .htaccess temporary.
Try this command
composer require maatwebsite/excel:^3.0
Actually I am deploying my laravel 5 Application on Linode Server.
My client create space for me in such type of path.
var/www/html/abcproject
I point out my godaddy domain to abcproject directory.
Now I have uploaded my all Laravel 5 files on abcproject directory.
My issue is that , my home page is working fine but my internal pages
are giving Not Fount Error.
Suppose when I try to logged in it is giving below error.
Not Found
The requested URL /abcproject/login was not found on this server.
Secondly Laravel 5 URL is getting url like that.
Supposed URL.
http://15.30.19.61/abcproject/index.php/registers
I did not understand where is and what is the issue.
One thing is my project is working fine when I try such type of URL.
http://example.com/index.php/ But In this case my URL Rewriting did not work but project is working like I can logged in, go in different pages, Logout etc.
My HTACCESS FILE
<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>
Thanks
If you are powering your laravel project from a sub folder such as you mentioned above:
http://15.30.19.61/abcproject
You should add this to your .htaccess file under RewriteEngine On.
RewriteBase /abcproject
I also faced a similar issue with LAMP configuration and I resolved by enabling rewrite rules of apache. If some needs details then it can be referred at the below blog notes
http://ankgne.com/post/setting-up-digital-ocean-for-laravel-application
Step 1: Enabling mod re-write using sudo a2enmod rewrite
Step 2: Allowing the laravel .htaccess (in public directory of laravel page)
file to apply rewrite rules
sudo vi /etc/apache2/sites-available/000-default.conf and adding below lines
Note: Change "/var/www/html" to "path of laravel public folder"
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
. . .
Step 3: Restarting web server using sudo systemctl restart apache2
We have two hosting packages at godaddy. Our live website is working fine using following .htaccess file. Website is accessible without using index.php in url.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
We used same htaccess file and same code on other hosting that is also by godaddy. We just wanted to make production and development instances seperate. But on other hosting with same code and htaccess file, website shows 404 page not found error but website works fine with index.php in url.
We have same php version on both server. Just wants to know what could be the issue?
I also faced the similar problem when I move my 100% working code to dedicated Debian server. After 3 hours of research, i found out why htaccess file is not working.You need to allow overriding of htaccess in Apache Configuration.
Here are the steps.
Step 1:
Add this in htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Step 2:
Remove index.php in codeigniter config
$config['index_page'] = '';
Step 3:
Allow overriding htaccess in Apache Configuration (Command)
sudo nano /etc/apache2/apache2.conf
and edit the file & change to
AllowOverride All
for www folder
Step 4:
Restart Apache (Command)
sudo /etc/init.d/apache2 restart
Before you make any changes in apache2.conf file make sure to make a backup copy of that file. If you are using Debian server you can avoid sudo command. I believe you know how to connect to your server using ssh client software like putty. Comment below if this method does not work for you.
Follow this
Create a new .htaccess file in your public_html/Project root
Paste the following code
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt|static) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/?$1 [L,QSA]
Optional
If you can ssh into the server using command ssh username#ip_address on a command line either Linux terminal or Putty
The username is the one given to you by GoDaddy or you can use root
The ip_address would be the Public IP to your host you can find it in your hosting panel
Run the command sudo a2dissite 000-default
The command disables the default apache config that handles request
Goodluck!
You can use this. This works for me in godaddy hosting.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
try this one.. it's works for me..
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
I have faced the similar problem when I move on godaddy server.And It's work for me.
Add this code into your .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
In config file:
$config['base_url'] = 'domain.com';
$config['index.php'] = '';
And Set AllowOverride to All in your httpd.conf
set the correct permission on the /cache folder, rather than just making the folder writable you need to make it reclusively writable.
I hope it will work for you.
Try to lowercase all your controllers. This fix the problem for me.
in index.php you echo "test" and run .then you can check whether it is called or not.
in config file enable error log .
Make your /application/logs folder writable.
In /application/config/config.php set. $config['log_threshold'] = 4;
check the log /application/logs folder
I have limited knowledge in server networking but this should give you a few ideas.
First ,you must know what is .htacess file is. you can check it here link
.htaccess is a configuration file for use on web servers running the
Apache Web Server software. When a .htaccess file is placed in a
directory which is in turn 'loaded via the Apache Web Server', then
the .htaccess file is detected and executed by the Apache Web Server
software. These .htaccess files can be used to alter the configuration
of the Apache Web Server software to enable/disable additional
functionality and features that the Apache Web Server software has to
offer. These facilities include basic redirect functionality, for
instance if a 404 file not found error occurs, or for more advanced
functions such as content password protection or image hot link
prevention.
Basically .htaccess is giving you permission to edit the configuration of Apache Web Server. You will gain permission using .htacess if mod_rewrite is enabled in Apache. I will not write what that 4 basic line in .htaccess can do in codeigniter because you can find it in google. this link can give you some nice basic info.
Now the main issue is .htaccess is not working in your other hosting. This is possible because a few reason :
For some reason, mod_rewrite is disabled in your Apache Web Server. If your hosting is VPS or DS it's possible you are didn't configuring it yet. Someone already ask how to enable mod_rewrite, you can go to this link. If you are using Shared Hosting, ask your hosting to enable mod.rewrite in your host. You can check if mod.rewrite enabled or not in your hosting following this link. Or you can simply check with <?php phpinfo(); ?> and check in "Loaded Modules" for mod_rewrite exist or not. Example in this image.
You are not using Apache as Web Server. There are others Web Server as NGINX and lighttpd. You should ask your server administrator what Web Server are you use currently. I dont have any experience using NGINX and lighttpd so i cannot give you any help in that. But as far as i know .htaccess code is different in APACHE, NGINX, and lighttpd. You can try to convert .htaccess apache code to nginx code in here or here. For converting .htaccess to lighttpd unfortunately, i cannot find any online converter but there are official guide here and here
Well for the complete tips sake i will write this. It's possible you are not configuring codeigniter to not use index.php. In config file, empty configuration for index_page. and give Base_url your domain name. $config['base_url'] = "yourdomainname.com"; $config['index_page'] = '';
I hope this clear your confussion why your .htaccess didnt work.
As you mentioned here, on localhost your code is working fine but when you moved it over live server it causes 404 error. There might be few cases you need to check:
Step 1: Check mod_rewrite is enabled or not in your Apache configuration
Step 2: Remove index.php in codeigniter config as #geordy suggested
You can check it by
<?php
echo 'Test'; die;
?>
in your root index.php. It ensures your all requests should go through this files else Codeigniter framework would not work properly.
I have installed composer on windows 8 and i am using the webserver xampp,
I did the comand composer global require
composer global require "laravel/installer=~1.1"
I even configure env path for composer like this
set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
Then created the project like this
Laravel new myproject
I check the file .htaccess in my public folder of my laravel project,
<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]
I have checked the module activation for url rewriting in apache httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
then i test it and i typed many urls and it gives a page not found ERROR !
Here are the url tested:
localhost/laravel/
localhost/laravel/public
localhost/laravel/myproject/
localhost/laravel/myproject/public
Did i miss something, i am quite surprised to fix things for hours to use a popular framework like laravel.
From the comment of my question we conclude that laravel has a bug with xampp and the bug was reported 3 days ago on the official bug tracking forum from laravel
Please check this link: http://github.com/laravel/framework/issues/8129
Also we have found that my folder structure is too long and it could generate conflict within the configuration of xampp, the advice was to use a virtual host solution, the one advised by laravel is Homestead, so let's try with homestead !
http://laravel.com/docs/5.0/homestead
Good luck to everyone who need to fix their xampp server to work with laravel maybe try to use another webserver instead.
I downloaded a PHP script written using CodeIgniter. when I run it from the localhost, on going to the admin folder, it shows localhost again. Also when running from my web host, it shows a 500 Internal Server Error.
I run the site from http://localhost/myproj It works. Then when I try to go to the admin page which is at http://localhost/myproj/administrator, it gives a 500 Internal Server Error.
I read here that this might be due to a wrong code in the .htaccess file. This is my present .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
Please help me. I know it might be a very small problem, but I'm unable to find the error.
The problem with 500 errors (with CodeIgniter), with different apache settings, it displays 500 error when there's an error with PHP configuration.
Here's how it can trigger 500 error with CodeIgniter:
Error in script (PHP misconfigurations, missing packages, etc...)
PHP "Fatal Errors"
Please check your apache error logs, there should be some interesting information in there.
Just in case somebody else stumbles across this problem, I inherited an older CodeIgniter project and had a lot of trouble getting it to install.
I wasted a ton of time trying to create a local installation of the site and tried everything. In the end, the solution was simple.
The problem is that older CodeIgniter versions (like 1.7 and below), don't work with PHP 5.3. The solution is to switch to PHP 5.2 or something older.
You're trying to remove index.php from your site URL's, correct?
Try setting your $config['uri_protocol'] to REQUEST_URI instead of AUTO.
Try this to your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >
Make sure your root index.php file has the correct permission, its permission must be 0755 or 0644
remove comment in httpd.conf (apache configuration file):
LoadModule rewrite_module modules/mod_rewrite.so
Whenever I run CodeIgniter in a sub directory I set the RewriteBase to it. Try setting it as /myproj/ instead of /.
I know I am late, but this will help someone.
Check if rewrite engine is enabled.
If not, enable rewrite engine and restart server.
sudo a2enmod rewrite
sudo service apache2 restart
if The wampserver Version 2.5 then change apache configuration as
httpd.conf (apache configuration file):
From
#LoadModule rewrite_module modules/mod_rewrite.so**
To ,delete the #
LoadModule rewrite_module modules/mod_rewrite.so**
this working fine to me
Pretty late to the party but, i think the best approach to 500 internal server errors in CodeIgniter would be to enable the error log functionality in the Config.php file in the config folder and set a threshold value i.e. $config['log_threshold'] = 1,2,3,4 depending on the logs you want to view.
This probably isn't relevant any more to this thread, but hopefully helpful to somebody.
I've had 500 errors for the past hour as I had a controller return an array not supported by the php version ran on my (crappy) server. Seems trivial but had the hallmarks of a codeigniter error.
I had to use:
class emck_model extends CI_Model {
public function getTiles(){
return array(...);
}
}
Instead of
class emck_model extends CI_Model {
public function getTiles(){
return [...];
}
}
Cheers
This works fine for me
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >
If your are using local server, this problem is faced in Wampserver when the essential modules are not enable.
You can Enable them with:
Left click on Wampsever icon
Go to APACHE -> APACHE MODULES
scroll down and find "rewrite_module" and "headers_module"
Then mark them check
It will restart automatically. Done.