Testing File Updates and Improvements without showing to users - php

I'm pretty new to web development and as I build websites using an Apache server, I was wondering how to prototype changes. For example, say I'm working on improving a PHP file that is already being displayed on the site. How can I test whether the changes I'm implementing work when the updated file is put on the server without disrupting users to the site if there is an error in the new code?

You should have a local copy of your site on your machine where you can test your codes, if that works, add it to your live website, Simple!

Related

Resolving urls on a Wordpress server using React

I'm working on creating a new React-based site to replace an old WordPress site. I have been creating directories within the wordpress server for the new sections I have been making. domain.org/about, for example, will go to the react files stored in the about directory. No problems there. The issue I am having now is for more complicated urls. I have set up react-router to handle lots of events by using an id to pull in information on a specific event. domain.org/events/event123, for example, should display information on event123. In development this works fine, localhost:3000/events/event123 will display event123. On the wordpress server, however, I get an error. I realize that this is because there is no event123 directory within the events directory on the wordpress server.
How can I configure wordpress to handle these urls? I realize I need to set something up so that any url that begins with domain.org/events will go to the react files in the events directory, but how I go about doing this while still passing along the event123 I do not know. Any help is appreciated. Apologies if my description is a bit confusing.
EDIT: I should add that the old parts of the site and new parts of the site have no connection to each other, other than the fact that they are hosted on the same server. Once the new site has enough content on it it will be moved to a new server and the wordpress site will be shut down.

How do I change a wordpress dev site url that was overwritten by live site backup

We have a dev site www.dev.site.co.za & a live site www.site.co.za.
I wanted the dev site updated to be a current replica of the live site, so our hosting provider copied it over.
But now when if you go to www.dev.site.co.za, you are "redirected" to www.site.co.za. I have tried changing the siteurl in phpmyadmin but that hasn't resolved the issue.
Is there somewhere else the url needs to corrected and is there anything else I need to do to make sure the dev site is a completely separate environment to the live site so I can safely fiddle without damaging the live site?
wordpress not only uses the database in PHPMyAdmin for the url.
As mentioned in the official documentation there are several files that can include the url:
the wp-config.php (wordpress file)
the functions.php (theme file)
Check these and have a look for the url address.
Have a look at the .htaccess file!
Also:
Helpful for that issue (e.g. restoring a wordpress page on another server) is the plugin BackupBuddy. It is one of the most well known plugins for wordpress. (Know right now that it is a paid version! But as always there are others with the functionality).
It allows you to backup and restore your page on a new system. You can initially set your new desired address for the system then.
Maybe it is worth a look!
For rectifying your dev site issue, you can try this.
Following is the URL to a simple utility via which you can replace some value in your database with some desired value.
https://github.com/interconnectit/Search-Replace-DB
Download the utility (zip file).
Upload it to your dev site root location and unzip it there. So that the the URL of the unzipped folder becomes: www.dev.site.co.za/Search-Replace-DB-master/.
Visiting that URL will show you the screen with options to replace some values in your database with desired values.
This utility automatically selected the connected database.
Put the URL of your live site in the field to replace.
Put the URL of your dev site in the field to replace with.
Choose the Dry Run option to see what all tables and columns will be affected.
Once you see the results and know what is changing then you the click on Live Run.
Clicking on Live Run will change all the URL of your live site in dev site database with URL of your dev site.
Once the changes are done you can delete this folder.
Hope this will at least resolve the problem of redirection of dev site to live site.
Once the new site is built you can then migrate(move, copy) it to the live site's location. There are some tools out there to help with moving the site you can use once the site is done. Some require a plugin to be installed to do that though. For example magicmigration can be used to move the completed site to a new location (that one specifically doesn't take extra installs). It is also possible to manually migrate the site though depending on the situation and know-how that can be a bit much for some people.

After migrating website rederection to old website

I just migrated my website and it keeps rederection to another domainname of mine. Before I did this I open de SQL file and replaced the old domain with the new one. And imported it this in a new database. After that I configured the wp-admin. So after done this it should work right? In can access the website through wp-admin and that seems to work, but when I just type in the URL it rederection to another old domain of mine.
Anyone any idea how to fix this?
Seems like you missed some records in the database. The best approach is to use a tool like https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
If you download this free tool and upload to your server then it does a batch find-and-replace across every single table in your Wordpress database.
So, for example, replace http://www.example.com with http://sub.example.com
You can do a dry run and it will show you all the replaces that it will make. Once you're happy then click the "live run" button and all the changes are made.
I use this tool all the time when I am moving a site from my local machine to the live server. I also use the exact same approach when migrating a site from http to https

Working with staging and Live url wordpress

I made my wordpress site live by moving it from the staging url (staging.example.com) to the live url(www.example.com).
I wont be working on the site anymore so I have to advice my client on how to manage things on his own from now on.
I have 2 options:
Let the client add blog posts directly on the live. When it comes to installing plugins or
any other changes that might cause the site to break, I can ask him to clone the live site by
using plugins such as wp-staging, test the changes on staging url and if everything works as
expected, then make the same changes in live.
I can ask him to make all the changes (adding posts, plugins etc.) on the staging url first and then transfer the
files to the live url. But how would we transfer the db from stage to live without overwriting the live db?
Also I used this script
to change the url in db but I dont want to let my client use that script because being a non-technical person,
I am afraid that he might end up deleting the entire files on the server or that he might forget to
delete the script after using it.
Or is there a better option? I am new to wordpress. Any help would be greatly appreciated. Thanks.
You could use a backup plugin like backupwordpress or any of the other popular options out there to backup the database and files on a regular basis. Then run the backup right before making any plugin/theme updates.
Well usually staging urls are used when developing plugins or themes. In your case you are simply installing new plugins and adding posts to the WordPress. This is how WordPress is normally used and it does not require a development site.
If your client installs well known WordPress plugins which are well tested, then he should not have any problems with installing them.

Deploying custom website onto clients hosting

I have developed a website application that includes a custom built CMS and PayPal payments etc...
My client already has hosting for his main website via the developer of that site.
I wish to host the new application under a subdomain such as:
application.website.com
I have reservations about storing my complete source code on the other web designers server.
Is there a way that the code can remain on my server but with the required subdomain or somehow password protect the folder?
Thanks for the help.
You might be able to store your source code on your server and use the PHP include function to get the pages on your client's website to use the code on your server. I've not tried this so it may not be possible for PHP to communicate between two servers like this, but give it a go and see what happens.

Categories