From 6ada2f1b9121eba3da80263c977044d92bf9e396 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Thu, 16 Mar 2017 20:53:14 -0400 Subject: [PATCH] nginx samples sites for multiple projects - add `project-1.conf` and `project-1.conf` to match the docs. - keep default to work with both multiple and single projects. - delete the .gitignore. - update docker-compose and example-env file to match the new settings - update the docs - delete `laravel-https.conf` to replace it with documentation instead --- .../content/getting-started/index.md | 64 ++++++++++--------- docker-compose.yml | 2 +- docs/getting-started/index.html | 61 +++++++++--------- docs/getting-started/index.xml | 61 +++++++++--------- docs/index.html | 61 +++++++++--------- docs/index.xml | 61 +++++++++--------- env-example | 1 - nginx/sites/.gitignore | 2 - nginx/sites/default.conf | 2 +- .../{sample.conf.example => project-1.conf} | 11 +++- .../{laravel-https.conf => project-2.conf} | 21 +++--- 11 files changed, 181 insertions(+), 166 deletions(-) delete mode 100644 nginx/sites/.gitignore rename nginx/sites/{sample.conf.example => project-1.conf} (64%) rename nginx/sites/{laravel-https.conf => project-2.conf} (60%) diff --git a/DOCUMENTATION/_settings/content/getting-started/index.md b/DOCUMENTATION/_settings/content/getting-started/index.md index 1cd90791..bee1d369 100644 --- a/DOCUMENTATION/_settings/content/getting-started/index.md +++ b/DOCUMENTATION/_settings/content/getting-started/index.md @@ -50,10 +50,10 @@ git submodule add https://github.com/Laradock/laradock.git Your folder structure should look like this: ``` -- project-A - - laradock-A -- project-B - - laradock-B ++ project-a + + laradock-a ++ project-b + + laradock-b ``` (It's important to rename the folders differently in each project) @@ -71,57 +71,59 @@ git clone https://github.com/laradock/laradock.git Your folder structure should look like this: ``` -- laradock -- Project-Z ++ laradock ++ project-z ``` -2 - Edit the `docker-compose.yml` file to map to your project directory once you have it (example: `- ../Project-Z:/var/www`). +2 - Edit your web server sites configuration. -3 - Stop and re-run your docker-compose command for the changes to take place. +**In case of NGINX:** open `nginx/sites/default.conf` and change the `root` from `/var/www/public` to `/var/www/{my-project-folder-name}/public`. + +*Or you can keep `default.conf` as it is, and create a separate config `my-site.conf` file for it.* + +**In case of Apache:** :P + +3 - Run your `docker-compose up` command and you're ready to go. + +*Note: if you already had your containers up, you might need to take them down first and rebuild them for the changes to take effect.* -``` -docker-compose stop && docker-compose up -d XXXX YYYY ZZZZ .... -``` ### B) Setup for Multiple Projects: -> (Follow these steps if you want a single Docker environment for all project) +> (Follow these steps if you want a single Docker environment for all your project) -1 - Clone this repository anywhere on your machine: +1 - Clone this repository anywhere on your machine (similar to [Steps A.2. from above](#A2)): ```bash git clone https://github.com/laradock/laradock.git ``` -2 - Edit the `docker-compose.yml` (or the `.env`) file to map to your projects directories: +Your folder structure should look like this: ``` - applications: - volumes: - - ../project1/:/var/www/project1 - - ../project2/:/var/www/project2 ++ laradock ++ project-1 ++ project-2 ``` -3 - You can access all sites by visiting `http://localhost/project1/public` and `http://localhost/project2/public` but of course that's not very useful so let's setup NGINX quickly. +2 - Go to `nginx/sites` and create config files to point to different project directory when visiting different domains. +Laradock by default includes `project-1.conf` and `project-2.conf` as working samples. -4 - Go to `nginx/sites` and copy `sample.conf.example` to `project1.conf` then to `project2.conf` +3 - change the default names `project-n`: -5 - Open the `project1.conf` file and edit the `server_name` and the `root` as follow: +You can rename the config files, project folders and domains as you like, just make sure the `root` in the config files, is pointing to the correct project folder name. + +4 - Add the domains to the **hosts** files. ``` - server_name project1.dev; - root /var/www/project1/public; -``` -Do the same for each project `project2.conf`, `project3.conf`,... - -6 - Add the domains to the **hosts** files. - -``` -127.0.0.1 project1.dev +127.0.0.1 project-1.dev +127.0.0.1 project-2.dev ``` -7 - Create your project Databases. Right now you have to do it manually by entering your DB container, until we automate it soon. +5 - Visit `http://project-1.dev/` and `http://project-2.dev/`. + + diff --git a/docker-compose.yml b/docker-compose.yml index 4bda231b..2477451e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: applications: image: tianon/true volumes: - - ${APPLICATION_1}:/var/www + - ${APPLICATION}:/var/www ### Workspace Utilities Container ########################### diff --git a/docs/getting-started/index.html b/docs/getting-started/index.html index 9e8e8825..4a8830e9 100644 --- a/docs/getting-started/index.html +++ b/docs/getting-started/index.html @@ -365,10 +365,10 @@

