I just decide to start learning Laravel. By following Getting Started most easy solution for me seems to be to start using laravel installer.
So what I did was installed installer globally and then simply created new project via laravel new laravelapi.
After cli prepare it I edited .env file with my database info and changed APP_URL to http://localhost/laravelapi/ (I'm using XAMPP and laravelapi is name of my project). Unfortunately when I opened browser on that URL I just see the files, not a rendered website.
Funny thing is that when i open http://localhost/laravelapi/server.php site load correctly (it's just some trivial laravel default page)
I was wondering if htaccess works correctly I tried to check if my apache has mod_rewrite as one of his loaded module but it was there.
I am really new in it and I obviously missed something important, but I fight here with it for couple hours without any result. Does anyone face this issue before? If so what was the solution?
The Document Root for a Laravel project is the public directory. All user requests should be routed to public/index.php unless the file requested exists within the public directory -- e.g: assets.
You can change the document root for an xampp operated project by following the steps provided in this StackOverflow answer.
Its not good practice to access project through "http://localhost/laravelapi/public"
Probably you will face problems for symbolic links or while hosting your project. It's good to have vHost for your PHP projects.
You can create a vhost for xampp and add document root upto the public directory of your project for Laravel, like as "../Project/laravelapi/public".
Also you can use inbuilt development server command as php artisan serve
which will start your server on "http://localhost:8000".
More helpful links
1. Laravel Documentation - here
2. vHost for Xampp - Here
I got the same issue were two reasons behind the error.
one is not a proper .htaccess file placed in the root directory.
other php version is not compatible with your laravel current version (low PHP version).
You can create another .htaccess file in the main directory which will indicate that your project root is the PUBLIC folder. It will solve your problem.
you can try the sample code below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I had same issue but I solved this problem. When we install Laravel then .htaccess file is in the public folder.
Cut the .htaccess file from the public folder
Paste this file in root folder of project
Related
I have a Laravel web application that works perfectly on my server but when I try to install it locally on wamp, I keep getting this error
The requested URL /rms/public/users/dashboard was not found on this
server.
I have mod_rewrite enabled.
I can't seem to find a .htaccess in /public/ folder.
Download the .htaccess file and put it into your public folder.
Here' the link
And it's better to follow the installation guide to create a laravel project locally, and replace your app and public folder with the ones on server
Have you try checking composer.. sometimes you maybe using packages that are under the gitignore folder so the wont come across... if you do a pull...
For some reason when I create a project in netbeans and go to run the project it also loads the xxamp index file and not the project index file that is apart of the codeigniter installation.
http://screencast.com/t/qOSH80wPgvf
Edit:
Here is my file tree I have right now set up for my project. Why Netbeans creates an important files folder I have no idea for my CI project. I have edited the index file to have the application and system variable to both have the ../system or applicaton as its value. I have changed the Web Root inside the project properties to have a value of public_html and I have also changed the value of the Index File field to say index.php.
After doing this and running the project I would expect to get the default Welcome to Codeigniter page and I don't. I am receiving a message that shows the following. Any ideas on why this is?
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16
Projects
- MyFirstProject
- Source Files
- application
- public_html
- assets
index.php
- system
- Test Files
- Important Files
- Include Path
I've tried doing some additional research on the topic and have yet to come up with a solution.
Edit 2:
Any ideas from anyone?
Your problem is likely related to your choice of folder layout. Which I assume you do, for "security reasons". That said, NetBeans isn't a server. Its an IDE, so you can't manipulate it the same way you would the server.
Most servers by default define your "root" folder as "public_html" or "www" as far as where it looks by default to serve files for public consumption. Through the use of PHP you can tell the index.php that comes with CodeIgniter to look up one directory outside of the defined root and have it read the file(s) accordingly.
However, to setup a project in netbeans and have all files and folder accounted for accordingly you need to tell it that all your files start in whatever folder they reside. So it can load all the files and read from them respectively. This in essence and in respect to server logic is telling it that the folder that houses
application
public_html
system
is the define root path. So inadvertantly by breaking out of the design of codeigniter and placing the core files outside of what would be your defined root on the server is breaking your project. There is not an index.php depicted in your listing above at the same level that those folders are in. If there is, its the index.php for xxamp that keeps loading for you by default.
What you need to do is stop trying to implement your "security measures" and put them in the right order. Or.. not include that folder in your project telling it the one with assets and index.php is the root path. If netbeans is smart enough it will find the files and folders outside like the server will.
Right click on your project and go to properties. Make sure that in the run configuration the URL is correct and the index file is properly set up and matches your directory in xxamp.
after downloading codeigniter open index.php file and there set your path correctly to your
application folder because i think you putted your index.php inside public_html folder so
the path which is set by default in index.php is not working and can not find application folder, try to fix it and it will work fine your problem is not with netbeans.
I can find dozens of articles on installing CakePHP in a sub-directory and getting it to appear in the root url. That is NOT what I am asking for. I rarely down-vote, but if you give that answer, I will down vote you.
I have CakePHP in my root directory on my hosting server. It's a clean Apache server instance... I think. I'm really not a server guy. I created a new account through WHM on Hostgator and have CakePHP sitting in the public_html.
However, there is no domain name associated with this server yet. The URL is like this:
http://123.456.0.0/~example/
And CakePHP gives me the following errors:
Error: ~exampleController could not be found.
Error: Create the class ~exampleController below in file:
app/Controller/~exampleController.php
I imagine there's some .htaccess configuration that makes it ignore that /~example in the URL. Can someone point me in the right direction, even if it's just the right page in the CakePHP docs?
By partially following the advice at http://bakery.cakephp.org/articles/syl-via/2011/09/19/rewritebase_config_for_cake_installation_with_userdir_and_mod_rewrite I was able to make this work by adding the following to the .htaccess file in the root of the Cake install:
RewriteBase /~example
I put this after RewriteEngine on for it to work.
In other words, if your Cake install is at /home/example/ then it's the /home/example/.htaccess file that you'd change.
I didn't edit app/.htaccess or app/webroot/.htaccess because it seems to work without these files needing to be edited.
Please note that I tested this with the latest version of Cake (2.3.5) -- I don't know if it will work the same way in older versions.
I read the docs and installed lithium exactly like they have explained but I keep on getting a 403 forbidden error. I am new to apache and php and I have been spending two full days trying to make lithium work. I am running apache 2.0 on osx lion and here is what I did:
1- I created a new directory called my_app in localhost/~marwan/
2- I extracted the sample lithium app in to that directory.
3- I downloaded the lithium framework and extracted it into /libraries/lithium/
When I access http://localhost/~marwan/my_app/ I get the following 403 error:
You don't have permission to access /~marwan/mj/ on this server.
I have researched and added Options +FollowSymLinks to the .htaccess file and the error changed to:
You don't have permission to access
/Users/marwan/Sites/my_app/app/webroot/webroot/ on this server.
I have tried to add Options +FollowSymLinks to every .htaccess file but nothing changed.
I dont know if this is relevant: websites on localhost/~marwan/ work but localhost also shows a 403 error. I tried to fiddle with different permissions posted in previous answers but with no luck.
Thank you for your help.
httpd.conf file is here http://pastebin.com/jLwHPbuq
Edit:
httpd-userdir.conf is here http://pastebin.com/ZXi51pn7
httpd-vhosts.conf is here http://pastebin.com/3xqRmrzL
Update
The lithium project works when I remove the .htaccess from the main folder but it doesnt work properly because rewriting doesnt work. Here is the .htacces in the project root http://pastebin.com/vt0fVyyL
The path you provide in the error message /~marwan/mj/ and the path you provide that you are trying to reach http://localhost/~marwan/my_app/ do not match. According to the error the web server says you are trying to access a directory called mj while your url does not include mj so unless you are doing some URL rewriting this looks like an issue.
Also, just to be clear, when you say you installed the library in /libraries/litium you mean relative to the web root path, correct?
OK, looking at your conf files you can serve files out of /Library/WebServer/Documents or out of ~/Sites (that tilde represents your user directory so it is the same path as /Users/marwan/Sites)
Do this...
In /Library/WebServer/Documents place a file called index.html and have it output some text.
Make sure there are no .htaccess files in /Library/WebServer/Documents.
Make sure you have not modified your httpd.conf file in any way from its default settings.
Do you see the correct behavior for your index.html (you should)? If not, what happens?
I looked at the error log after restarting apache and found DocumentRoot [/usr/docs/dummy-host.example.com] does not exist so I fixed it by using this answer stackoverflow.com/questions/6671042/… and now it works.
I have a shared hosting account in which I want to install my symfony 1.4 and deploy and application. I bumped into some issues because of the inability to change the apache config on the production server.
the structure of my web server is:
hosting_account_name
html <--- public folder
I then moved all files in symfony local app folder to my hosting_account_name and put the web folder content in html
So i got the following structure:
hosting_account_name
apps
cache
config
data
html
css
js
index.php
.htaccess
frontend_dev.php
lib
log
plugins
test
and i added the line bellow to config/ProjectConfiguration.class.php
$this->setWebDir($this->getRootDir().'/www');
I have a couple of issues though:
1. when i access the frontend_dev.php no images are due to the fact that symfony expects some files to be under a sf/ folder. Should I move the files there?
2. Index.php gives an error. Even with display errors set to yes and 500 internal server error is presented.
Also i had to set my permissions to 777 on cache and log. Their are under the folder html so that's ok for security right?
First, you said that the "public" folder is html, but you used $this->setWebDir($this->getRootDir().'/www');. Is it html or www? (Just to make sure)
Then: setting the sf_web_dir should work like you expected, so that shouldn't throw any errors.
To link the /sf Symfony folder, you will need to add something to your apache configuration. As described on the first page of the Jobeet tutorial, you will need to add an Alias to the /lib/vendor/symfony/data/web/sf.
If you don't have access to the httpd.conf, you could also add this to your .htaccess.
777 for log and cache is ok. It's what the default project:permissions task does as well.