So I've been learning the main technologies for web development and I really wanted to know what are the best options to store and manage my databases.
I have been using XAMPP to store all my files, HTML, PHP, JS and so on, but how do I manage my databases?
Any suggestion on how to keep track of the data on them?
Its best for you to work locally on xampp other than using other local servers. for startup its most easy for you to use. http://localhost/phpmyadmin is platform where you will be able to manage your database . xampp/htdocs/Yourfolder will be place where you can manage your project files .
Choose your favorite editor .
hope you understand
Use XAMPP only for development!
Normaly you have a Webserver and a Database server (like MySQL or PostgreSQL).
On the webserver there is a directory called "www" or something like that. Within that dir all your files go in.
On the database Server you have your databases.
But you can't "keep track of the data". A database is a folder with some files that can only be read by the database.
If you want to import/export/backup the data, there are manager tools to write the data into an extra file / read data from an extra written file.
Take a look at phpMyAdmin - allows to manage MySQL databases visually through the web browser
One of the best ways to create and manage databases on a server is via PHPMyAdmin.
First you will need to install MySQL on your server and then install phpmyadmin into a sub folder of your websites root directory.
If using linux both of these steps are very simple and there is numerous guides on the topic.
After that you can use PHPMyAdmin to import an existing SQL database or create new ones from scratch.
Related
I'm having problems keeping consistent versions of a repository on different local machines, and pushing and pulling effectively.
When I worked with Rails, I could push and pull easily and all the files required to start a Rails server were included.
With Wordpress, I have to include files like wp-config.php in .gitignore so when I pull the repository to a new computer, I cannot start a local server (through Desktop Server). I did try manually transferring wp-config because that wasn't too inconvenient, but then a database error followed and I need a more complete solution.
How do you transfer entire WP repositories between developers through version control? I want to be able to push and pull, not drag and drop.
(One solution I thought of: Duplicate the WP base, connect the remote repository to the base, then pull and merge the updated site into the base server.)
(Another possible solution: moving the db config and salts lines from wp-config.php into dbsalts.php, then including that file in wp-config.php. I would then add dbsalts.php to .gitignore and remove wp-config, so the big important stuff would be ignored but the reduced wp-config would be pushed. Not sure if this would work, and we'd still have to drag and drop dbsalts.php.)
dbsalts.php
define( 'DB_NAME', ..... (redacted code for security)
...........................
define('AUTH_KEY'......
..........................
wp-config.php
include(dbsalts.php);
Currently using wpengine and desktop server, but I'm just now implementing this and open to suggestions.
*Private BitBucket Git Repository – While most of the time the only truly sensitive information in a WordPress install is in the wp-config file, which is preferable not to include in Git repository, keep whole sites in private repos, which are free from Bitbucket. Open-sourcing your entire site might make sense, but it’s something to think through thoroughly before doing so, and erring on the side of caution is a good policy, especially when doing client work.
*WP Migrate DB Pro – While Git can keep all of the site’s files in sync between environments, a different tool is required for keeping the MySQL databses in sync. WP Migrate DB Pro is an excellent plugin that automates this process.
Even if you get this to work you are going to have further problems with the database. 2 developers working on 2 different local WordPress sites can create a number of issues with data in the database.
Here's an example suppose both of you pull the site that has the following posts in the database: A, B, C.
Now you make a new post: 'D1' and the other developer make a different post: 'D2'. This will associate D1 and D2 with the same post ID (since D1 isn't at the second developer's WordPress database, the same is true for D2).
What you could do (in theory), is set up both machines to connect to the same remote database (you'll have to white-list both of your IP address, if they are different, for that particular install with WPEngine's support). You'll need to modify the local wp-config.php, which I believe will make it different from the one on the server, but that's okay, since you can include it in gitignore.
Now you might can both pull and push to the server without an issue. But I'd use BitBucket or GitHub and have only one of you pushing to the server. I'd also look at DeployBot.com at some point. It can push the code from BitBucket/GitHub to WPEngine's server through ftp automatically.
I use local configs based on the url by adding the following to wp-config.php:
$site_options_filename = dirname(__FILE__) . '/options-' . $_SERVER['SERVER_NAME'] . '.php';
if (!file_exists($site_options_filename)) {
die('missing config: ' . $site_options_filename);
}
This will look for a specific config file based on the domain you are viewing. I use a dev. prefix or similar for my local builds.
I also use a quick bash script to dump the db to a .sql file which I include in the commit whenever there are database changes that have to be propagated:
mysqldump -uyour_db_username -pyour_db_password --add-drop-table --create-options your_database_name > dump.sql
It's a simple task to run dump.sql against the database every time you pull and dump.sql has changed.
Our main website uses symfony 1, and by the time I started working on the code it seems impossible to upgrade (too much custom code from previous developer). Now we are adding a large addition to what the company offers. Instead of using a really old framework I wanted to use CodeIgniter, also since I'm very familiar with it. My real question:
What is a proper way of setting up a website to use multiple frameworks. The new features will be separate from the original website, but it will still need a few tables of the database.
I was going to have apache handle where the root directory was depending on the url and just do everything normally. The main website is example.com and the new feature will be abc.example.com
I'm really looking for people who have done this and some tips and warning they had.
PHP will run the framework based on which directory is loaded on the server. For instance, on most apache servers the root directory for example.com would be /www. Which means all of the code for Symphony would be in /www/*.
When you setup the path of your subdomain, just put it outside of the /www folder. Then, when you go to abc.example.com apache won't try to load the original site along with the Symphony framework.
I think it will be fine for both frameworks to share the same database tables. I'm not entirely sure how you plan for these two applications to work, but as long as you don't change the column names and types you should be okay.
If you don't want the applications to share the data in the original table, then look into using mysqldump or something of the like to copy the data over to a new table.
OK, here is the problem, I have a running application on the server, and a developing version. User have more and more request and suggestion about the site. So, we need to upgrade the site and the database. Since the database update, we need some database schema change. How can we handle this? Because if the php program, we can easy as upload all the script files and deploy, but the database, it there any 'diff' for the database? Thank you.
I usually log every change I make to the database structure while I develop. Later I just apply the same changes to production.
You can always use migrations, kinda like rails
I am developing an application with Ruby on Rails (will be more to come) and it has got to the stage where I would like to remotely host a development version, followed by a production one. I have done lots of rails development but I am reviewing my current setup and would like to make sure I do things the industry recommended way form now on.
I already have a dedicated server which is running parallels plesk and has several domains on it. I have currently had some success by creating a new user "passenger" to run the rails app and deploying via that user to an apps directory under
/var/www/vhosts/myrailsapp.com/subdomains/dev/
which is the parallels-format for site directories, deploying using capistrano and running the passenger module for apache. I have basically been putting my rails files where I would put them if it were a plain php site or similar and I was wondering if this was the way things are usually done?
I also found some information online which points at putting my rails apps under
/var/apps/
or similar, but then it would conflict with the parallels plesk way of doing things which could potentially cause issues, or could it?
I have already looked at solutions like Heroku and they won't quite work as I need to run other programs alongside my rails app on the same server to handle some real time server to server file syncing of files uploaded using the app. Added to this I need to ideally be able to host normal PHP applications alongside my RoR ones to make best use of the server.
How should I ideally go about implementing this sort of setup for secure hosting and deployment? If needs be (i.e my current setup is far less than ideal) you could assume I am starting from a vanilla ubuntu server install which I would be open to if it produced a nicer system to manage.
I figured many people would have had similar situations and so any advice from any of you veteran Rails/PHP developers or server admins would be greatly appreciated.
Many Thanks,
Peter
Normally it's a bad idea to put your Rails project files anywhere in your public html space because you don' want anybody to be able to put something like http://yoursite.com/config/database.yml and access sensitive information. Even if that's not possible under normal situations, it could still happen if you have problems with Passenger starting up correctly or something similar.
So I would recommend putting your Rails apps in /var/apps or /srv/apps (as we've done) and setup the Apache config to point your domain or subdomain to that directory.
If you want to have your app accessible by a subdirectory on an existing domain it takes some additional setup but that can also be done.
Currently my workflow is like this:
Make some changes to the local
copy of my website
Use Akeeba backup to make a copy of my website and database
Delete contents of hosted server
Upload Akeeba backup files
Visit website and
run akeeba restore which syncs my
database
Is there a better way to manage a joomla website? The problem is, I have a team working on one website so this doesn't really work as well. Setting up version control with the server won't exactly work because pretty much everything in Joomla gets stored in a database so we would need to somehow also get the CVS to work with the database. Potentially if Joomla and SQLite worked together (they don't) a CVS solution might work.
Write a php script, doesn't look like you are doing anything to difficult.
The only problem I see with your process is the downtime. In order to eliminate the downtime you can create two versions of Joomla on your LIVE server and point the apache to one of them, when you deploy your code, do it to the currently "off-line" version of Joomla and after you finish the deploy - point the apache to that version. Just a thought ;)