Your folder structure should look like this:

-
- project-A
-	- laradock-A
-- project-B
-	- laradock-B
+
+ project-a
+	+ laradock-a
++ project-b
+	+ laradock-b
 

(It’s important to rename the folders differently in each project)

@@ -388,56 +388,57 @@

Your folder structure should look like this:

-
- laradock
-- Project-Z
+
+ laradock
++ project-z
 
-

2 - Edit the docker-compose.yml file to map to your project directory once you have it (example: - ../Project-Z:/var/www).

+

2 - Edit your web server sites configuration.

-

3 - Stop and re-run your docker-compose command for the changes to take place.

+

In case of NGINX: open nginx/sites/default.conf and change the root from /var/www/public to /var/www/{my-project-folder-name}/public.

-
docker-compose stop && docker-compose up -d XXXX YYYY ZZZZ ....
-
+

Or you can keep default.conf as it is, and create a separate config my-site.conf file for it.

+ +

In case of Apache: :P

+ +

3 - Run your docker-compose up command and you’re ready to go.

+ +

Note: if you already had your containers up, you might need to take them down first and rebuild them for the changes to take effect.

B) Setup for Multiple Projects:

-

(Follow these steps if you want a single Docker environment for all project)

+

(Follow these steps if you want a single Docker environment for all your project)

-

1 - Clone this repository anywhere on your machine:

+

1 - Clone this repository anywhere on your machine (similar to Steps A.2. from above):

git clone https://github.com/laradock/laradock.git
 
-

2 - Edit the docker-compose.yml (or the .env) file to map to your projects directories:

+

Your folder structure should look like this:

-
    applications:
-        volumes:
-            - ../project1/:/var/www/project1
-            - ../project2/:/var/www/project2
+
+ laradock
++ project-1
++ project-2
 
-

3 - You can access all sites by visiting http://localhost/project1/public and http://localhost/project2/public but of course that’s not very useful so let’s setup NGINX quickly.

+

2 - Go to nginx/sites and create config files to point to different project directory when visiting different domains.

-

4 - Go to nginx/sites and copy sample.conf.example to project1.conf then to project2.conf

+

Laradock by default includes project-1.conf and project-2.conf as working samples.

-

5 - Open the project1.conf file and edit the server_name and the root as follow:

+

3 - change the default names project-n:

-
    server_name project1.dev;
-    root /var/www/project1/public;
+

You can rename the config files, project folders and domains as you like, just make sure the root in the config files, is pointing to the correct project folder name.

+ +

4 - Add the domains to the hosts files.

+ +
127.0.0.1  project-1.dev
+127.0.0.1  project-2.dev
 
-

Do the same for each project project2.conf, project3.conf,…

- -

6 - Add the domains to the hosts files.

- -
127.0.0.1  project1.dev
-
- -

7 - Create your project Databases. Right now you have to do it manually by entering your DB container, until we automate it soon.

+

5 - Visit http://project-1.dev/ and http://project-2.dev/.

Usage

