Deploying a Wordpress Site over SSH

wordpress
#1

Hi everyone! I’m very new to circleci and so far what i’m trying to do is to simply deploy the code from github to my server, don’t need to build anything. I looked up test config example in the docs and modified it:

version: 2
jobs:
  deploy:
    machine:
      enabled: true
    steps:
      - run:
          name: Deploy Over SSH
          command: |
            ssh mytest@mytest.com "<remote deploy command>"

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: master

With this config my workflow is not failing (which is good i guess), but not deploying either. It looks like it can connect to the server. However I cannot figure out how do I specify path to the folder where I want to deploy to. Also, not quite sure what is “”. Thank you!

#2

Could you provide some more info on what exactly you are trying to deploy?

Here is an example of a project that SSH’s into a server and runs some deployment commands (in this case running docker-compose). Depending on your specific situation the approach will be similar but the details will vary.

1 Like
#3

I’m trying to deploy wordpress site to the ubuntu server. Sorry, my expertise in devops is very low. I’ve used https://beanstalkapp.com/ for deploying code for a long time, and over there I just specify the destination where to deploy and it works. I see that with circleci it’s more complicated, but I still would love to figure it out.

#4

Deploying a wordpress site typically means moving the new files on top of the old ones. I would recommend using rsync. You can see an example in that link that I sent you.

rsync -e "ssh -o StrictHostKeyChecking=no" -avz $PATH_TO_WORDPRESS_DIRECTORY_ON_CI $PROD_SERVER:$PATH_TO_WORDPRESS_DIRECTORY_ONSERVER

Just replace those variables with your own.

PATH_TO_WORDPRESS_DIRECTORY_ON_CI – should be the path to where your wordpress files are in CI.

PROD_SERVER – should be something like ubuntu@127.0.0.1 (username@IP_ADDRESS)

PATH_TO_WORDPRESS_DIRECTORY_ONSERVER - should be the path to where your wordpres files are on the server.

The only thing to make sure is that the user that you are logging into the server with over SSH has permissions to write to the directory where you are uploading your wordpress files to.

1 Like
#5

Thank you Lev, rsync indeed worked. But I’m still having issues, again, because of lack of the knowledge of CI. I don’t quite understand what PATH_TO_WORDPRESS_DIRECTORY_ON_CI would be for me. I tried to ssh into the box while workflow is running, but I didn’t see the files from my repo overthere. I obviously missing something. This is the article that inspired me to use circleci - https://medium.com/@marineboudeau/what-is-the-easiest-way-to-deploy-from-github-to-a-web-server-3eac148b4484, and deployment config looks pretty straightforward there…

#6

Your project is probably located at ~/project or just ./ so try to reference the present working directory with just the period slash.

rsync -e "ssh -o StrictHostKeyChecking=no" -avz ./ $PROD_SERVER:$PATH_TO_WORDPRESS_DIRECTORY_ONSERVER
#7

It looks to me that ~/project or ./ is empty. Jobs runs successfully, but no files getting copied over. Am I missing some building steps that have to be made prior rsync deployment?

#8

Can you share your entire config here?

closed #9

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.