Laravel project on host server - php

I try to deploy my laravel project on host server. So I upload all files contains in my Laravel Project folder on my host server. But when I check with the url, I can't use my project like when I'm on my localhost. I have just the homepage and when I tried to access others pages the server return 404 not found.
I really have no idea what I should do ?
Any suggests, thanks !

There are several things to check while you work to resolve this issue:
Compatible Environments
If your host uses web server software (Apache, Nginx, etc) other than the one that you use in your development environment, check the Laravel documentation for information about configuration Laravel to run with your hosts's web server.
Routing
Ensure that you deployed your .htaccess file. This file lives in the public directory. It is responsible for mapping all of your URLs to the main Laravel router.
Deployed Files
Verify that all of your other files on the host server match the files in your development environment. It is not uncommon to miss files or entire directories when deploying a new project.
Logging
If your problem still is not resolved, get access to the host's log files and examine the errors that are logged when you try to access your site. You can often find a clue in the log files that will lead you to the specific problem.

Sounds like you've deployed it onto a non-apache webserver so .htaccess rewrites are not being used.
If its nginx then you need to add the following rewrites to your vhost configuration.
location / {
try_files $uri $uri/ /index.php?$query_string;
}
http://laravel.com/docs/4.2/installation#pretty-urls

Related

Creating apache alias without access to .conf file

I have a PHP application that is written in Zend Framework. The document root is appdir/public. In appdir I also have a directory called admin that hosts a wordpress website. I would like to be able to map an alias to appdir/admin so that the wordpress website can be reached at website.com/admin. Unfortunately, I do not have access to my apache conf files through my hosting provider. Is it possible to map an alias without access to that? I was thinking in the .htaccess file but after extensive googling, that doesn't look possible either. All help/suggestions are appreciated. Thanks!
I have tried contacting my hosting provider and getting access to the apache conf file, but they wouldn't let me. (SiteGround)
I have tried using the .htaccess file.
Edit: Apache 2.4
Currently you can' use .htaccess to move current directory above document root.

Centralized Codebase with Multiple Websites

I have a CentOS 7.1.1503 (Core) server running with Plesk 12.0.18 and Nginx 1.9.4-centos7.15091112.
I am trying to host the codebase for my web-app at /var/www/vhosts/my-web-app/
Then I want to host multiple websites on different domains that all use the same codebase, ie /var/www/vhosts/my-first-website.com/, /var/www/vhosts/my-second-website.org/
/var/www/vhosts/my-web-app/ doesn't necessarily have to be in /vhosts/, I've not done this before.
So really my aim is to direct all requests to http://www.my-first-website.com that don't point to a file that already exists to actually be pointed to /var/www/vhosts/my-web-app/index.php where I have a parser that will connect to the right database and deal with the request.
I've tried to use the nginx directives section in my Plesk setup as below:
if (!-e $request_filename){
rewrite .*$ /var/www/vhosts/my-web-app/index.php break;
}
But this isn't working, perhaps because the route is already set to /var/www/vhosts/my-web-app/ and so I am in fact trying to redirect to /var/www/vhosts/my-first-website.com/var/www/vhosts/my-web-app/index.php?
Any help would be greatly appreciated!
Try this possible solutions via plesk control panel:
create domain alias name.
or create additional domain with same document root as on first domain.

zend framework 2 project in server doesn't work

