How to swap from XAMPP to cPanel - php

I have a php website that I wrote and is functioning with XAMPP. I would like to transfer this to use cPanel. When using xampp, I had to put all of my files in htdocs folder for it to work properly. What is different now that I am using a different server?
I believe that I have finally figured out what my problem is. I am assuming too much.
When working from xammp in eclipse with localhost/project, if I want to add a file "test.php" I simply add it, save it, and then when I type localhost/project/test.php, there is it. This does not seem to be how cPanel works. Do I need to manually update it somehow? If so, how do I do this?
Also I am using mysite.com/~lamar/test.php which is how it is set up in cPanel. test.php is in S:/Lamar/www/test.php. This may also be the source of my problem.
Any ideas? As of right now I cannot even access any page of my project

Depending on your host, you may need to look for a specific folder, although many times you can just put your files in the root directory that you're taken to once you FTP into the system.
If you login and see a www, htdocs, public_html, httpdocs, or html folder, place your files there.

With CPanel you have to put your files into the public_html folder. As said in the comments, depending on your hosts configuration, it might another folder - in your case www.

The problem that I was having is that Eclipse was not updating to the server. So no matter how much I changed in the files, they were not being reflected on the site. I am using Dream Weaver now instead.

Related

Files not loading on php file

I'm having a few problems when I upload my design to my hosting.
Sometimes different things won't load css files, images, jsfiles, etc.
This makes it so my design looks like this. I've checked all my file paths, and they all are correct.
Sometimes my index.php won't even load.
Here's a preview.
Here's another preview when I refresh.
Thank you for the help.
I have contacted my website hosting. They have restarted the server and everything is working now.
The problem would have been that there were 2 servers running on one or something they said. I have no idea what they were talking about. But it helped!
Thanks to everyone who helped out!
If you have Linux Hosting, then the references for css, images, javascript files must have the same exact name. It is case sensitive.
E.g., Style.css is different than style.css and style.CSS for Linux hosting hence it will not load those files and will give file not found error.
And it applies to folder names as well. E.g. if logo.jpg is in a folder named "Images" then reference should have "../Images/logo.jpg". And if you have "../images/logo.jpg" then you get "File not found".
Option 1: Use Xampp
www.apachefriends.org/de/download.html
But if you do, download the version 5.5.38, it works better than the new version.
After installing, close applications that need Port 80, start the Apache, and pull your folder with your stuff in "C:\xampp\htdocs".
localhost/"yourfilename" is the domain you could use it.
Option 2: Use a virtual machine and install a linux server.
Virtual Machine Download
Ubuntu Server Download
Now you can install your Server and open it.

Changing directory paths of links in one place

I've got a website which I need to move across to another server, however i've got a problem with the directory paths and how they've been setup throughout the whole site.
So on every page, there're includes that look like the following
<?php include($_SERVER['DOCUMENT_ROOT'].'/views/includes/header.php'); ?>
This setup works perfectly fine on its own server because the DOCUMENT_ROOT is fine, however, the issue i've ran into is that i've just brought this down onto my localhost where the DOCUMENT_ROOT is
/Applications/MAMP/htdocs
when i need it to look like this
/Applications/MAMP/htdocs/website-name
Is there anywhere in the Perch CMS or .htaccess where i can perhaps change the DOCUMENT_ROOT or otherwise without having to amend every single link?
Thanks.
If you have mod_rewrite activated in Apache, you could use a rewrite rule in .htaccess.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
$_SERVER is a global variable. You could also override it in an entry point PHP script.
I guess you're using the free MAMP where setting up hosts is a manual task? Now you're running the site in a subdirectory of the root, right?
I strongly recommend always running the CMS in the root. Running CMS in a subdomain is always trouble, in my experience. Also, you want your local and remote setup to be as similar as possible.
With MAMP PRO it's very easy to set up multiple roots, it's a good investment to avoid the hassle with manual apache configs. Works flawlessly.

MAMP moodle project

I am working on a moodle based project, which I inherited from someone else. Having copied the files into htdocs folder and started MAMP, the files still don't show in the browser. Instead, the browser automatically initiates a download. I might be required to change the config file, however, since I do not have much experience with php and SQL I am not sure what exactly. My part of the project is to develop html and css, but need to be able to run it locally first.
What do I need to do to get the files run locally? The route I use is localhost:8888/whatever/whatever/index.php
In case someone else runs into the same problem - Apache downloads php files instead of reading them - here is what helped me.
.htaccess file may need changes if the application has changed servers.
Delete (at least rename if you don't want to remove it) config.php and run the application through the browser. It should initiate install automatically.
To run php and SQL I used MAMP.

"Target folder cannot be created" when trying to make Netbeans copy sources folder

I'm trying to test a php app I'm working on in my Netbeans environment, and so I'm setting it up to run on a local Apache server. It seems to work fine when I manually copy my project into the htdocs folder, but when I try to configure Netbeans to automatically copy the sources, It tells me "Target folder cannot be created". I've tried changing the folder from read-only, including everything mentioned here but it doesn't seem to stick (Probably relevant to mention that I'm on Windows 7)
I could just keep manually copying it every time I want to test it, but that would be a major headache. Any ideas?
As I had guessed, it was a Windows permissions issue. After doing pretty much the same thing over and over without the change sticking, it finally stuck, and I was able to get things working the way I wanted. Sigh...

cant run php files in a folder on windows 7 webserver which was previously created on xp webserver?

im doing a php project. all is fine doing it in xp webserver which im using iis..but now i have set up a new pc with windows 7 and iis.
problem is when i copy my php files which is in a folder(e.g portal1) from the xp wwwroot to the windows 7 wwwroot, i cant access it on the browser. it returns an internal server error.
now i assumed i didnt properly set up my web server or even php. i have done it a dozen times following tutorials and im pretty sure its all correct.
i have done a further research on the folder itself and has led me to a theory that this has to do with permissions.
when i copy directly the whole thing,it wont run, BUT if i CREATE a folder and the subfolder with all the same names as the one i copied and just take the php files and put it accordingly, it runs ok!!
now that has something to do with inherited permission i think. how do i overcome this?
i dont want to everytime take the updated work folder from my partner which is done in xp and i have to create new folder and its subfolder with all the same name on my machine and then copy the php files accordingly. thats a lot of work!!
i just want to copy the folder and put it in my wwwroot folder and run it on the browser without problems. how do i overcome this permission issue?
any ideas?
By the sounds of things, you're working on a project with someone else. Copying & pasting is the absolute worst way of sharing files when working on a project with multiple people. You should really be using versioning like git. That's pretty hard to set up and learn though. An easy solution which will work for the time being (but won't manage conflicts well) is to use Dropbox. Set up a free Dropbox account, and create a folder in that called www or whatever you want. Then install WAMP (way better than IIS), and create an alias to the www folder in your Dropbox. Do this on both machines. Now every time your partner makes a change, it will be instantly reflected on your machine, and vice versa. Easy, free, and will work while you learn a versioning tool.
I know this doesn't address your actual problem, but it should be more helpful to you.

Categories