How to start for a newbie

Hi guys,

First, a big thanks to the Roots team & community for your awesome work, help.

Let me explain my problems :

I’m totally new on Bedrock, and Sage (and with a lot of tools, like Vagrant, Ansible, Bower, Gulp, etc).

In the past, I created a lot of wp site in the traditionnal way with default wordpress install, premium theme or not, on dedicated servers (Debian 7, Apache 2, php 5.4, mysql, apc, etc). I worked in a local environnement and uploaded the project on the server “/www” via FTP when was finnished.

I read since few weeks now the roots project (Bedrock, Sage + Soil) and i want to improve my way to work.

I can saw Bedrock, the “modern WordPress stack that helps you get started with the best development tools and project structure” inspired by the Twelve-Factor App methodology and Sage who use the best practice and tools as a starter theme.

For Sage + Soil with Gulp & Bower :
I think it’s ok for the moment, i bought the book “Theme Development with Sage” and the screencast “Theme Development with Gulp and Bower” so i have a good base to start working with Browsersync, etc.

For Bedrock :
There are 2 things : Bedrock and Bedrock-ansible. If i well understood, you can work with Bedrock directly on you web server or use Bedrock-ansible locally with Vagrant & virtualbox [Local] for create a server environment on your machine, and Ansible for deploy your environment on the web server ?

If it’s right, Ansible will install all the requirements on my dedicated server ? (nginx, hhvm, etc ?) Or i need to install manually ?

Thx for reading and for your help !

You seem to have a good handle on things.

To deploy sites via Ansible you can use Trellis (aka bedrock-ansible), or you can use the separate bedrock-capistrano project, which uses Capistrano to deploy.

Trellis can also provision an Ubuntu 14.04 server with (almost) everything you need for a high performance lemp stack. It’s very easy to do this with any of the big providers (Digital Ocean, AWS, Rackspace et al).

Thanks for your answer, it’s easier for me now.

I have virtualbox + vagrant installed on my windows desktop, and i configure the env files.

Somes questions :

  • Each site i want install will create a database on my server right ? (If i have 3 sites, so 3 databases locally, 3 on the server for staging and 3 for production ?)

  • Php errors commands (last lines of devlopment file) need to be duplicate 3 times (1 per site) or not ?

Thanks again !

  1. Correct.
  2. Nope, just once. Those aren’t part of the wordpress_sites variable.

Thanks !

1/ Ok so i configured my 3 environments in group/vars. I edit the main.yml after a bug (thread)

So now, i have an error with composer when i vagrant up :

==> default: stderr: Composer could not find a composer.json file in /srv/www/mydomain/current
==> default: To initialize a project, please create a composer.json file as desc
ribed in the https://getcomposer.org/ “Getting Started” section
==> default:
==> default: FATAL: all hosts have already failed – aborting

==> default: PLAY RECAP ********************************************************


==> default: to retry, use: --limit @/root/dev.retry
==> default:
==> default: 127.0.0.1 : ok=70 changed=39 unreachable=0
failed=1

How can i resolve this error ?

2/ Stupid question : Ansible need to be installed on my virtualbox environment right ? Not on windows, like vagrant ?

EDIT : Ok i saw Ansible need to be installed on my windows like Vagrant, but there is no windows client right now. I saw a lot of threads who people says, “you can run ansible with Cygwin (or Babun) but It’s not a good solution !”. So… What is the solution for windows users ? I hope i’m not the only windows user on this forum :wink: !

Thanks for your help !

I’m not sure where you read that. Ansible does not support Windows, and I don’t believe there are plans to. However, bedrock-ansible is set up to install Ansible in the VM and provision itself with Ansible.

Oh ok thanks @kalenjohnson for your answer.

So i need to run the command : ansible-playbook -i hosts/production server.yml and ./deploy.sh production <site name> directly on the VM ?

One of the thread : Running Vagrant with Ansible Provisioning on Windows
And on google for the “it’s not a good solution”

My bedrock-ansible works fine now with my 3 sites. Thanks all for your help !

2 Likes

Correct. Everything other than vagrant commands needs to be run on the VM.

1 Like

Thanks !

An another question :

So i want to desploy 3 websites on the same server, how can i configure my /hosts/ environments files ?

The 3 websites are ok for development environment locally, but for the 3 staging and the 3 production environments ?

Like this ?

With my hosts files :

  • Staging

    [web]
    My Server IP

    [staging:children]
    web

  • Production

    [web]
    My Server IP

    [production:children]
    web

This is right ?