Working with zf2, we have configured the project successfully in local env, we deployed the same code to server, but there..only the IndexController action is working.
like www.project.com/public/ works,
but when I access other modules like
www.project.com/public/country doesn't work.
This means the mod_rewrite rules to rewrite all requests to your index.php file are not being used. Generally this means either:
The .htaccess file was not uploaded (check the public folder on the server to see if it's there)
The .htaccess file is being ignored (check AllowOverride for the vhost on the live server)
Also, really public/ should not appear in your URLs. Unless you are using shared hosting (where this can be tricky), you want to point your vhost's document root at the public folder.
In a proper Zend setup an error should come from Zend. When you get an error like this, returned from Apache, your apache configuration is not working. Your Zend application isn't even considered, i.e. the index.php in your public folder.
It's a save guess that your [public/].htaccess isn't used. Check your apache web configuration. Most likely you're missing the AllowOverride All statement which is usually inside the <Directory> statement.
And as mentioned by Tim you really should not have public/ in your path to begin with.

.htaccess file won't respond on localhost:63342 in PhpStorm

I'm using the IDE PhpStorm 7.1.4 and trying to make an .htaccess file to stop users from going into a specific directory.
My folder structure is like this:
I want to make it so that users can't go in the /app folder or any folders inside that folder. For this, I've figured out that I can use this piece of code inside .htaccess:
Options -Indexes
I'm using the PHP web server from PHPStorm itself (which goes to localhost:63342/projectname/folderinproject/etc/etc/).
Problems
When directing to the page to the /app folder, I get an 404 error,
saying the index file doesn't exist.
When I have made an index.php file inside the /app folder, and I am redirecting to the /app folder, it just loading up the index.php.
When doing this with just a normal HTML project and opening the index.html via my windows explorer, the same problem occurs
Question
How can I make it so that my project would actually respond on the .htaccess file and wont allow me or other users to go into the /app folder?
EDIT
I figured out that when I copy all my files from my project to the c:\xampp\htdocs\ folder and turn on my Apache server inside of XAMPP, the .htaccess file is working whenever I open it via my regular browser (without selecting index.php in PhpStorm and choosing Open in browser...).
Is there any way I can do this same thing in PhpStorm without moving all the files?
If you are using the default configured web server, you are actually using PHP's new web server feature, which doesn't listen to .htaccess files. Only Apache listens to .htaccess files.
If you are wanting to test this functionality, you can either setup a VM running Linux and test, or setup WAMP on your system and run from there.
EDIT 1
Ok, can you add a little more detail about the exact problem? When you access localhost/app/ it is displaying the index.php file, instead of the 404. Does the application work entirely through the index.php file? If so, is the index.php file in the app or public?
EDIT 2
Ok, here's what you need to do. Place an .htaccess file in the root of your app directory. Clear the contents of this .htaccess and place the line DENY from ALL. You can keep the .htaccess file in the root of the project.
EDIT 3
PHPStorm is going to use the PHP Engine's web server. If you add the XAMPP location as a deployment path, it's fairly quick to deploy to. You can even setup PHPStorm to automatically deploy files to the XAMPP location on save. Here's the walk-through on the JetBrains site JetBrains Config.
The .htaccess plugins are mainly for editing and formating, not for modifying PHP Engine's server environment.
Using mod_alias is even easier:
Redirect 301 /app /new_directory
But if you have rewrite rules in your htaccess file already, then you need to stick with using mod_rewrite:
RewriteRule ^app/(.*)$ /new_directory/$1 [L,R=301]

.HTaccess Subdirectory Redirect to Different Server

I'm about to start running three different environments of our PHP application - Development, Staging and Production. Some of our customers will get access to Staging to help us test new features with real customers before it his production.
Our application is running on AWS EC2 though an elastic load balancer using HTTPS only. I need a way to allow users to go to https://mydomain.com/staging and be redirected to the staging environment (would still show https://mydomain.com/staging in the address bar, but they'd be getting content from a different set of servers). There will be some code in Staging that will ensure their account has been approved for Staging access and will allow them in or redirect them to the main application.
I can't seem to figure out how to write this in .htaccess. I've tried a number of things I've found online and haven't gotten it to work. I am beginning to think it may make more sense to have a real directory even in the production environment called 'staging' and have an index.php file inside that checks their account and redirects them based on the result.
However, I'd like to avoid having to purchase another SSL certificate for this, so instead of using a subdomain for staging, I'd like to use a virtual directory. Does that make sense?
Thanks in advance.
You need to enable the use of .htaccess in your httpd config file (you can do so by finding the line in your conf file that has AllowOverride None and change it AllowOverride All) and then place a .htaccess in a folder in your html folder called staging with the following line
Redirect /staging http://whereverYourStagingEnvoIs
I would recommend using a subdomain instead of a subdirectory, staging.mydomain.com
Then in your host records for mydomain.com you could point staging to whatever server you like.

Categories