diff --git a/docs/getting-started/index.xml b/docs/getting-started/index.xml index 0ab36543..86c3dfc3 100644 --- a/docs/getting-started/index.xml +++ b/docs/getting-started/index.xml @@ -68,10 +68,10 @@ <p>Your folder structure should look like this:</p> -<pre><code>- project-A - - laradock-A -- project-B - - laradock-B +<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> @@ -91,56 +91,57 @@ <p>Your folder structure should look like this:</p> -<pre><code>- laradock -- Project-Z +<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>2 - Edit your web server sites configuration.</p> -<p>3 - Stop and re-run your docker-compose command for the changes to take place.</p> +<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> -<pre><code>docker-compose stop &amp;&amp; docker-compose up -d XXXX YYYY ZZZZ .... -</code></pre> +<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> + +<p><strong>In case of Apache:</strong> :P</p> + +<p>3 - Run your <code>docker-compose up</code> command and you&rsquo;re ready to go.</p> + +<p><em>Note: if you already had your containers up, you might need to take them down first and rebuild them for the changes to take effect.</em></p> <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> +<p>(Follow these steps if you want a single Docker environment for all your project)</p> </blockquote> -<p>1 - Clone this repository anywhere on your machine:</p> +<p>1 - Clone this repository anywhere on your machine (similar to <a href="#A2">Steps A.2. from above</a>):</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> +<p>Your folder structure should look like this:</p> -<pre><code> applications: - volumes: - - ../project1/:/var/www/project1 - - ../project2/:/var/www/project2 +<pre><code>+ laradock ++ project-1 ++ project-2 </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>2 - Go to <code>nginx/sites</code> and create config files to point to different project directory when visiting different domains.</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>Laradock by default includes <code>project-1.conf</code> and <code>project-2.conf</code> as working samples.</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> +<p>3 - change the default names <code>project-n</code>:</p> -<pre><code> server_name project1.dev; - root /var/www/project1/public; +<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> + +<p>4 - Add the domains to the <strong>hosts</strong> files.</p> + +<pre><code>127.0.0.1 project-1.dev +127.0.0.1 project-2.dev </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> +<p>5 - Visit <code>http://project-1.dev/</code> and <code>http://project-2.dev/</code>.</p> <h2 id="usage">Usage</h2> diff --git a/docs/index.html b/docs/index.html index de0efabe..bdd7fd40 100644 --- a/docs/index.html +++ b/docs/index.html @@ -563,10 +563,10 @@ QUEUE_HOST=beanstalkd

Your folder structure should look like this:

-
- project-A
-	- laradock-A
-- project-B
-	- laradock-B
+
+ project-a
+	+ laradock-a
++ project-b
+	+ laradock-b
 

(It’s important to rename the folders differently in each project)

@@ -586,56 +586,57 @@ QUEUE_HOST=beanstalkd

Your folder structure should look like this:

-
- laradock
-- Project-Z
+
+ laradock
++ project-z
 
-

2 - Edit the docker-compose.yml file to map to your project directory once you have it (example: - ../Project-Z:/var/www).

+

2 - Edit your web server sites configuration.

-

3 - Stop and re-run your docker-compose command for the changes to take place.

+

In case of NGINX: open nginx/sites/default.conf and change the root from /var/www/public to /var/www/{my-project-folder-name}/public.

-
docker-compose stop && docker-compose up -d XXXX YYYY ZZZZ ....
-
+

Or you can keep default.conf as it is, and create a separate config my-site.conf file for it.

+ +

In case of Apache: :P

+ +

3 - Run your docker-compose up command and you’re ready to go.

+ +

Note: if you already had your containers up, you might need to take them down first and rebuild them for the changes to take effect.

B) Setup for Multiple Projects:

-

(Follow these steps if you want a single Docker environment for all project)

+

(Follow these steps if you want a single Docker environment for all your project)

-

1 - Clone this repository anywhere on your machine:

+

1 - Clone this repository anywhere on your machine (similar to Steps A.2. from above):

git clone https://github.com/laradock/laradock.git
 
-

2 - Edit the docker-compose.yml (or the .env) file to map to your projects directories:

+

Your folder structure should look like this:

-
    applications:
-        volumes:
-            - ../project1/:/var/www/project1
-            - ../project2/:/var/www/project2
+
+ laradock
++ project-1
++ project-2
 
-

3 - You can access all sites by visiting http://localhost/project1/public and http://localhost/project2/public but of course that’s not very useful so let’s setup NGINX quickly.

+

2 - Go to nginx/sites and create config files to point to different project directory when visiting different domains.

-

4 - Go to nginx/sites and copy sample.conf.example to project1.conf then to project2.conf

+

Laradock by default includes project-1.conf and project-2.conf as working samples.

-

5 - Open the project1.conf file and edit the server_name and the root as follow:

+

3 - change the default names project-n:

-
    server_name project1.dev;
-    root /var/www/project1/public;
+

You can rename the config files, project folders and domains as you like, just make sure the root in the config files, is pointing to the correct project folder name.

+ +

4 - Add the domains to the hosts files.

+ +
127.0.0.1  project-1.dev
+127.0.0.1  project-2.dev
 
-

Do the same for each project project2.conf, project3.conf,…

- -

6 - Add the domains to the hosts files.

- -
127.0.0.1  project1.dev
-
- -

7 - Create your project Databases. Right now you have to do it manually by entering your DB container, until we automate it soon.

+

5 - Visit http://project-1.dev/ and http://project-2.dev/.

Usage

