Where to upload my PHP files on web hosting server? - web-hosting

I have a GoDaddy web hosting account with a cPanel access. I am trying to figure out where should i upload my php files.
I have created a new folder inside the public_html folder as fortnox_invoicing and have copied all the code (PHP/HTML/JS) files in that folder.
But when i try to browse the php files it doesn't work instead i get "ops, this page does not exist" message.
http://example.com/fortnox_invoicing/index.php
Following is how the public_html directory looks like for now:

You can upload your PHP files in public_html if you want to browse your website like:
http://example.com
You can also upload PHP files in subfolder if you wish to browse it like
http://example.com/subfolder
If you are receiving error 404 while browsing subfolder, locate .htaccess file and check if there is any rules that are restricting index.php to load and causing 404 page. If .htaccess file is hidden, you'll have to enable the show hidden file in while opening cPanel File Manager. Try renaming .htaccess file and load your website again. Also make sure that root folder contains index page and it is listed as default page in .htaccess file.

You see this page because your website doesn't have "index.php" or "index.html" file in public_html folder.
for example
-public_html
-index.php
**-subfolder**
-aboutus.php
-contact.php
-service.php
**-subfolder**
-thankyou.php
Most service providers use the above hierarchy.

Related

Laravel 9 error "Vite manifest not found" on production server

I am deploying Laravel 9 project to shared hosting (without the ability to ssh into the server so I can't npm run build in the server) and I am getting this error:
Vite manifest not found at: laravel_project/public/build/manifest.json
I am using FileZilla to upload the project to the CPanel, I uploaded the public folder into public_html and configured the index.php file.
Before uploading the project i run npm run build locally on my localhost and everything works ok there.
Does anyone have a solution for this ?
I tried changing the APP_ENV=production but it didn't work.
so I found a solution for that which is:
put all my local laravel files and folders including the public folder (of course after running composer install and npm run build locally) inside the public_html directory in the server
now inside the server in public_html directory move the two files .htaccess and index.php of the public folder one level up in way so that the index.php file and the .htaccess file are directly inside the public_html directory (this way you don't have to include /public in your url but instead access the application directly when you visit your website)
configure the content of index.php you just moved from public up to public_html in a way that its links point correctly to the content of the app inside public_html
for example:
__DIR__.'/../storage/framework/maintenance.php'
becomes
__DIR__.'/storage/framework/maintenance.php'
so that the /.. is removed
and the other links too like:
__DIR__.'/../vendor/autoload.php'
becomes
__DIR__.'/vendor/autoload.php'
and
__DIR__.'/../bootstrap/app.php'
becomes
__DIR__.'/bootstrap/app.php'

117/5000 Uploaded file to public_html in cpanel

I tried uploading the first laravel projet in cpanel, when uploading image files can't enter public_html as I marked red, and I have changed the index.php file as shown below.
cPanel public_html
index.php
You should use Composer (and git) to deploy your project. Here's a guide that works well for shared hosting: https://github.com/petehouston/laravel-deploy-on-shared-hosting

Upload Laravel 5 to server subfolder

I am trying to upload Laravel 5 project to subfolder as:
public_html/project/
I have changed in index.php
require __DIR__.'/../project/bootstrap/autoload.php';
$app = require_once __DIR__.'/../project/bootstrap/app.php';
in config/app.php
'url' => 'http://example.com/project',
when I try url as:
http://example.com/project/public it is directed to
http://example.com/public
What is the way to upload it to server. Can anyone help me as I have tried lot options.
It is not a good idea to upload your entire laravel project in the public_html (public)folder. The files in the public folder are having unrestricted access.
If you are constrained to think about uploading the laravel project to the public_html folder because you want to upload to a shared host, then it is not necessary to do so.
Instead try this:
1. Create a folder called laravel (or anything you like) on the same level as the public_html folder.
Eg:
/
|--var
|---www
|----laravel
|----public_html
2. Copy every thing except the public folder from your laravel project in the laravel folder (on server host).
3. Open the public folder of your laravel project, copy everything and paste in the public_html folder (on server host)
4. Now open the index.php file in the public_html folder and:
Change:
require __DIR__.'/../bootstrap/autoload.php';
To:
requrie require __DIR__.'/../laravel/bootstrap/autoload.php';
And
Change:
$app = require_once __DIR__.'/../bootstrap/app.php';
To:
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
Save and close.
5. Now go to the laravel folder and open server.php file
Change:
require_once __DIR__.'/public/index.php';
To:
require_once __DIR__.'../public_html/index.php';
Save and close.
Now when you visit the url which you configured as the domain with your server, your laravel app should work just as it worked on your localhost.
Note: The 'url'=>'someurl' in the config/app is used by artisan ie the cli, it does not have any effect on your webserver urls.
Hope it helps.
Edit
After completing the above if your get a blank page when you try to visit the url, set write permissions for the storage folder recursively .i.e all folders within the storage and its subfolders should have permissions 775 set for the webserver owner and group to have write permission.
You can also set the permissions as 777 to give read, write and execute access to all for the storage folder if you don't plan to store any sensitive information in the storage folder.
Be careful with the file permissions in linux, they are like double edged sword, if not used correctly, they may make your app vulnerable to attacks. For understanding Linux file permissions you can read this
After I completed the above steps. Do check with read/write permissions(i.e it should be 777) for few folcers:
storage, vendor and bootstrap>cache
Check for .htaccess file if it is there in the public_html folder or copy it from public folder.
Finally check the version of php it should be higher than 5.5
It worked for me. Cheers!!
Issue Fixed:-
Go to laravelFolder/bootstrap/cache then rename config.php
eg. config.php_old and reload your site.
I did like this. (My version was laravel 5.2)
Change the name of server.php file to 'index.php'.
Copy .htaccess file from public folder to main directory(Created subfolder)
And inside .htaccess after RewriteEngine On we have to add
RewriteBase /yoursubfolder/

XAMPP is displaying parent directory

I installed XAMPP on my Windows 2008 server and created a new folder in the HTDOCS folder and the user can access the pages using the link.
For example:
http://1.1.20.305/MyDB/index.php
Will take the user to the index.php page.
But if I enter the following in my browser:
http://1.1.20.305/MyDB/
It displays the parent directory with all the files.
It is a security risk and how do I prevent it from happening? It should auto-route user to the index page or somewhere I define.
I added the .htaccess and .htpasswd file in the directory and the directory is not shown anymore.

accessing image from public_html not possible

I am using Cyberhost.in to host a JSF application. The problem that I am facing is that whenever I am trying to access image files from public_html folder I am getting a 404 error. I have kept my war file in webapps folder. I am using c-panel, the thing is that I want to take backup of files for my website so I have kept them in public_html folder. Initially I was saving the files under webapps/[WAR FILE NAME] but when ever I was trying to overwrite webapps/[WAR FILE NAME] I was getting permission denied error.
You should upload image files on their location that you have mentioned in your code, otherwise you should change the location in website code of the same.
Also check permissions/ownership of files

Resources