Deploy CakePHP application to webserver - php

I am having trouble deploying my CakePHP application onto a shared web server. Here's what I've done:
1) I zipped the application from my local machine: application.zip
2) I then uploaded the zip file on to my public_html on the server and extracted it
So now my application sits at www.mydomain.com/application which works fine, but once I move the contents of the application folder onto public_html (so that my application sits at www.mydomain.com) it doesn't load the application properly. It only loads SOME of the links of the home page and none of the styles.
So to sum it up.. the app works fine right after extracting to public_html/application/
But once I move the contents of the application folder to public_html it doesn't work.
How am I supposed to set up the folder structure so that my application sits at www.mydomain.com?
Any help would be greatly appreciated.

I just happened to try deploying a Cake app in the same way to a shared server using CPanel and had exactly the same problem. What I discovered is that somehow (I think when I extracted the zip to the public_html directory there was an empty .htaccess file that didn't want to be replaced) the .htaccess file in the root of the application was empty.
Just make sure the .htaccess file in the root of your application (i.e. in public_html) contains this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Worked fine for me and I'm all set now!

You could also try deleting cache files in app/tmp/cache
Not the folders but the files in the folders

Related

How to deploy a Laravel-Vue project on shared server (GoDaddy)

This is the first time I am developing a Laravel Vue app. When I use php artisan serve, everything works fine. But when I load it with http://localhost/myProject/public, assets are not loaded. My images are in img directory inside public folder. I was using blade templating to manage this issue when I use Laravel alone. But now I can't use blade since it is a Vue component. How can I run the project without php artisan serve? My Ultimate aim is to deploy the project in godaddy shared server. Please help me.
Debug your application using 'php artisan serve' while you develop from your local machine.
When you publish it into godaddy,
compress the project folder (say 'my_project') and upload the zip file ('my_project.zip') to 'public_html' directory in godaddy.
unzip the folder.
Now the directory structure will be 'public_html/my_project...'
you will have a 'public' directory inside 'my_project'.
Now create a subdomain which points to the 'public' directory.
That's it. Now load the subdomain.
The assets and api's will work perfectly.
just rungit clone [your_project_address] in the www folder and then run 'php artisan migrate', of course, you should have configured well.
#ThasheelApps this is your solution to access api's.
Create a .htaccess file in root folder and paste the following code there:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This issue occurs many times due index.php in url. if you try your api endpoint including index.php, it will work perfectly. to prevent this issue we need to follow above soution htaccess
Follow these steps:
zip your project after npm run dev and php artisan serve without
any error.
Go to your shared hosting location and outside fo public_html
make a folder name say myproject. Inside this folder extract all
your project files.
cut your public folder from project folder on root, go to your
subdomain folder under public_html and paste.
go to index.php inside public folder and
require DIR.'/../vendor/autoload.php'; and
$app = require_once DIR.'/../bootstrap/app.php'; pointing to your project location on root.
That is all. Enjoy, if you have properly created and attached your DB to your project.

How can I upload my local Laravel web project to server?

I work on a website which i made from Laravel and now i need to push it to the server and go live. I'm new to Laravel hosting. Earlier I did coding by pure php and those days i just push the project to server and it works. My server is one.com and this is what i get when i copy my content and try to access the page.
please help me on this manner! thank you
Option 1: Use .htaccess
if it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Laravel has an Entry Point (which is the index.php File). This File lives inside the public folder. To go L-I-V-E with a Laravel Project, you have to set your Document Root to point to the public Directory.
Right now, you can only access your Site by navigating to: http://van.lesthi.com/public/
At the moment of this writing; accessing the URL above throws somewhat of an SQL Error, which you may want to fix first....

Moving Laravel Project to a Sub Directory

I am a newbie to Laravel.
I want to upload Laravel project from local to shared hosting server.
Scenario is like below:
I have a site (abc.com).
I want to deploy Laravel project inside this site so that URL will be like abc.com/xyz
I have moved Laravel project files and folders inside xyz folder.
But site is not running.
What paths needs to change and in which files?
Please help.
It will run as abc.com/xyz/public
This can be done, but keep in mind that having the Laravel files in your web server root is not recommended.
How you can accomplish abc.com/xyz:
In folder xyz where laravel is installed you can add this in a .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Again, this setup is not recommended, because the Laravel files should never be in or above your root.
A better way would probably be to install Laravel in the dir below the root and set xyz as your public directory. You would just have to change the paths in index.php to make sure it searches for the Laravel files below your web root.

Why should we keep index.php in the public folder instead of in the root?

I still don't quite understand why we must keep index.php in a public directory instead of in the root directory.
root/of/project
public/
index.php
.htacess
(html, image, css, etc)
Then, write the following in our virtual host file:
DocumentRoot /path/to/myapp/app/public
<Directory "/path/to/myapp/app/public">
# other setting here
</Directory>
The .htaccess file then redirects all non-existing URLs to index.php:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
I notice that most frameworks do so, such as Symfony and Zend, just as this tutorial. What is the actual benefits really by having the trouble of modifying the virtual host file?
Why shouldn't we do have this below instead without modifying the virtual host file? Is it a security risk or something?
root/of/project
index.php
.htacess
public/
(html, image, css, etc)
If keeping index.php and modifying the virtual host file is better, how can we modify the virtual host file in the live server then? Let's say I have this domain name, http://my-website.com/ and I access it on my browser, what I see first is not the web page but the directories below untill I click the public directory then I see the home page,
root/of/project
public/
index.php
.htacess
(html, image, css, etc)
I assume that this is the same for Zend or Symfony project as well without being able to modify the virtual host file in the live server. I am no good at these frameworks, I will see this below if I upload my Zend project to the live server,
So, how do you deploy your Zend or Symfony project to your live server to see your web page right away?
It is a very good idea to keep index.php outside of your project root directory because of one simple reason:
You don't want your user to access any files other that one in public folder (index.php, css, js etc). When you will put index.php in root folder you will be also able to access composer.json file for example which is a security risk - a potential hacker will know what packages are you using, in which versions so it's easier for him to perform attack.
When it comes to your hosting - you should have some public_html folder on your root directory which is meant to be public folder (web) of your Symfony app and you should also be able to keep files outside of public folder. If you don't - you really need to think about changing hosting partner
EDIT:
Answering your comment. Let's assume you have public_html folder on your hosting and you want to deploy Symfony app which should be accessible directly on http://your-domain.com. Then you should put whole Symfony project anywhere (but outside of public_html folder) and make a public_html folder a symbolic link to web folder of your Symfony project. This action is equivalent of editing virtual host and changing DocumentRoot which, I assume, you are not able to do.
You can also check my answer on another question to get more clarification

How to configure laravel to use on hoster One.com

I recently created a website with laravel 4. I used XAMP to test my website on localhost and to make it easier I created a virtual host in the vhosts file which points to the public folder of my Laravel app. The website is working perfectly.
Now I rented a webspace at One.com hoster. I opened the webspace with ftp and when I came on the "root" but there weren't any folders so I guess that the root location is the public location? I don't for sure.
The normal structure of a Laravel app is like this:
--> app
--> bootstrap
--> public
--> vendor
--> other files
This doesn't work because I think that One.com doesn't use a public html folder. I tried to make it work but unfortunately. I moved the contents of the public folder to the root of my domain and moved all the other folders in a folder named core. Then I changed some config files index.php and paths.php but still it doesn't work.
The question is what do I need to change to my folder structure to let it work on this One.com webserver and which files I need to adapt (.htaccess, paths.php)? I would like to protect my private folders of course.
Thanks in advance.
Just place .htaccess file in the root folder with data below:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
one.com does use a public_html folder because that's where your files are served from. What you can't get to is your home folder. Xampp is a windows package - have you made sure your filenames follow case conventions? Windows being case insensitive, and Linux being sensitive.

Categories