diff --git a/docs/index.xml b/docs/index.xml index 0f55b4dc..fcad27e4 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -270,10 +270,10 @@ QUEUE_HOST=beanstalkd <p>Your folder structure should look like this:</p> -<pre><code>- project-A - - laradock-A -- project-B - - laradock-B +<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> @@ -293,56 +293,57 @@ QUEUE_HOST=beanstalkd <p>Your folder structure should look like this:</p> -<pre><code>- laradock -- Project-Z +<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>2 - Edit your web server sites configuration.</p> -<p>3 - Stop and re-run your docker-compose command for the changes to take place.</p> +<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> -<pre><code>docker-compose stop &amp;&amp; docker-compose up -d XXXX YYYY ZZZZ .... -</code></pre> +<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> + +<p><strong>In case of Apache:</strong> :P</p> + +<p>3 - Run your <code>docker-compose up</code> command and you&rsquo;re ready to go.</p> + +<p><em>Note: if you already had your containers up, you might need to take them down first and rebuild them for the changes to take effect.</em></p> <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> +<p>(Follow these steps if you want a single Docker environment for all your project)</p> </blockquote> -<p>1 - Clone this repository anywhere on your machine:</p> +<p>1 - Clone this repository anywhere on your machine (similar to <a href="#A2">Steps A.2. from above</a>):</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> +<p>Your folder structure should look like this:</p> -<pre><code> applications: - volumes: - - ../project1/:/var/www/project1 - - ../project2/:/var/www/project2 +<pre><code>+ laradock ++ project-1 ++ project-2 </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>2 - Go to <code>nginx/sites</code> and create config files to point to different project directory when visiting different domains.</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>Laradock by default includes <code>project-1.conf</code> and <code>project-2.conf</code> as working samples.</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> +<p>3 - change the default names <code>project-n</code>:</p> -<pre><code> server_name project1.dev; - root /var/www/project1/public; +<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> + +<p>4 - Add the domains to the <strong>hosts</strong> files.</p> + +<pre><code>127.0.0.1 project-1.dev +127.0.0.1 project-2.dev </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> +<p>5 - Visit <code>http://project-1.dev/</code> and <code>http://project-2.dev/</code>.</p> <h2 id="usage">Usage</h2> diff --git a/env-example b/env-example index 191b5868..d13094eb 100644 --- a/env-example +++ b/env-example @@ -1,6 +1,5 @@ ### Application # Point to your application code, wish should be available at `/var/www` -APPLICATION_1=../ ### PHP version (Does not apply for HHVM) # PHP_VERSION=55 diff --git a/nginx/sites/.gitignore b/nginx/sites/.gitignore deleted file mode 100644 index dcb7ef9e..00000000 --- a/nginx/sites/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.conf -!default.conf diff --git a/nginx/sites/default.conf b/nginx/sites/default.conf index 59e4e2da..bb7525ca 100644 --- a/nginx/sites/default.conf +++ b/nginx/sites/default.conf @@ -3,7 +3,7 @@ server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; - server_name laradock; + server_name locahost; root /var/www/public; index index.php index.html index.htm; diff --git a/nginx/sites/sample.conf.example b/nginx/sites/project-1.conf similarity index 64% rename from nginx/sites/sample.conf.example rename to nginx/sites/project-1.conf index e6520e59..011213a6 100644 --- a/nginx/sites/sample.conf.example +++ b/nginx/sites/project-1.conf @@ -3,8 +3,8 @@ server { listen 80; listen [::]:80; - server_name sample.dev; - root /var/www/sample/public; + server_name project-1.dev; + root /var/www/project-1/public; index index.php index.html index.htm; location / { @@ -15,6 +15,8 @@ server { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } @@ -22,6 +24,11 @@ server { location ~ /\.ht { deny all; } + + location /.well-known/acme-challenge/ { + root /var/www/letsencrypt/; + log_not_found off; + } } diff --git a/nginx/sites/laravel-https.conf b/nginx/sites/project-2.conf similarity index 60% rename from nginx/sites/laravel-https.conf rename to nginx/sites/project-2.conf index 2c0b0bf2..590c1a55 100644 --- a/nginx/sites/laravel-https.conf +++ b/nginx/sites/project-2.conf @@ -1,14 +1,10 @@ server { - listen 443 default_server; - listen [::]:443 default_server ipv6only=on; + listen 80; + listen [::]:80; - #ssl on; - #ssl_certificate /var/certs/cert1.pem; - #ssl_certificate_key /var/certs/privkey1.pem; - - server_name laravel; - root /var/www/laravel/public; + server_name project-2.dev; + root /var/www/project-2/public; index index.php index.html index.htm; location / { @@ -19,6 +15,8 @@ server { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } @@ -27,4 +25,11 @@ server { deny all; } + location /.well-known/acme-challenge/ { + root /var/www/letsencrypt/; + log_not_found off; + } } + + +