So I have an employer who currently operated their website with no testing server whatsoever. All updates to the site are "tested" live in front of the whole world. I don't need to hear about why that's dangerous... I know it is. In fact if this continues for much longer I'm going to develop an ulcer.
I am trying to place a working copy of the svn of the site on my MB pro for testing purposes. The site is all PHP and MySQL so my plan is to install MAMP and run the test copy on localhost.
My employer is worried that by hosting a copy of the site on my laptop I will interfere with the operation of the live site. Is this possible? Is there any way that my hosting a copy of the site on localhost will interfere with the operations of the live website (hosted on a remote server)? Are there dangers in setting up a localhost copy?
Apologies if this is out of scope, hopefully this will be useful to others.
It depends on the site. When I make a site and the database is hosted on localhost / the same server as the web-server, no.
But I have noticed that if you use for example WordPress, you are testing on your local copy one minute and are on the live site the next as the url seems to be hard-coded in the generated pages (in the case of WordPress a setting in the database).
So:
Always make sure the database connection is to your local database (ideally that is just in one place and you don't have to change anything if the live site uses localhost as well)
Look out for links / settings / rewrites that direct you to the live site from your local site.
Related
I have a client who wants me to update their Drupal site. I've never done this before, and I want to work on it from my local machine just in case something goes wrong. I have no idea where to even start!
First off, how do I access my client's site files so I can get them onto my computer? I've tried entering the information the client gave me into Cyberduck, but it won't give me access. Is there another way to get access?
Also, how do I host it locally? I have XAMPP, but I'm not sure how to use it.
That being said, I have found a few forums that should help me set up the local server. I just don't know how to get the files from the live server to my computer.
I know this is a super noob problem, but I could use the help. Thank you!
Well, for the basic question, you have to get the correct credentials from your client. There's no alternative, really :D
While you're at it, you'll want a copy of the site's database too.
For the question "how do I host it locally?" Here's how I would go about it.
Get the site into version control.
Given that you were given (S)FTP credentials, I'm guessing the site is not version-controlled. If that's correct, then that is probably the very first thing you want to do. This will allow you to keep track of the changes you've made on your local site that are different to the production version.
Create an empty directory on your computer.
Navigate to the directory in a terminal and run git init.
Add a .gitignore file to that folder (you can create your own, or use one customized for Drupal).
Download the site's files into the directory created in step 1.
Add the files from the in the directory to the git repository by running this command in a terminal: git commit -am "First commit of Drupal files to repository."
There's a good help page about working with Drupal in git on drupal.org.
Create and populate your database.
Get a database dump from the live site.
Create a new database and database user on your machine.
Import the database dump into your new database.
Record the database credentials in settings.php or settings.local.php and store them somewhere safe, preferably in a password manager.
Change the database credentials in settings.php or settings.local.php to match the credentials of the database you've just created.
(For safety and to avoid confusion, I always create local databases with a different name, user, and password than the live site has. This means if your local credentials are compromised, the live site isn't, and it means you can't connect to and change the live site's database by accident.)
Set up the webserver in XAMPP
Create a new site in XAMPP called e.g. example.local that points to the directory that contains the file index.php
Add the following line the file called /etc/hosts on your computer:
127.0.0.1 example.local
Test that this works in a browser by visiting e.g. http://example.local or http://example.local/robots.txt.
Move your local changes to the Production site
How you will be able to do this depends to some extent on your client's web-hosting infrastructure, and what version of Drupal your client uses. but in any case, you will have three separate concerns for changes you make:
Code changes
You will need to deploy changes you make to the code back to the server. Ideally you would probably do this via Git either by cloning directly into the live site or (far better!) as part of an automated build process. By the sound of it, you may just have to FTP the changes back up.
Be careful not to re-upload your modified settings.php or settings.local.php file!
Content changes
You probably have to test some/all of your content changes locally and then recreate them on the live site. Because your client may have made changes to the live site while you were working, you can't risk importing your local database into the live site.
Configuration changes
Changes to configuration should be managed in code (i.e. as part of 1. Code changes above) if that's possible. In Drupal 7, the Features module is usually the best way to accomplish this (here's an answer I wrote describing the Features workflow). Drupal 8 has the Configuration Manager. Be aware that these two tools can both be tricky to use well.
Your client needs to gave you access to the files so you can put them into htdocs on XAMPP, then you need the database (also provide by the client), start XAMPP, create a new database on localhost/phpMyAdmin and import the db of the site. On the proyect code go to sites/default/settings and change the db settings to your local settings. Then you can go to localhost/{your-proyect} and it should work.
me and a coworker are trying to move a website from a test server to local web development. Our boss wants us to use Amazon web services CodeCommit in conjunction with Xampp to do this. We have made progress but cannot overcome a database issue. Here is what we have done.
Set up AWS accounts and recieved necessary credentials from boss for the sites repo
Pulled repo and ensured that we could both commit and pull normally
Downloaded xampp, made sure apache and php were functioning normally
Now, one of us (me) has used the duplicator wordpress plugin to backup the site and load it into a local version.
I can now develop locally fine and push changes, all images and pages from the site are showing up locally
ISSUE:
How can my coworker also develop locally, the issue appears to be that he has not made a database in xampp phpmyadmin control panel for the site, but if he did wouldnt it be a different one than I am using, and thus wouldnt sync with git properly? Where xampp stores the database info isnt in the git folder, so I may be doing it wrong as well!
We cannot figure out the correct course of action, please if you can point us in the right direction. Much appreciated!!
I am using my laptop as a test environment for a wordpress website before I move it to an online server. I have this setup with a xampp sever running on the local machine. Wordpress is installed and running a theme which I have modified somewhat. When I navigate to the website from the local machine by going to 'localhost', the website displays correctly, however if I navigate to the website from another device whether it may be a computer, phone or tablet, the website seems to exclude css styling and only displays plain html. Any insights would be appreciated.
I know that with some browsers, sites in your local intranet except localhost are rendered differently. I am not sure whether this is the issue here. I am using Chrome Version 42.0.2311.135 dev-m
When you're accessing the site on another machine, open up the developer tools in your browser and see where the link to your CSS is pointing at.
It sounds like that CSS URL is hard-coded to be pointing at localhost (which would explain why it only works on your machine). It could also be the case that you have set your site's domain to be localhost in Wordpress which may be using that to render the URLs.
Double check your Wordpress settings, and also your theme's code.
I planned to move my Wordpress site from my Xampp server to my production server. I changed the address under the 'Administration - Settings - General' panel. However, unfortunately I was not able to move the actual files to the new location via ftp, as my hosting network appears to be down.
I want to continue working on the project in my local server, however, when I tried to access the WP-admin login screen to login to my site, it automatically redirected me to the newly specified address of the site (which is currently empty).
I am now stuck outside, unable to log into my site. Has a constant been changed somewhere, or does anyone have a fix where I could somehow undo the changes that I have made?
Thanks!
Best Regards,
Robert Young
London, UK.
You can re-set the correct URL working on the MySql DB. In the table "wp_options" you can find "option_name = 'www.example.com';".
Here is a nice free plugin which handles moving Wordpress sites from one host to another:
https://wordpress.org/plugins/duplicator/
It is an easy way to complete the job, without having to get your hands "dirty" with database and configuration files modifications. Hope this helps!
I'm new to PHP and everything, so I'm trying to learn some things.
I'm currently developing my first PHP site in Dreamweaver using MAMP and Localhost.
I have already bought my domain name, and built a smaller html site just to act as a "holding site" before the PHP one gets put up. I'm wandering if instead of using localhost, that I could use a subdomain of that domain. So instead of going to localhost/mysite I could go to test.mysite.com.
Tell me if I'm wrong, but I shouldn't have to upload any files to GoDaddy because I'm using MAMP as the server. Right?
Keep in mind, this isn't permanent. I'm not planning on hosting my site on my computer using MAMP. I'm just wandering if it's possible and how to do it if it is.
Any suggestions, comments, or answers are greatly appreciated.
Thanks.
- Ryan
MAMP is not the server. MAMP adds server capabilities to your computer, but you can't use MAMP to mimmic any server.
What I recommend you is working on your computer, with MAMP and using localhost as the "test address". After the page is finished in your localhost, and everything work fine, you can upload your page to your server (with FTP). This way you avoid having to upload your files via FTP every time you make a change in your code.
And welcome to the PHP World. Countless mugs of coffee and restless night await you.
You can create some folder on web server(on your paying hosting) and upload all files from your test localhost folder. Everyting would work perfectly if you type: https://yourwebsite.domain/yourfolder. If you want to set it to view like http://yourfolder.yourwebsite.domain you must from Control Panel set up an some subdomain. Subdomain is make something like this: you enter name of subdomain and folder which is mapped to that subdomain. For example, you set up subdoman http://test.web.com and map that to http://web.com/testfolder.
I hoppe that I help you.