Laravel 500 server error on shared hosting - sql

Im trying to deploy my laravel project with namecheap however I'm getting a 500 server error.I've updated the server.php and index.php to point to the correct directories but I'm still getting the error. I've checked the error.log file in the public_html directory but it doesn't give any error when loading the site. I've also double checked the .env file to make sure the correct database credentials were entered.
index.php
if (file_exists(__DIR__.'/../nue/storage/framework/maintenance.php')) {
require __DIR__.'/../nue/storage/framework/maintenance.php';
}
require __DIR__.'/../nameofproject/vendor/autoload.php';
$app = require_once __DIR__.'/../nameofproject/bootstrap/app.php';
server.php
require_once __DIR__.'/../nameofproject/public_html/index.php';

Whenever I deploy my Laravel project in a sharedhost. These things I do
Copy the entire application directory (appname) inside public_html
Path to the domain will be "public_html/appname/public"
Link storage path using ssh

If your Laravel project is installed in the webroot (assuming public_html), then do the following:
Move the contents of public/ up one dir to the webroot. index.php and server.php should now be in the same dir as your .env.
In index.php, change ../vendor/autoload.php to just vendor/autoload.php and ../bootstrap/app.php to just bootstrap/app.php.
In server.php, change public/index.php to just index.php.

Related

Remove /public from URL in a subfolder

I'm building a Laravel application, and it will be in a subfolder of a current project. I'm trying to get rid of the /public in the URL, so that the users can view the project at this URL :
www.domain.com/project
instead of the default ...
www.domain.com/project/public
I did some digging on StackOverflow and the Laracasts forum, and I tried this, in a .htaccess file at the root of my project :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
However, my routes doesn't work anymore when I do this. Even the default route for / stopped working.
A lot of answers mention that the best way is to change the root in the Apache config, so that it serves the files from /public instead of at the root of the directory.
The problem is that this in a subfolder of a main project, how can I make it so that only this project is affected? The website at www.domain.com works fine and does not have a /public in the URL.
There are a couple options. I don't think you want to try fixing this at the htaccess level with mod rewrites (or anything like that)
One option is to create another virtual host that listens on an abitrary port (eg, 8080). Then set the document root for this virtual host to .../public/
Another option, you can spoof the dns in your /etc/hosts or Windows hosts file, and set up a dev.domain.com virtual host.
•Go to mainproject/public>>
a. .htacess
b. favicon.ico
c. index.php
d. robots.txt
e. web.config
1.cut these 5 files from public folder,and then paste on the main project folder that’s means out side of public folder… mainproject/files
2.Next after paste ,open index.php ,modify
•require __DIR__.'/…/bootstrap/autoload.php'; to
•require __DIR__.'/bootstrap/autoload.php';
modify
- $app = require_once DIR.'/../bootstrap/app.php'; to
- $app = require_once DIR.'/bootstrap/app.php';

Apache - only main domain's root is not working

I've created a new domain and setup a php application on the webroot. All the following requests are working perfectly.
/index.php
/info.php
/?anyting ( Note this, without index.php only query string is working )
/css/app.css
Only the domain's root is not working domian.in
I have created an virtual host for the domain. I tried giving DirectoryIndex index.php also, but still it's not working. There is no htaccess and it's a fresh server setup.
Googled whatever was possible, couldn't get any solution.
And if i hit domain.in it's serving the apache's default page.
If you have an virtual host you cant acces files outside the document root.
Maybe your html files (or others) are in a htdocs folder or something, you cant access htdocs/../

Need of vhost for zend application

If running any zend application it is recommended to ceate the vhost.
Why is it so?
Although the public part form the url can be removed by copying the index.php and .htaccess file to root of project directory.
Well... yes, technically can just copy index.php and .htaccess to the root of the project directory. However, by doing that you will expose all of your application files to the public.
For example, someone could try to access your config file like this: http://yourhost/yourproject/application/configs/config.ini
This will actually display the content of the config file (which might include sensitive data like your database configuration) unless you explicitly configure something in your .htaccess to prevent this.
When using a vhost with the DocumentRoot set to the public dir, that means that no file outside the public directory will be accessible from an URL. And since you should normally only have the index.php file in there, you ensure that your application is always accessed from that starting point.

