{"id":160,"date":"2013-09-06T00:25:46","date_gmt":"2013-09-05T22:25:46","guid":{"rendered":"http:\/\/hesmid.nl\/test\/?p=160"},"modified":"2014-02-19T16:23:10","modified_gmt":"2014-02-19T15:23:10","slug":"starting-a-new-wp-project-step-by-step-method-2","status":"publish","type":"post","link":"https:\/\/hesmid.nl\/test\/starting-a-new-wp-project-step-by-step-method-2\/","title":{"rendered":"Starting a new WP project with WP-Skeleton"},"content":{"rendered":"<p>Install using Mark Jaquith&#8217;s <a href=\"http:\/\/markjaquith.wordpress.com\/2011\/06\/24\/wordpress-local-dev-tips\/\">method<\/a>. This involves<\/p>\n<ol>\n<li>Handling differing database connection details<\/li>\n<li>Handling plugins that can\u2019t or shouldn\u2019t run on a localhost<\/li>\n<\/ol>\n<p><span style=\"line-height: 1.5;\">Create a local subdirectory. Then clone Mark Jaquith&#8217;s wp-skeleton into a new directory www. Or, if you already did the steps below, clone it directly from your own fork.<\/span><\/p>\n<p><span style=\"line-height: 1.5;\">Note: use recursive cloning otherwise the submodule will not be cloned:<br \/>\n<!--more--><br \/>\n<\/span><\/p>\n<pre>git clone --recursive https:\/\/github.com\/markjaquith\/WordPress-Skeleton.git www<\/pre>\n<p>Create your own Git repo (named after your project). I created wptest2 at bitbucket.org<br \/>\nRemove the remote repo from your local repo:<\/p>\n<pre>git remote rm origin<\/pre>\n<p>And add the new remote repo:<\/p>\n<pre><code>git remote add origin ssh:\/\/git@bitbucket.org\/sdims\/wptest2.git<\/code><\/pre>\n<pre><code>git push -u origin --all # pushes up the repo and its refs for the first time<\/code><\/pre>\n<pre><code>git push -u origin --tags # pushes up any tags<\/code><\/pre>\n<p>The wp-config.php is in the root.\u00a0Now open up your <code>wp-config.php<\/code> file \u00a0and change the names to the ones you will use on the server.<br \/>\nSome notes from Mark Jaquith:<\/p>\n<ul>\n<li>For local development, create <code>\/shared\/<\/code> (it is ignored by Git), and have the files live there. For production, have your deploy script (Capistrano is my choice) look for symlinks pointing to <code>\/shared\/<\/code> and repoint them to some outside-the-repo location (like an NFS shared directory or something). This gives you separation between Git-managed code and uploaded files.<\/li>\n<li>What&#8217;s the deal with <code>local-config.php<\/code>?<br \/>\n<strong>A:<\/strong> It is for local development, which might have different MySQL credentials or do things like enable query saving or debug mode. This file is ignored by Git, so it doesn&#8217;t accidentally get checked in. If the file does not exist (which it shouldn&#8217;t, in production), then WordPress will used the DB credentials defined in <code>wp-config.php<\/code>.<\/li>\n<li>(Use WP_LOCAL_DEV in other tasks that are different for the live server and the local installation (such as backups etc))<\/li>\n<\/ul>\n<h3><span style=\"color: #ff9900;\">Server stuff<\/span><\/h3>\n<p>Follow the steps pointed out in a <a title=\"A web-focused Git workflow\" href=\"https:\/\/hesmid.nl\/test\/workflow\/web-focused-git-workflow\/\">previous<\/a> post.\u00a0Summarized:<\/p>\n<p>Go to the working directory of your website (the <strong>Prime<\/strong>):<\/p>\n<pre lang='bash'>$ cd ~\/www\r\n$ git init \r\n$ touch test.txt # extra step for empty dir: create a test.txt file (so there is something to commit)\r\n$ git add . \r\n$ git commit -m\"initial import of pre-existing web files\"<\/pre>\n<p>create a bare repository outside the web directory, this is\u00a0<strong>Hub<\/strong>.cd<\/p>\n<pre>$ cd; mkdir site_hub.git; cd site_hub.git \r\n$ git --bare init<\/pre>\n<p>from inside Prime\u2019s working directory, add Hub as a remote and push Prime\u2019s master branch:<\/p>\n<pre>$ cd ~\/www \r\n$ git remote add hub ~\/site_hub.git \r\n$ git remote show hub\r\n$ git push hub master<\/pre>\n<p>create <strong>post-update<\/strong> in the Hub repository (in hooks\/):<\/p>\n<pre>#!\/bin\/sh \r\necho \r\necho \"**** Pulling changes into Prime [Hub's post-update hook]\" \r\necho \r\n\r\ncd $HOME\/www || exit \r\nunset GIT_DIR git \r\npull hub master \r\n\r\nexec git-update-server-info<\/pre>\n<p>create\u00a0<strong>post-commit<\/strong>\u00a0in the Prime repository (in .git\/hooks\/):<\/p>\n<pre>#!\/bin\/sh \r\n\r\necho \r\necho \"**** pushing changes to Hub [Prime's post-commit hook]\" \r\necho \r\n\r\ngit push hub<\/pre>\n<p>Give the right permissions to both the hooks:<\/p>\n<pre>chmod +x &lt;hook&gt;<\/pre>\n<p>Deny acces to git repositories. <strong>important!<\/strong><br \/>\nAdd the following to your top-level .htaccess file to forbid web access:<\/p>\n<pre># deny access to the top-level git repository: \r\nRewriteEngine On \r\nRewriteRule \\.git - [F,L]<\/pre>\n<h3>Back to local<\/h3>\n<p>To keep things simple for now I avoid using submodules in the repo<\/p>\n<p>SO remove the submodule for wp<br \/>\n<strong>To remove a submodule you need to:<\/strong><\/p>\n<ol>\n<li>Delete the relevant section from the\u00a0<code>.gitmodules<\/code>\u00a0file.<\/li>\n<li>Stage the\u00a0<code>.gitmodules<\/code>\u00a0changes\u00a0<code>git add .gitmodules<\/code><\/li>\n<li>Delete the relevant section from\u00a0<code>.git\/config<\/code>.<\/li>\n<li>Run\u00a0<code>git rm --cached path_to_submodule<\/code>\u00a0(no trailing slash).<\/li>\n<li>Run\u00a0<code>rm -rf .git\/modules\/path_to_submodule<\/code><\/li>\n<li>Commit<\/li>\n<li>Delete the now untracked submodule files<br \/>\n<code>rm -rf path_to_submodulegit<\/code><\/li>\n<\/ol>\n<p>Now simply clone wordpress into a directory \u00a0outside of the repo<br \/>\n<span style=\"color: #666666; font-family: monospace; font-size: 14px; line-height: 18px; white-space: pre-wrap;\"><br \/>\ngit clone\u00a0<\/span><span style=\"color: #666666; font-family: monospace; font-size: 14px; line-height: 18px; white-space: pre-wrap;\">https:\/\/github.com\/WordPress\/WordPress.git<\/span><\/p>\n<p>Create a new wp dir in the repo root<br \/>\nCopy everything except .* files to this dir (just skipping .git is not enough)<\/p>\n<pre>cp -r WordPress\/!(.*) destination_dir<\/pre>\n<p>Commit the changes<\/p>\n<p>Now add the bare repository as a remote to your local repo<\/p>\n<pre>git remote add hub webmaster@debaskist.nl@ftp.greenhost.nl:repos\/site_hub.git<\/pre>\n<p>merge remote, you may also delete the test.txt, and push back:<\/p>\n<pre>$ git fetch hub\r\n $ git merge hub\/master\r\n $ rm test.txt\r\n $ git commit -am 'removed test.txt'\r\n $ git push hub<\/pre>\n<h4>\u00a0<span style=\"color: #ff9900;\">Configure WAMP<\/span><\/h4>\n<p>If the local website is in a directory outside wamp\/www, you will have to define an alias:<\/p>\n<p>Go to wamp\/alias\/ ,\u00a0create a new file your_local_url.conf and put this in:<\/p>\n<pre>Alias \/your_local_url \"d:\/path_to_www\/\"\r\n\r\n&lt;Directory \"d:path_to_www\/\"&gt; \r\n    Options Indexes FollowSymLinks MultiViews\r\n    AllowOverride all\r\n        Order allow,deny\r\n    Allow from all\r\n&lt;\/Directory&gt;<\/pre>\n<p>Restart WAMP services<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install using Mark Jaquith&#8217;s method. This involves Handling differing database connection details Handling plugins that can\u2019t or shouldn\u2019t run on a localhost Create a local subdirectory. Then clone Mark Jaquith&#8217;s wp-skeleton into a new directory www. Or, if you already did the steps below, clone it directly from your own fork. Note: use recursive cloning [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/160"}],"collection":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":13,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/160\/revisions\/439"}],"wp:attachment":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}