index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. <!DOCTYPE html>
  2. <html class="no-js">
  3. <head lang="en-us">
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=10" />
  7. <title>Getting Started - Laradock</title>
  8. <meta name="generator" content="Hugo 0.19" />
  9. <meta name="description" content="Laradock documentations.">
  10. <link rel="canonical" href="http://laradock.io/getting-started/">
  11. <meta name="author" content="Mahmoud Zalt">
  12. <meta property="og:url" content="http://laradock.io/getting-started/">
  13. <meta property="og:title" content="Laradock">
  14. <meta name="apple-mobile-web-app-title" content="Laradock">
  15. <meta name="apple-mobile-web-app-capable" content="yes">
  16. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  17. <link rel="shortcut icon" type="image/x-icon" href="http://laradock.io/images/favicon.ico">
  18. <link rel="icon" type="image/x-icon" href="http://laradock.io/images/favicon.ico">
  19. <style>
  20. @font-face {
  21. font-family: 'Icon';
  22. src: url('http://laradock.io/fonts/icon.eot');
  23. src: url('http://laradock.io/fonts/icon.eot')
  24. format('embedded-opentype'),
  25. url('http://laradock.io/fonts/icon.woff')
  26. format('woff'),
  27. url('http://laradock.io/fonts/icon.ttf')
  28. format('truetype'),
  29. url('http://laradock.io/fonts/icon.svg')
  30. format('svg');
  31. font-weight: normal;
  32. font-style: normal;
  33. }
  34. </style>
  35. <link rel="stylesheet" href="http://laradock.io/stylesheets/application.css">
  36. <link rel="stylesheet" href="http://laradock.io/stylesheets/temporary.css">
  37. <link rel="stylesheet" href="http://laradock.io/stylesheets/palettes.css">
  38. <link rel="stylesheet" href="http://laradock.io/stylesheets/highlight/highlight.css">
  39. <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Doctarine:400,700|Source&#43;Code&#43;Pro">
  40. <style>
  41. body, input {
  42. font-family: 'Doctarine', Helvetica, Arial, sans-serif;
  43. }
  44. pre, code {
  45. font-family: 'Source Code Pro', 'Courier New', 'Courier', monospace;
  46. }
  47. </style>
  48. <script src="http://laradock.io/javascripts/modernizr.js"></script>
  49. </head>
  50. <body class="palette-primary-deep-purple palette-accent-purple">
  51. <div class="backdrop">
  52. <div class="backdrop-paper"></div>
  53. </div>
  54. <input class="toggle" type="checkbox" id="toggle-drawer">
  55. <input class="toggle" type="checkbox" id="toggle-search">
  56. <label class="toggle-button overlay" for="toggle-drawer"></label>
  57. <header class="header">
  58. <nav aria-label="Header">
  59. <div class="bar default">
  60. <div class="button button-menu" role="button" aria-label="Menu">
  61. <label class="toggle-button icon icon-menu" for="toggle-drawer">
  62. <span></span>
  63. </label>
  64. </div>
  65. <div class="stretch">
  66. <div class="title">
  67. <b>Laradock</b> <span style="color: rgba(249, 245, 255, 0.63);"> / Getting Started</span>
  68. </div>
  69. </div>
  70. <div class="button button-github" role="button" aria-label="GitHub">
  71. <a style="padding: 0px; font-size:40px" href="https://github.com/laradock/laradock" title="@laradock/laradock on GitHub" target="_blank" class="toggle-button icon icon-github"></a>
  72. </div>
  73. <p style="font-size: 18px; padding: 8px">Github</p>
  74. </div>
  75. <div class="bar search">
  76. <div class="button button-close" role="button" aria-label="Close">
  77. <label class="toggle-button icon icon-back" for="toggle-search"></label>
  78. </div>
  79. <div class="stretch">
  80. <div class="field">
  81. <input class="query" type="text" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck>
  82. </div>
  83. </div>
  84. <div class="button button-reset" role="button" aria-label="Search">
  85. <button class="toggle-button icon icon-close" id="reset-search"></button>
  86. </div>
  87. </div>
  88. </nav>
  89. </header>
  90. <main class="main">
  91. <div class="drawer">
  92. <nav aria-label="Navigation">
  93. <div class="scrollable">
  94. <div class="wrapper">
  95. <div class="toc">
  96. <ul>
  97. <li>
  98. <a title="Introduction" href="http://laradock.io/introduction/">
  99. Introduction
  100. </a>
  101. </li>
  102. <li>
  103. <a class="current" title="Getting Started" href="http://laradock.io/getting-started/">
  104. Getting Started
  105. </a>
  106. <ul id="scrollspy">
  107. </ul>
  108. </li>
  109. <li>
  110. <a title="Documentation" href="http://laradock.io/documentation/">
  111. Documentation
  112. </a>
  113. </li>
  114. <li>
  115. <a title="Related Projects" href="http://laradock.io/related-projects/">
  116. Related Projects
  117. </a>
  118. </li>
  119. <li>
  120. <a title="Help &amp; Questions" href="http://laradock.io/help/">
  121. Help &amp; Questions
  122. </a>
  123. </li>
  124. <li>
  125. <a title="Contributing" href="http://laradock.io/contributing/">
  126. Contributing
  127. </a>
  128. </li>
  129. <li>
  130. <a title="License" href="http://laradock.io/license/">
  131. License
  132. </a>
  133. </li>
  134. </ul>
  135. <ul>
  136. </ul>
  137. </div>
  138. </div>
  139. </div>
  140. </nav>
  141. </div>
  142. <article class="article">
  143. <div class="wrapper">
  144. <h1>Getting Started </h1>
  145. <h2 id="requirements">Requirements</h2>
  146. <ul>
  147. <li><a href="https://git-scm.com/downloads">Git</a></li>
  148. <li><a href="https://www.docker.com/products/docker/">Docker</a> <code>&gt;= 1.12</code></li>
  149. </ul>
  150. <h2 id="installation">Installation</h2>
  151. <p>Choose the setup the best suits your needs.</p>
  152. <ul>
  153. <li><a href="#A">A) Setup for Single Project</a>
  154. <ul>
  155. <li><a href="#A1">A.1) Already have a PHP project</a></li>
  156. <li><a href="#A2">A.2) Don&rsquo;t have a PHP project yet</a></li>
  157. </ul></li>
  158. <li><a href="#B">B) Setup for Multiple Projects</a></li>
  159. </ul>
  160. <p><a name="A"></a></p>
  161. <h3 id="a-setup-for-single-project">A) Setup for Single Project</h3>
  162. <blockquote>
  163. <p>(Follow these steps if you want a separate Docker environment for each project)</p>
  164. </blockquote>
  165. <p><a name="A1"></a></p>
  166. <h3 id="a-1-already-have-a-php-project">A.1) Already have a PHP project:</h3>
  167. <p>1 - Clone laradock on your project root directory:</p>
  168. <pre><code class="language-bash">git submodule add https://github.com/Laradock/laradock.git
  169. </code></pre>
  170. <p><strong>Notes:</strong></p>
  171. <ul>
  172. <li><p>If you are not using Git yet for your project, you can use <code>git clone</code> instead of <code>git submodule</code>.</p></li>
  173. <li><p>Note 2: To keep track of your Laradock changes, between your projects and also keep Laradock updated. <a href="http://laradock.io/documentation/#keep-track-of-your-laradock-changes">Check this</a></p></li>
  174. </ul>
  175. <p>Your folder structure should look like this:</p>
  176. <pre><code>+ project-a
  177. + laradock-a
  178. + project-b
  179. + laradock-b
  180. </code></pre>
  181. <p>(It&rsquo;s important to rename the folders differently in each project.)</p>
  182. <blockquote>
  183. <p><strong>Now jump to the <a href="#Usage">Usage</a> section.</strong></p>
  184. </blockquote>
  185. <p><a name="A2"></a></p>
  186. <h3 id="a-2-don-t-have-a-php-project-yet">A.2) Don&rsquo;t have a PHP project yet:</h3>
  187. <p>1 - Clone this repository anywhere on your machine:</p>
  188. <pre><code class="language-bash">git clone https://github.com/laradock/laradock.git
  189. </code></pre>
  190. <p>Your folder structure should look like this:</p>
  191. <pre><code>+ laradock
  192. + project-z
  193. </code></pre>
  194. <p>2 - Edit your web server sites configuration.</p>
  195. <p><strong>In case of NGINX:</strong> open <code>nginx/sites/default.conf</code> and change the <code>root</code> from <code>/var/www/public</code> to <code>/var/www/{my-project-folder-name}/public</code>.</p>
  196. <p><em>Or you can keep <code>default.conf</code> as it is, and create a separate config <code>my-site.conf</code> file for it.</em></p>
  197. <p><strong>In case of Apache:</strong> :P</p>
  198. <p><br></p>
  199. <blockquote>
  200. <p><strong>Now jump to the <a href="#Usage">Usage</a> section.</strong></p>
  201. </blockquote>
  202. <p><a name="B"></a></p>
  203. <h3 id="b-setup-for-multiple-projects">B) Setup for Multiple Projects:</h3>
  204. <blockquote>
  205. <p>(Follow these steps if you want a single Docker environment for all your project)</p>
  206. </blockquote>
  207. <p>1 - Clone this repository anywhere on your machine (similar to <a href="#A2">Steps A.2. from above</a>):</p>
  208. <pre><code class="language-bash">git clone https://github.com/laradock/laradock.git
  209. </code></pre>
  210. <p>Your folder structure should look like this:</p>
  211. <pre><code>+ laradock
  212. + project-1
  213. + project-2
  214. </code></pre>
  215. <p>2 - Go to <code>nginx/sites</code> and create config files to point to different project directory when visiting different domains.</p>
  216. <p>Laradock by default includes <code>project-1.conf</code> and <code>project-2.conf</code> as working samples.</p>
  217. <p>3 - change the default names <code>project-n</code>:</p>
  218. <p>You can rename the config files, project folders and domains as you like, just make sure the <code>root</code> in the config files, is pointing to the correct project folder name.</p>
  219. <p>4 - Add the domains to the <strong>hosts</strong> files.</p>
  220. <pre><code>127.0.0.1 project-1.dev
  221. 127.0.0.1 project-2.dev
  222. </code></pre>
  223. <blockquote>
  224. <p><strong>Now jump to the <a href="#Usage">Usage</a> section.</strong></p>
  225. </blockquote>
  226. <p><a name="Usage"></a></p>
  227. <h2 id="usage">Usage</h2>
  228. <p><strong>Read Before starting:</strong></p>
  229. <p>If you are using <strong>Docker Toolbox</strong> (VM), do one of the following:</p>
  230. <ul>
  231. <li>Upgrade to Docker <a href="https://www.docker.com/products/docker">Native</a> for Mac/Windows (Recommended). Check out <a href="http://laradock.io/documentation/#upgrading-laradock">Upgrading Laradock</a></li>
  232. <li>Use Laradock v3.*. Visit the <a href="https://github.com/laradock/laradock/tree/LaraDock-ToolBox">LaraDock-ToolBox</a> branch. <em>(outdated)</em></li>
  233. </ul>
  234. <p><br></p>
  235. <blockquote>
  236. <p><strong>Warning:</strong> If you used an older version of Laradock it&rsquo;s highly recommended to rebuild the containers you need to use <a href="#Build-Re-build-Containers">see how you rebuild a container</a> in order to prevent as much errors as possible.</p>
  237. </blockquote>
  238. <p><br></p>
  239. <p>1 - Enter the laradock folder and rename <code>env-example</code> to <code>.env</code></p>
  240. <pre><code class="language-shell">cp env-example .env
  241. </code></pre>
  242. <p>You can edit the <code>.env</code> file to chose which software&rsquo;s you want to be installed in your environment. You can always refer to the <code>docker-compose.yml</code> file to see how those variables are been used.</p>
  243. <p>2 - Build the enviroment and run it using <code>docker-compose</code></p>
  244. <p>In this example we&rsquo;ll see how to run NGINX (web server) and MySQL (database engine) to host a PHP Web Scripts:</p>
  245. <pre><code class="language-bash">docker-compose up -d nginx mysql
  246. </code></pre>
  247. <p><strong>Note</strong>: The <code>workspace</code> and <code>php-fpm</code> will run automatically in most of the cases, so no need to specify them in the <code>up</code> command. If you couldn&rsquo;t find them running then you need specify them as follow: <code>docker-compose up -d nginx php-fpm mysql workspace</code>.</p>
  248. <p>You can select your own combination of containers form the list below:</p>
  249. <blockquote>
  250. <p><code>nginx</code>, <code>hhvm</code>, <code>php-fpm</code>, <code>mysql</code>, <code>redis</code>, <code>postgres</code>, <code>mariadb</code>, <code>neo4j</code>, <code>mongo</code>, <code>apache2</code>, <code>caddy</code>, <code>memcached</code>, <code>beanstalkd</code>, <code>beanstalkd-console</code>, <code>rabbitmq</code>, <code>beanstalkd-console</code>, <code>workspace</code>, <code>phpmyadmin</code>, <code>adminer</code>, <code>aerospike</code>, <code>pgadmin</code>, <code>elasticsearch</code>, <code>rethinkdb</code>, <code>postgres-postgis</code>, <code>certbot</code>, <code>mailhog</code>, <code>minio</code> and more&hellip;!</p>
  251. </blockquote>
  252. <p><em>(Please note that sometimes we forget to update the docs, so check the <code>docker-compose.yml</code> file to see an updated list of all available containers).</em></p>
  253. <p><br>
  254. 3 - Enter the Workspace container, to execute commands like (Artisan, Composer, PHPUnit, Gulp, &hellip;)</p>
  255. <pre><code class="language-bash">docker-compose exec workspace bash
  256. </code></pre>
  257. <p><em>Alternatively, for Windows PowerShell users: execute the following command to enter any running container:</em></p>
  258. <pre><code class="language-bash">docker exec -it {workspace-container-id} bash
  259. </code></pre>
  260. <p><strong>Note:</strong> You can add <code>--user=laradock</code> to have files created as your host&rsquo;s user. Example:</p>
  261. <pre><code class="language-shell">docker-compose exec --user=laradock workspace bash
  262. </code></pre>
  263. <p><em>You can change the PUID (User id) and PGID (group id) variables from the <code>.env</code> file)</em></p>
  264. <p><br>
  265. 4 - Update your project configurations to use the database host</p>
  266. <p>Open your PHP project&rsquo;s <code>.env</code> file or whichever configuration file you are reading from, and set the database host <code>DB_HOST</code> to <code>mysql</code>:</p>
  267. <pre><code class="language-env">DB_HOST=mysql
  268. </code></pre>
  269. <p><em>If you want to install Laravel as PHP project, see <a href="#Install-Laravel">How to Install Laravel in a Docker Container</a>.</em></p>
  270. <p><br>
  271. 5 - Open your browser and visit your localhost address <code>http://localhost/</code>. If you followed the multiple projects setup, you can visit <code>http://project-1.dev/</code> and <code>http://project-2.dev/</code>. But first don&rsquo;t</p>
  272. <aside class="copyright" role="note">
  273. Documentation built with
  274. <a href="https://www.gohugo.io" target="_blank">Hugo</a>
  275. using the
  276. <a href="http://github.com/digitalcraftsman/hugo-material-docs" target="_blank">Material</a> theme.
  277. </aside>
  278. <footer class="footer">
  279. <nav class="pagination" aria-label="Footer">
  280. <div class="previous">
  281. <a href="http://laradock.io/introduction/" title="Introduction">
  282. <span class="direction">
  283. Previous
  284. </span>
  285. <div class="page">
  286. <div class="button button-previous" role="button" aria-label="Previous">
  287. <i class="icon icon-back"></i>
  288. </div>
  289. <div class="stretch">
  290. <div class="title">
  291. Introduction
  292. </div>
  293. </div>
  294. </div>
  295. </a>
  296. </div>
  297. <div class="next">
  298. <a href="http://laradock.io/documentation/" title="Documentation">
  299. <span class="direction">
  300. Next
  301. </span>
  302. <div class="page">
  303. <div class="stretch">
  304. <div class="title">
  305. Documentation
  306. </div>
  307. </div>
  308. <div class="button button-next" role="button" aria-label="Next">
  309. <i class="icon icon-forward"></i>
  310. </div>
  311. </div>
  312. </a>
  313. </div>
  314. </nav>
  315. </footer>
  316. </div>
  317. </article>
  318. <div class="results" role="status" aria-live="polite">
  319. <div class="scrollable">
  320. <div class="wrapper">
  321. <div class="meta"></div>
  322. <div class="list"></div>
  323. </div>
  324. </div>
  325. </div>
  326. </main>
  327. <script>
  328. var base_url = '';
  329. var repo_id = '';
  330. </script>
  331. <script src="http://laradock.io/javascripts/application.js"></script>
  332. <script>
  333. /* Add headers to scrollspy */
  334. var headers = document.getElementsByTagName("h2");
  335. var scrollspy = document.getElementById('scrollspy');
  336. if(scrollspy) {
  337. if(headers.length > 0) {
  338. for(var i = 0; i < headers.length; i++) {
  339. var li = document.createElement("li");
  340. li.setAttribute("class", "anchor");
  341. var a = document.createElement("a");
  342. a.setAttribute("href", "#" + headers[i].id);
  343. a.setAttribute("title", headers[i].innerHTML);
  344. a.innerHTML = headers[i].innerHTML;
  345. li.appendChild(a)
  346. scrollspy.appendChild(li);
  347. }
  348. } else {
  349. scrollspy.parentElement.removeChild(scrollspy)
  350. }
  351. /* Add permanent link next to the headers */
  352. var headers = document.querySelectorAll("h1, h2, h3, h4, h5, h6");
  353. for(var i = 0; i < headers.length; i++) {
  354. var a = document.createElement("a");
  355. a.setAttribute("class", "headerlink");
  356. a.setAttribute("href", "#" + headers[i].id);
  357. a.setAttribute("title", "Permanent link")
  358. a.innerHTML = "#";
  359. headers[i].appendChild(a);
  360. }
  361. }
  362. </script>
  363. <script>
  364. (function(i,s,o,g,r,a,m){
  365. i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||
  366. []).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  367. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;
  368. m.parentNode.insertBefore(a,m)
  369. })(window, document,
  370. 'script', '//www.google-analytics.com/analytics.js', 'ga');
  371. ga('create', 'UA-37514928-9', 'auto');
  372. ga('set', 'anonymizeIp', true);
  373. ga('send', 'pageview');
  374. var buttons = document.querySelectorAll('a');
  375. Array.prototype.map.call(buttons, function(item) {
  376. if (item.host != document.location.host) {
  377. item.addEventListener('click', function() {
  378. var action = item.getAttribute('data-action') || 'follow';
  379. ga('send', 'event', 'outbound', action, item.href);
  380. });
  381. }
  382. });
  383. var query = document.querySelector('.query');
  384. query.addEventListener('blur', function() {
  385. if (this.value) {
  386. var path = document.location.pathname;
  387. ga('send', 'pageview', path + '?q=' + this.value);
  388. }
  389. });
  390. </script>
  391. <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js"></script>
  392. <script>hljs.initHighlightingOnLoad();</script>
  393. </body>
  394. </html>