Multiple CI application in a sub-domain

I am new to Apache environment. Preferably I do not want .htaccess file, but I think I have not choice. My application runs without problem in my notebook which is windows environment using WAMPSERVER. But when I deploy to hosting server which uses Apache, I face some problems. I am not sure the following structure is correct for CodeIgniter application. Following is the directory structure in hosting server...
httodocs/
/survey
/admin
/config <-- $route['default_controller'] = "admin";
/controllers
/models
/views
/...
/statistic
/config <-- $route['default_controller'] = "statistic";
/controllers
/models
/views
/...
/mySurvey
/config <-- $route['default_controller'] = "mySurvey";
/controllers
/models
/views
/...
/css
/images
/scripts
/system
/...
/index.php <-- $application_folder = 'mySurvey';
/admin.php <-- $application_folder = 'admin';
/Statistic.php <-- $application_folder = 'statistic';
What I did was just duplicate the Application folder and rename to admin, statistic and mySurvey respectively, I set the default controller as stated above.
all application base_url() = 'http://survey.myhost.com' which is a sub domain under myhost.com
The root index.php is actually CI application environment which allow user to go to mySurvey application by default, when they enter "http://survey.myhost.com".
From the first page on, when I access http://survey.myhost.com/index.php/mySurvey/index/0
I got error:
`The specified CGI application misbehaved by not retruning a complete set of HTTP headers.`
The same message shows when I access http://survey.myhost.com/admin.php/admin/login or http://survey.myhost.com/statistic.php?statistic/chart/1 (note that I also do use query string for my application)
Obviously, these have to do with the route. I do not have any .htaccess file at the server because WAMP does not need it, Appreciate if anyone can advice where can I put the .htaccess file and what is the correct mod-rewrite for the structure above and is this structure appropriate.
Regards,
KK Gian
root
/subs
/survey (survey.domain.tld)
/application (CI application folder)
/config
/models
...
index.php (CI index.php file)
/statistics
/application (CI application folder)
/config
/models
...
index.php (CI index.php file)
/mySurvey
/application (CI application folder)
/config
/models
...
index.php (CI index.php file)
/system (CI system folder)
in every index.php (subs/survey/index.php, subs/mysurvey/idnex.php, subs/statistics/index.php) you will link at root/system/ folder so
$system_path = '../../system';
now you can easily go to survey.myhost.com, statistics.myhost.com etc. remove index.php, admin.php strings from url ($config['index_page'] = '';)
hope I got what you want
sorry for my english

.htaccess Redirect request to files exts in particular folder only

How do you write rules to redirect all requests to *.php and *.html files in upload/ folder to a text file name forbidden.txt in root www folder. What I'm trying to do exactly is preventing script execution in this dir by redirecting those requests to the text file
Note: The upload/ folder is accessibly by ftp used by a group of people to upload files so I cannot place htaccess inside this folder.
Create an .htaccess file at the root level of your site containing
RedirectMatch ^/upload/.+(html|php)$ http://www.yoursite.com/forbidden.txt
You could also try switching off the PHP engine in that directory by creating an .htaccess file in /upload/ containing:
php_value engine off
although you would need to ensure that people cannot upload files with the name .htaccess
Put your htaccess rules in httpd.conf instead.
If you can't edit httpd.conf, then your best bet is to not allow web access to that directory at all. Let FTP users access a folder outside of your web directory and then provide a mechanism for retrieving the file contents.
You could name that directory "upload". Then you could have your .htaccess file make requests to /upload/myfile execute upload.php, which finds ../upload/myfile and spits backs its contents. This way it would appear to users that they are accessing the "upload" folder directly, but you would the level of control you want through the PHP script.