And how i need to run the ansible-playbook -i hosts/production server.yml?
One time for staging and one time for production ?
And for ./deploy.sh production <site name> ?

(Ok sorry it’s not just one question, but i’m a little lost for now…)

Thx for your help again !

I’m a bit confused. The 3 sites are on the same server? Meaning they all have the same IP (but different DNS/domain name)?

If so you only need to put the server IP once in each hosts file.

The commands you had would be correct in that case.

I have one question I install bedrock on my localhost and url is localhost/wptest/bedrock and i wrote in my .env file that WP_HOME = localhost/wptest/bedrock and WP_SITEURL = localhost/wptest/bedrock/wp and filed beacuse directory isn’t found,
please tell me what is wrong?

Thanks for your help.

So now, i have my dev environment ok.

vagrant up work fine and my configuration is ok.

(I restart all the process with your roots example on github)

I’m trying now to install the Sage theme on 2 of 3 on my local server but i have a bug.

So i used this :

  • Create a new project directory: $ mkdir example.com && cd example.com
  • Clone bedrock-ansible: $ git clone --depth=1 git@github.com:roots/bedrock-ansible.git ansible && rm -rf ansible/.git
  • Clone Bedrock: $ git clone --depth=1 git@github.com:roots/bedrock.git site && rm -rf site/.git
  • Clone Sage: $ git clone --depth=1 git@github.com:roots/sage.git site/web/app/themes/sage && rm -rf site/web/app/themes/sage/.git
  • Move Vagrantfile to root: $ mv ansible/Vagrantfile . and update the ANSIBLE_PATH to ‘ansible’

I changed the configuration for my server, etc (in group_vars and hosts)

(i do not clone the sage theme on the third website)

After i added : define('WP_DEFAULT_THEME', 'sage'); in site/config/application.php

I run vagrant up, all work.

I installed the requirements for sage with vagrant ssh :

  • Node v12.6
  • Gulp CLI version 3.9
  • NPM v2.12.1
  • Bower v1.4.1
  • and php 5.6 installed by bedrock ansible

Now when i’m going in my theme folder (cd srv/www/domain/current/web/app/themes/sagerenamed/) and i try to run npm install i have a lot or ERR ! and WARN.

I look the NPM Debugging Guidelines here and try to npm install -g npm@latest and npm cache clear && rm -rf node_modules && npm install but still doesn’t work.

Have you an idea ?

(I haven’t tried : “Trying to run npm install on an external volume resulted in errors. Works fine when moved to local HDD.” because i don’t know if it’s needed and how to proceed…)

Thanks again !

Just a little bump :smile:

I’ve never used npm on Windows, but if npm installs globally and you still have trouble running npm in the Sage theme folder, typically it means there’s a permissions or path (locations where npm can look for/save information) problem. I’d look into re-installing npm.

If you’re working from an external drive, it’s definitely worth just creating a simple Sage install on your internal HD to see if it solves the problem.

Update: These instructions seem like they might at least offer a different approach.

Thx for anwser.

But NPM is not used on windows right ?

I mean, is used on virtualbox with Ubuntu 14.04 Trusty LTS no ? I installed nodejs for windows atleast but change nothing.

Sometimes i have errors (err tar unpack) and sometime all is unmet dependency…

It depends upon your setup - but running npm/gulp inside the virtual machine while developing on Windows seems like it would be painful. Bedrock doesn’t install node or npm, so one way or antoher you have to install/troubleshoot it, if you do it in Windows you only have to do it once rather than each time you setup a virtual machine.

I believe the idea of Vagrant (or developing using virtual machines) is that the web server, PHP and MySQL etc. are installed within the virtual machine, and your development tools (Gulp, Grunt, npm) all run on your local machine, with the shared folder acting as the meeting point.

I follow your recommendations and it’s better.

I deleted my folder and restart from scratch with all the necessary installed on my computer.

For my first website all works well (No vagrant up for the moment but i had no error when i ran npm install, just 1 line for dependencie not up to date)

But when i run npm install for my second website (second folder, second theme) i had few errors, i don’t know if it’s important for the moment or no. Maybe i should run npm cache clear && rm -rf node_modules && npm install

Bower and gulp install works fine.

Node and npm are tricky - but worth taking some time to get right, IMHO.

If one site works and another doesn’t, that’s a pretty good base for troubleshooting. Npm often shows warnings and all kinds of colourful messages as it installs - I guess worst case, if you’re able to run the gulp commands then everything must be installed correctly.

Yes - clearing cache and removing the node_modules folder will definitely help with general troubleshooting.

Thanks a lot ! :smile: