Where should I put a larval project on server directory?
I put my larval file ~/[larave_project_name]
DocumentRoot is /var/www/html/.
I moved public/index.php into DocumenRoot.
But I found In DocumentRoot, Those files can’t load files from outside of var/www
My Server environment is Cent OS7 / Apache 2.4 /PHP 7.4
The intent is for the webserver to have a document root of the public directory within your laravel project.
A good starting point would be:
Move the files from ~/[laravel_project_name] to /var/www/[laravel_project_name]
Update the default for the web server configuration to change the document root from /var/www/html to /var/www/[laravel_project_name]/public
Related
I have created a website in a LAMP using Apache MySQL and PHPmyAdmin, I have migrated this website and is db to a similar configuration but and Windows. And my directory are all mucked up. from index I am able to access any file in root location but if it is in a folder I have to had a ../../htmlwhere I previously had ../I have a lot of folder and a lot of header(Location: ../whatever) using them. How can I fix the directory ?
This is my root in var/www/ :
And this is inside the html folder (var/www/html) :
I have developed a MVC project with Laravel 5.4. Whenever I want to develop it on localhost, I use php artisan serve command to access it via localhost:8000 on browser. Now I have uploaded the project on a linux server with centos 6 and I run php artisan serve --host 0.0.0.0 --port 8080 to access it via x.x.x.x:8080 on browser but it is a temporary way to access project from browser. What is the permanent way to access a laravel project by clients via public IP?
I have apache,php and ... separately installed on my server. I can not see x.x.x.x/projectname/public or x.x.x.x/projectname. The project is in /var/www/html directory.
You can access the laravel project with yoursite.com/projectname/public if you upload your project on web root.
If you want to access it directly with yoursite.com you need to map the public folder in your virtual host configuration.
# The location of our projects public directory.
DocumentRoot /path/to/your/public
On your linux server install the LAMP or XAMP that include the apache server and Mysql and some other related tools into it. Upload the code on web root. Now try to access it with the IP or the domain name like:
XXX.XXX.XXX.XXX/projectname/public
or
or domain/projectname/public
Note: You can remove that public by making a symlink to the public directory or by making a virtual host entry.
Here are the steps you need to do [assuming you are using apache, but its not very different for nginx]:
install PHP, MySQL and apache in your server
place your project in /var/www/ folder
give permission to storage folder of your project chmod -R 777 your/project/storage
edit /etc/apache2/sites-available/000-default.conf file e.g. DocumentRoot /path/to/your/public
restart apache
Please check other answers. They are very good and give you a clear starting point. Just do little research and you will get it.
Laravel's documentation does not explicitly say where to execute "laravel new project_name"? Should it be executed at the webserver's root that is htdocs or www? I use WAMP server in Windows.
It should be executed at the parent folder of htdocs or www.
The laravel folder can't live in htdocs, as it will expose all sensitive files.
After that, you must map laravel_myapp/public to something as htdocs/myapp.
You can also symlink the laravel_myapp/public folder to where you want in htdocs.
Depending on your needs, but I would put it in htcdocs/www because is the default folder configured in apache by WAMP, anyway you can change the documentroot of your server if you want.
As long as you have the right folder permissions and the project is created under your root folder laravel shouldn't have any problem with that.
Hope this helps you :)
I just bought my first mac and I develop in PHP. I run MAMP to serve my php files. You have to save files to Applications/MAMP/htdocs to be able to serve a file. I would rather have one file in the root directory that sends all the files I create to htdocs so that I can access them easier in emacs and such from the command line. How could I do this?
You should check httpd.conf of MAMP. You can change the root folder of you WWW there. Look for the http.conf file in the Apache directory, and then look for htdocs and change that path.
I've set up PHP and Apache for my Snow Leopard machine using these instructions I can change Document Root in httpd.conf such that I can run php files from different local directories. However, when I set it to the the location of my Eclipse workspace, I get "Forbidden - You don't have permission to access / on this server"
I'd like to be able to use the Eclipse New PHP Project to "Create a new project in workspace" instead of creating a directory somewhere else and using "Create project at existing location..."
What am I missing?
You need to modify corresponding <Directory path> directive. You already have this directive for previous DocumentRoot, so just change path in there to your current document root.