How to upload laravel 5.5 project to cpanel in addon domain - php

This is Bablu Ahmed. I want to upload my laravel 5.5 project into cpanel and my domain is an addon domain name is w3public.com and it's root directory is not inside the public_html it is outside the public_html (www.w3public.com). I have separated the project's files into two directories, one is www.w3public.com and another is laravel and I moved public folder's files into www.w3public.com and all other files into the laravel folder in cpanel that is given in screenshot below. I have also modified the index.php file of www.w3public.com as follows:
require __DIR__.'/../../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
But it is not working. Can anyone help me with appropriate solutions?
Screenshot:

Your application should be installed in www.w3public.com and then change the root path from cpanel domains to the public folder inside laravel.
The best way to transfer files is git or the likes, but if they don't have it (usually is the case in shared hosting), you should use a ftp client, and if they don't allow that either, you can upload files/folders from cpanel (way too slow sadly).
If you use git be careful since by default vendor folder is in the .gitignore (you have to run "composer update --no-dev" after all the files are transferred)
Make sure also that your ".env" (usually in .gitignore too, so you prob have to make one) file have your server database info.

Related

Yii2 configuring to use vendor folder in an external http storage

I have multiple restful apis build using yii2 framework, What i wouldlike is to use a single vendor directory stored in a different address
That is
I have an application hosted at www.example1.com and another one hosted at www.example2.com and the one i would like to contain the vendor files to be at www.example3.com so that in both example1 and example2 i only have to upload the resful folder without vendor directories
After some looking into yii2 advanced folder i have found these lines in index.php
require(__DIR__ . '/_protected/vendor/autoload.php');
require(__DIR__ . '/_protected/vendor/yiisoft/yii2/Yii.php');
Ive tried as a work around by doing
require(__DIR__ . 'http:://example1.com/pathto/_protected/vendor/autoload.php');
But the above fails, How best can i achieve this
You can't do it via HTTP.
The only solution is to create shared, NFS volume, which will be mounted on both servers as your vendor/ directory. After you will be able to use the same vendor dir for two servers.
If those two sites are deployed to the same server, it might be easier.
It is very simple .
you can just copy the vendor file into your next project and change the two lines of required file path (autoload.php & yii.php) to the correct vendor location.
the /config/web.php. add vendorPath to the config with your vendor directory.
As the vendor is moved from /var/www/html/myapp/vendor to /var/www/html/frameworks/yii2, you will find problem installing a new extension or updating the existing through composer command. To fix it, modify your composer.json (right under your project directory) by adding the vendor-dir attribute under the config section, eg:
// other settings ...
"config": {
"vendor-dir":"your path",
"process-timeout": 1800
},
// other settings ...
Also, you may find "a man-in-the-middle attack" message when either update or install the new extension (i don't know if there is a relation to the modification of composer.json but i get it several times during experiments). To fix it run composer update --dry-run. then it would ok.
This can be done: Include through http.
You need to set some php variables (allow_url_include, allow_url_fopen). And you need to get rid of __DIR__ constant in front of your php file path:
require('http://example1.com/pathto/_protected/vendor/autoload.php');
BUT
Don't do this. Really. You don't want to go through all these unsafe php setups. And you don't want to expose your vendor files to all the people in the world. If your script can access php source code via http, everyone can. Also, includes over http will be extremely slow.
The (probably) only solution
If you really want to share core php files between multiple websites, you can purchase virtual server, set up both websites on it and create one folder accessible from all websites on this server.
You don't even need virtual server, you can go with some kind of multihost service with custom folder for each website and shared folder for core (vendor) files.

move laravel to live web

Hi I have my website which its my resume and now I want to show the project that I have done one of my project is laravel and I move it to: public_html/laravel
and also move my DB to there but I get this error:
403 Forbidden
You don't have permission to access /laravel/ on this server.
I don't understand is it because of I didn't put files on main public_html and move it to folder or other stuff I also changes(i don't know if its right) change config/database.php mysql part to database configuration but I keep getting this error
Laravel server files from the public/ directory. So try a URL like this instead:
http://example.com/laravel/public
If that works, you'll need to move some files around a bit. This should help with moving things around:
How to change public folder to public_html in laravel 5
If you use shared hosting then please do not uplaod whole laravel application to the publitc_html folder. You have to upload your all application at global document root for your domain like home/yourdomainand you have to rename existing public_html folder to any name and rename laravel public folder to public_html and try again. See the image below:

Affect on security of Laravel 5 when change folder structure to remove public folder

I'm new in Laravel 5.
I found this Laravel 5 - Remove public from URL on Stack Overflow to remove public folder from my Laravel 5 App. Only I have a question about the security.
When I am removing public from URL, then I have to change the basic folder structure of Laravel 5. Yes, it's working fine without the public from the URL.
But what's about the security of Laravel, because I am changing the default folder structure? Is it secure to use?
You should be pointing your Apache host root to the $LARAVEL_PATH/public directory instead of $LARAVEL_PATH.
The point of having sub directory for www host root instead of project root is that you're not leaking any of your project files through your web server.
Even though all the PHP files have the file suffix .php, malicious user can access your $LARAVEL_PATH/storagedirectory and its subdirectory contents, read your composer.json or package.json to find vulnerable dependencies or read .env file etc.
If you're running on shared hosting and you have mandatory public_html, try installing Laravel outside of that public_html directory and either removing public_html (if empty) and replace it with symlink to $LARAVEL_PATH/public OR if you want the Laravel instance to be subdirectory ofpublic_html, do the same but create symlink from$LARAVEL_PATH/publictopublic_html/$PROJECT_SUBDIR`.
That public directory is there for reason to make project a bit more secure. Solve the actual problem and don't try to break this simple but nice security addition. :)
you this link you provided is not about changing the actual file structure of the framework, this example uses mod_rewrite to rewrite the url of your application. In other words you are telling your server that you would like to point to that directory without the full path is visible to the end user.
Also take a look on the below answers of the link you've provided.
Rename the server.php in the your Laravel root folder to index.php and
copy the .htaccess file from /public directory to your Laravel root
folder. -- Thats it !! :)

Laravel 4 - class not found on live server

I'm uploading my laravel 4 app to a testing server which is shared hosting.
I'm uploading to a password protected directory which has a .htaccess file within it. My subdomain points to the public folder.
For the most part they app is working as expected I can log in, view most of the pages however every class that I have created such as a helper class and additional controllers are not being found on the live server yet all works on my local environment.
I've redone a composer dump-autoload and uploaded the composer.json file
I'm not sure where to start with this.
In my upload I've included all the files and folders to the live server (twice now). I read somewhere else I should namespace my classes but why would this help if the main laravel controllers do not namespace?
Confused - all help appreciated
When you do a composer update, if Composer finds anything new it will update some files in the folder
vendor/composer
Like the file autoload_classmap.php.
So, you have to reupload at least this folder too.
Maybe it's about git, you are pushing changings with some certain case sensitive Folders and Files, but git is changing this therefore it will work on Mac and Windows OSs but not on the server.
just use this command:
git config core.ignorecase false
above command for the current repository and you may add --global just after config keyword.
please note that ignorecase option available since version 1.5.6 and I assume you are running 2.0.x but just mentioning!

Setup Projects with CakePHP

If you setup your document root as C:\xampp\htdocs\ and you create a project folder named "ProjectX" where you include all your project files and folders and subfolders, how are you going to make your project runnable with url "http://localhost/projectx" ? I would like to learn how your config and routes files you included in your projects are changed ?
you can refer below link
http://book.cakephp.org/1.3/en/view/912/Installation
cheers
I would not run them as "localhost".
If you link css/js/img absolute to the / root, you will run into problems later on your life server.
it is always best to use virtual hosts and simulate the "real life" on your system:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
You can create a folder projectx in C:\xampp\htdocs\
Then copy all the CakePHP files in C:\xampp\htdocs\projectx\ (including .htaccess, app\, lib\ and all. Setup the salt, cypher, db files and you should be able to access it through http://localhost/projectx/

Categories