Okay so basically, I switched my DocumentRoot in Apache2 default to look like this:
DocumentRoot /home/scott/MySite/
That works. I have a file called index.php in that root.
I created a Zend Studio project, pointing to /home/scott/MySite/, and was able to create my project use this line as it's source, modify the .php file and see the change when I navigate to localhost in my browser.
Now, in Zend I created a folder called 'Index', and placed my index.php file in there, because I want to separate my files in the project to things like Database/, Index/, Login/, etc. all different folders. Now, when I navigate to localhost, I get:
You don't have permission to access / on this server.
When I place the index.php file back in the main root it works fine again.
I tried changing the apache2 default DocumentRoot to look like this:
DocumentRoot /home/scott/MySite/Index/
But that doesn't work either. Is there a way to get all this to work and have like my folder structure be able to separate all the logic for the project as well as apache2 still find my index.php and be able to call all the files it calls correctly?
Thanks guys.
Apache is run by www-user which doesn't have the rights to read you home folder. The quick and dirty solution will be to set the persmission to 777 for you home folder
Related
guys I have a laravel project and its working fine. Every time I start the project by typing the command php artisan serve and then by typing the url localhost:8000 in my browser. But now I want to start my project only by typing the url localhost/projectname.
So I did a little bit of digging and found out a way to do this, I made it possible by changing the server.php file from root directory to index.php and copying the htaccess file from public folder to root directory`. This way my browser loaded only html file or php file but css files and js files were not loaded so I had to modify there link on the blade file for example:
Previously a style.css file was linked as:
<link rel="stylesheet" type="text/css" href="{{asset('front_end/assets/css/style.css')}}">
Now I link the same style.css file as below:
<link rel="stylesheet" type="text/css" href="{{asset('/public/front_end/assets/css/style.css')}}">
And It works fine.
But now I have found another problem, I have stored some files (images) in the the storage/app/public/myfolder directory so to access the files I had to use the command php artisan storage:link command and to access the files(images) from above mentioned directory from blade file I use the code below:
<img src="{{$url = Storage::url('myfolder/'.$company->logo_name)}}">
This code did worked only worked when I used to start my project using php artisan serve command. Now I its not linking so what should I do? And also can you guys tell me the way that I changed the server.php file to index.php is the right way or not? And what you guys do in your real projects?
Thank You.
When deploying a Laravel project you want your nginx or apache configuration to point to your public path of your project. Changing the server.php or index.php files are not necessary.
Apache Config Example:
<VirtualHost *:80>
ServerName project.dev
DocumentRoot "/home/vagrant/projects/project/public"
<Directory "/home/vagrant/projects/project/public">
AllowOverride all
</Directory>
</VirtualHost>
As you can see with this apache config example, it points to the public directory of your project.
You can achieve this locally by installing either Apache or nginx on your local machine.
I would recommend following Laravel's documentation guide on using Vagrant's Homestead to get an idea of how this is working before you decide to run this on a server. A link here
There is a couple of options you can take to achieve essentially the same goal. This depends on the machine you are running on and personal preference.
Laravel Valet for Mac
Laravel Homestead
WAMP for Windows
MAMP for Mac
You don't need to modify any file.
You need one of this:
Web server installed locally, Apache or Nginx
A Vagrant Virtual machine for running the project like in production environemnts like Homestead
Valet
If you decide to go with Web Server, you just need to consider to point to project/public folder instead of project.
Doing with one of this options, you won't need to modify the assets url, since public shouldn't be part of your url in any case.
First of all, don't do any tweaks in server.php file, it's fine.
To run your project with url like, http://localhost/my-project.dev or simply my http://project.dev, use WAMP or XAMPP (if working on a windows machine) and lamp for linux. You can also checkout Laravel's Homestead.
Then setup virtual host.
See this tutorial for setting up virtual host on WAMP - http://www.coderomeos.org/how-to-set-up-virtual-host-on-wamp-server
And don't put your assets in public/assets folder to prevent using storage link.
I am trying to change the file directory for XAMPP from htdocs to a different folder. I did go into httpd.conf and change the directory in there like I saw to do from other posts, but it did not work.
When I tried to go to my file from localhost in my browser it would show the folders in the folder, but when I clicked on one, it would say "object not found."
I am unsure of the problem.
Other details:
Where I want it pointed to is on a VHD
that VHD is hooked up to sourcetree (idk if this matters)
Thank you in advance
Edit: This is what I changed
DocumentRoot "P:/projects"
<Directory "P:/projects">
Maybe some one know the solution for my problem.
In localhost all works fine.
I bought vps server, install Ubuntu, and LAMP stack in it.
And now copy all files from localhost to live server, threw ftp.
I write ip/public in web browser and I see my projects mine path running well, but if I wanna go to url like ip/public/login it throws 404 error. (Now working only public address)
.htaccess in public folder is good.
Now I find If I write ip/public/index.php/login it works well, but I need that it work like in localhost
Try making a symbolic link to your public folder and using that as the URL of your project. For example, I have a project called inspections in my /var/www/html folder. If I try to access http://url/inspections I get an error:
403 Forbidden: You don't have permission to access /inspections/ on this server.
However, after calling this command:
ln -s /var/www/html/inspections/public /var/www/html/insp
And navigating to http://url/insp the page displays properly and everything works fine.
Another thing to keep in mind is that app/storage need to have write access (at least) in order for Laravel to work properly. I usually just do:
sudo chmod 777 -R app/storage
To activate all privileges and go from there. Hope that helps!
Also did you check if mod_rewrite is enabled on this server?
Maybe Overwrite is not defined for this folder?
Try:
<?php in_array('mod_rewrite', apache_get_modules()); ?>
Or this:
<?php die("Enabled: ". strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false); ?>
And check if Allowoverride is enabled in your virtual host file.
The location of the file depends on the operating system and structure.
It should look a little like this:
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Hi I want to store my php project folder out side apache folder. How can I do that?
I changed my DocumentRoot "C:/sbnproj" like this.
after that I created one folder named mytest.php and write
<?php
phpinfo();
?>
This code on that. But when I try to access http://localhost/
is working but when I type http://localhost/mytest.php is not working. it shows
Forbidden
You don't have permission to access /mytest.php on this server.
Why this happening please help me.
Thanks
You need a trailing forward slash.
C:/sbnproj/
Also, check your paths... if your getting the root page it's working, make sure C:/sbnproj/foldername/ exists.
I'm having quite a weird problem here.
I have just pasted the Yii folder into my htdocs folders and, for some reason, apache can't see one specific folder within the Yii folder, which is called "framework". I.e., when I type http://localhost/yii , apache correctly lists all sub-folder within the Yii folder except for the "framework" folder!
When I try to call this folder directly from the browser (i.e. writing http://localhost/yii/framework) I get a 403 Access forbidden error.
I'm at a loss here, why isn't apache listing one single folder? The folder which it cannot see is no different from the ones it can see.. I've even removed the read-only attribute from all folders within htdocs but to no avail.
P.S.: my OS is windows Vista sp2
I'm not sure why you are even trying to view the framework folder directly. It does have an .htaccess file in it which says "deny from all". Just make sure you have the correct path for the "yii.php" file inside the framework folder set in the index.php file in your web root.
PHP can include files that are inside "deny from all" folders but you can't browse them directly via a web browser.
Try working through one of tutorials from the start:
http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app
http://www.larryullman.com/series/learning-the-yii-framework/