my company asked me to transfer their wordpress websites (web and database files) to another server. The other server is a virtual machine which is already running and there is already an empty shell. I have the username, ip address and password of the virtual machine where they want to transfer the file. I was able to login to the virtual machine using putty and double check the directory of that virtual machine and it seems that there is nothing yet. And I've downloaded the wordpress files and its database in local computer. And the local computer that I'm going to use dont have any internet connect but I was able to connect to the virtual machine using putty.
Questions:
- how can I transfer the wordpress files from the local computer to the virtual machine using putty?
- what command line should I type to upload the wordpress files? The command line that I've tried is this below. I logged in on the virtual machine and type the command line below. And it seems that it didnt work.
scp root#127.0.0.1:C:\Users\localComputer\Desktop\wordpress.zip /home/virtualMachine
- should I login on the virtual machine via putty and then type in the command line to upload the files from the local computer OR use command prompt from the windows and type the command lines to upload the files to the virtual machine?
The local computer Im using is windows 7 32bit. Please advise. Also, I dont know how to unzip the files once it is uploaded in the virtual machine. what command line should I used.
Well you cant upload files from your local computer through putty, you have ftp for that. To upload files from your local computer you have a couple of options.
Upload to a git repository like github and bitbucket
Check if ftp is installed and then connect through ftp.
For ftp you might first have to check if ftp is installed and then create a new user which you can then use to ftp into the server. I personally like git so i will just explain about git.
If its your first time using git, then it might be a bit tricky. But none the less you will have to learn it for the long run. Create an account on github or bitbucket, if your code is copyrighted/ Ultra top secret :P and dont want anyone to get hands on it then you have to upload it to a private repository, while if its just a wordpress theme or nothing much of any value then you can upload it to a public repository and later delete it (bitbucket has free private repositories while you have to pay for github).
After creating the account, create a new repository with the name of the project.
I personally like github, so i will explain for github. But 99% of the things are same for bitbucket as well.
First install the github globally on your OS, Once installed goto the directory you want to upload and type, these commands
git init
git add *
git commit -m "Upload code to server"
git remote add origin <github-repository-url>
git push -u origin master
if asked for username/pass just type it in. This will upload the code to github. Then on your server first install git by
sudo yum install git-all // For redhats e.g fedora, centos etc
OR
sudo apt-get install git-all // for debian e.g ubuntu
Then goto the directory you want to upload your code to and type.
git init
git clone <github-repository-url> .
Dot is important, as it tells the server to download the code in the directory that you are currently inside. Then it will start downloading all the code to your server.
Making changes like a pro
Lets say later on you want to make changes to the files on your local computer. After you make all the changes, just type
git add *
git commit -m "My new changes"
git push
And it will upload all the changes to repository you defined in the previous steps.
Then on your server, you can just type
git pull
And it will pull all the changes from the respository.
Related
I have figured out how to create a repository on github. Now I am trying to push the repository to both my macbook pro and my server, which is hosted through http://namecheap.com, and be able to understand how to keep things simple. I am using wordpress on my server and I have a template theme. I want to edit my files on my mac and then push them to the website, keeping everything easy.
There is plenty of information out there on how to get started with github, so I will just focus on clearing up a misconception:
Now I am trying to push the repository to both my macbook pro and my server
You do not push from github to a server. You need to clone your github repo to your development (macbook) and production (server) environments.
git clone https://github.com/USERNAME/REPOSITORY.git
https://help.github.com/articles/fetching-a-remote/
Alternatively, you can push existing code to an empty repository by initializing locally, setting your remote and then pushing
git init
git add -A
git commit -m "Initial commit"
git remote add origin https://github.com/USERNAME/REPOSITORY.git
git push origin master
Once you have your repo setup, your typical workflow will look something like this:
Make changes in your development environment (macbook).
push those changes to github.
pull those changes from github in your production or staging environment (server).
One of the main things you need to use git this way is access to a terminal on the hosting serve, to push your files directly through git that should be installed as well.
Alternatively you can upload file using any available protocol such as (s)FTP or SSH direct to your server. In this case you'll be using git to version and manager your templates but not to upload or release them.
I've seen that cheapnames.com provides Softaculous as a mechanism to manage their servers. This software also provides synch and install scripts.
I m writing a web application where it accepts the git URL and file to read and then displays the file on the webpage. I m using JGit for this. I see that JGit needs a local repository to clone before viewing the file. Since this is server, I do not have access to local files. So, is there anyway I can access the git remotely and view the file from there?
Thanks
It's not just JGit that needs a local repository, Git itself requires a local repository. Centralized version control systems like CVS and SVN had remote server viewing built-in, but decentralized systems (such as Git and Mercurial) typically do not.
If you want to browse a Git server, you have to make a local clone, but you could do this in the background for the user.
You might also be interested in the GitHub API, which lets you do what you want, but only for repositories hosted by GitHub.
I want to be able to develop my plugins & themes on my machine and the changes be reflected on my server almost instantly. Also I want a backup plan. So git & github seems a very good solution. I want to make regular changes to the server (push from local) and once in a while upload them on github too (local to github or remote to github).
The question is can I clone the repo from github to my remote server and to my local machine and be able to push from local to remote or pull from github to remote (if I'm not at home)?
Edit: I did a research and I found out that I actually need a bare repo in the server, but i want it to be able to push/pull to/from github.
In github and bitbucket (https://bitbucket.org) you can add any number of ssh keys from different machines and push and pull from anywhere you want. The command to generate such a key is
ssh-keygen
answer the questions with enter and the ssh key will be in /home/user/.ssh/id_rsa.pub. You have to do this for every machine you want to push and when the repository is set to private, yo also have to do it for those machines, you want to pull from.
So the workflow would be
editing locally
pushing to github/butbucket repo: git push -u origin
log in to the machine where wordpress is running: git pull
I have an ec2 instance running on AWS. Aegir installed and drush make works perfect for installing new platforms except when I need to download a theme from a private github repository.
drush make doesn't have access to the github private repository and fails the platform install.
How do I overcome this? Is there some fancy way to give drush make or the aegir user ssh keys for the git repository?
I don't know much about ssh-agent, but I figured maybe getting that to run all the time on my server so aegir will have access to my github.
how to make drush make access a private github repository?
Generate an SSH key on the EC2 instance, then add the public key (usually id_rsa.pub) to the private repository as a deoploy key.
stevenh512 is right,a step by step explanation follows:
Disclaimer: I use GitLab + custom VPS on Centos but the same workflow can be applied on any hosting (with ssh) and GitHub (ps I love GitLab for private repos)
Login to VPS as aegir, probably you can’t (if you configure your server tightly secure) so login as root an su aegir
Go to home dir (cd /var/aegir) and check is you have an SSH key. If you have one jump 1 step.
cat ~/.ssh/id_rsa.pub
If you don’t have create one and don’t use a pass-phrase (for more info http://community.aegirproject.org/node/30#SSH_keys but there are solutions if you want a pass-phrase). After the creation you will have the key’s random image. (Study the SSH it's too important for security!)
ssh-keygen -t rsa
Copy the key and then go to you GitHub/Lab->account/profile settings->SSH keys->Add SSK key. For title give anything you want (like: Aegir Key) and for key paste the key from your server.
cat ~/.ssh/id_rsa.pub
Now back to server you must add the Git as known host, we go the easy way: just login with ssh and type yes when it will ask for connection. Ready!!
ssh git#github.com
- or -
ssh git#gitlab.com
Testing: make a .make file and save it somewhere public (like Dropbox, right click copy public url) like:
core = 7.x
api = 2
projects[drupal][version] = 7.26
projects [my_module_name][type] = "module"
projects [my_module_name][download][type] = "git"
projects [my_module_name][download][url] = "git#gitlab.com:my_repo.git"
projects [my_module_name][download][branch] = "master"
Go to aegir gui and create an new platform and wait for verification (otherwise you can ssh as aegir to the server and test it with drush make url.make folder)
Warning! This workflow isn’t the most secure! Just experiment with it and configure proper your server!
Info: This workflow also works for your local dev machine (linux, mac, cygwin) to play with private repositories on GitHub and GitLab
Can you throw some points on how it is a best way, best practice
to install web application on Unixes?
Like:
where to place app and its bases and so for,
how to configure to be secure and easy to backup,
etc
For example I know such suggestion -- to set uniq user for each app.
App in question is Jira on FreeBSD, but more general suggestions are also welcomed.
Here's what I did for my JIRA install on Fedora Linux:
Create a separate user to run JIRA
Install JIRA under the JIRA user's home directory
Made a soft link "/home/jira/jira" pointing to the JIRA installation directory (the directory as installed contains the version number, something like /home/jira/atlassian-jira-enterprise-4.0-standalone)
Created an /etc/init.d script to run JIRA as a service, and added it to chkconfig so that it runs at system startup - see these instructions
Created a MySQL database for JIRA on a separate data volume
Set up scheduled XML backups via the JIRA admin interface
Set up a remote backup script to dump the MySQL database and copy the DB dump and XML backups to a separate backup server
In order to avoid having to open extra firewall ports, set up an Apache virtual host "jira.myhost.com" and used mod_proxy to forward requests to the JIRA URL.
I set everything up on a virtual machine (an Amazon EC2 instance in my case) and cloned the machine image so that I can easily restart a new instance if the current one goes down.