Getting-starteds on Laradock http://laradock.io/getting-started/index.xml Recent content in Getting-starteds on Laradock Hugo -- gohugo.io en-us Getting Started http://laradock.io/getting-started/ Mon, 01 Jan 0001 00:00:00 +0000 http://laradock.io/getting-started/ <h2 id="requirements">Requirements</h2> <ul> <li><a href="https://git-scm.com/downloads">Git</a></li> <li><a href="https://www.docker.com/products/docker/">Docker</a> <code>&gt;= 1.12</code></li> </ul> <h2 id="installation">Installation</h2> <p>Choose the setup the best suits your needs.</p> <ul> <li><a href="#A">A) Setup for Single Project</a> <ul> <li><a href="#A1">A.1) Already have a PHP project</a></li> <li><a href="#A2">A.2) Don&rsquo;t have a PHP project yet</a></li> </ul></li> <li><a href="#B">B) Setup for Multiple Projects</a></li> </ul> <p><a name="A"></a></p> <h3 id="a-setup-for-single-project">A) Setup for Single Project</h3> <blockquote> <p>(Follow these steps if you want a separate Docker environment for each project)</p> </blockquote> <p><a name="A1"></a></p> <h3 id="a-1-already-have-a-php-project">A.1) Already have a PHP project:</h3> <blockquote> <p>(Follow these steps if you already have a PHP project, and all you need is an environment to run it)</p> </blockquote> <p>1 - Clone laradock on your project root directory:</p> <pre><code class="language-bash">git submodule add https://github.com/Laradock/laradock.git </code></pre> <p><strong>Notes:</strong></p> <ul> <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> <li><p>Note 2: To keep track of your Laradock changes, between your projects and also keep Laradock updated. <a href="#keep-tracking-Laradock">Check this</a></p></li> </ul> <p>Your folder structure should look like this:</p> <pre><code>- project-A - laradock-A - project-B - laradock-B </code></pre> <p>(It&rsquo;s important to rename the folders differently in each project)</p> <p><a name="A2"></a></p> <h3 id="a-2-don-t-have-a-php-project-yet">A.2) Don&rsquo;t have a PHP project yet:</h3> <blockquote> <p>(Follow these steps if you don&rsquo;t have a PHP project yet, and you need an environment to create the project)</p> </blockquote> <p>1 - Clone this repository anywhere on your machine:</p> <pre><code class="language-bash">git clone https://github.com/laradock/laradock.git </code></pre> <p>Your folder structure should look like this:</p> <pre><code>- laradock - Project-Z </code></pre> <p>2 - Edit the <code>docker-compose.yml</code> file to map to your project directory once you have it (example: <code>- ../Project-Z:/var/www</code>).</p> <p>3 - Stop and re-run your docker-compose command for the changes to take place.</p> <pre><code>docker-compose stop &amp;&amp; docker-compose up -d XXXX YYYY ZZZZ .... </code></pre> <p><a name="B"></a></p> <h3 id="b-setup-for-multiple-projects">B) Setup for Multiple Projects:</h3> <blockquote> <p>(Follow these steps if you want a single Docker environment for all project)</p> </blockquote> <p>1 - Clone this repository anywhere on your machine:</p> <pre><code class="language-bash">git clone https://github.com/laradock/laradock.git </code></pre> <p>2 - Edit the <code>docker-compose.yml</code> (or the <code>.env</code>) file to map to your projects directories:</p> <pre><code> applications: volumes: - ../project1/:/var/www/project1 - ../project2/:/var/www/project2 </code></pre> <p>3 - You can access all sites by visiting <code>http://localhost/project1/public</code> and <code>http://localhost/project2/public</code> but of course that&rsquo;s not very useful so let&rsquo;s setup NGINX quickly.</p> <p>4 - Go to <code>nginx/sites</code> and copy <code>sample.conf.example</code> to <code>project1.conf</code> then to <code>project2.conf</code></p> <p>5 - Open the <code>project1.conf</code> file and edit the <code>server_name</code> and the <code>root</code> as follow:</p> <pre><code> server_name project1.dev; root /var/www/project1/public; </code></pre> <p>Do the same for each project <code>project2.conf</code>, <code>project3.conf</code>,&hellip;</p> <p>6 - Add the domains to the <strong>hosts</strong> files.</p> <pre><code>127.0.0.1 project1.dev </code></pre> <p>7 - Create your project Databases. Right now you have to do it manually by entering your DB container, until we automate it soon.</p> <h2 id="usage">Usage</h2> <p><strong>Read Before starting:</strong></p> <p>If you are using <strong>Docker Toolbox</strong> (VM), do one of the following:</p> <ul> <li>Upgrade to Docker <a href="https://www.docker.com/products/docker">Native</a> for Mac/Windows (Recommended). Check out <a href="#upgrading-laradock">Upgrading Laradock</a></li> <li>Use Laradock v3.* (Visit the <code>Laradock-ToolBox</code> <a href="https://github.com/laradock/laradock/tree/Laradock-ToolBox">Branch</a>).</li> </ul> <p><br></p> <blockquote> <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> </blockquote> <p><br></p> <p>1 - Run Containers: <em>(Make sure you are in the <code>laradock</code> folder before running the <code>docker-compose</code> commands).</em></p> <p><strong>Example:</strong> Running NGINX and MySQL:</p> <pre><code class="language-bash">docker-compose up -d nginx mysql </code></pre> <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> <p>You can select your own combination of Containers form the list below:</p> <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>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> <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> <p><br> 2 - Enter the Workspace container, to execute commands like (Artisan, Composer, PHPUnit, Gulp, &hellip;).</p> <pre><code class="language-bash">docker-compose exec workspace bash </code></pre> <p>Alternatively, for Windows PowerShell users: execute the following command to enter any running container:</p> <pre><code class="language-bash">docker exec -it {workspace-container-id} bash </code></pre> <p><strong>Note:</strong> You can add <code>--user=laradock</code> to have files created as your host&rsquo;s user. Example:</p> <pre><code class="language-shell">docker-compose exec --user=laradock workspace bash </code></pre> <p><em>You can change the PUID (User id) and PGID (group id) variables from the <code>docker-compose.yml</code> or the <code>.env</code>)</em></p> <p><br> 3 - Edit your project configurations.</p> <p>Open your <code>.env</code> file and set the <code>DB_HOST</code> to <code>mysql</code>:</p> <pre><code class="language-env">DB_HOST=mysql </code></pre> <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> <p><br> 4 - Open your browser and visit your localhost address <code>http://localhost/</code>.</p>