{"_id":"59365227e16643001bac503c","category":{"_id":"59365227e16643001bac5032","version":"59365226e16643001bac5030","project":"543026235eceb608003fde5f","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-06-05T10:03:36.502Z","from_sync":false,"order":1,"slug":"getting-started-from-supportghostorgdevelopers","title":"Self-Host Install & Setup"},"project":"543026235eceb608003fde5f","user":"55acc88c6b4ff90d00784b61","parentDoc":null,"version":{"_id":"59365226e16643001bac5030","project":"543026235eceb608003fde5f","__v":1,"createdAt":"2017-06-06T06:56:38.999Z","releaseDate":"2017-06-06T06:56:38.999Z","categories":["59365227e16643001bac5031","59365227e16643001bac5032","59365227e16643001bac5033","59365227e16643001bac5034"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0.0"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-06-05T15:17:59.781Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note\",\n  \"body\": \"The [Ghost-CLI](doc:installing-ghost-via-the-cli)  is able to take over NGINX setup for you **soon**. Pretty cool, hm? ๐Ÿ˜€\"\n}\n[/block]\nIf you have setup up Ghost to run in the background (see [Ghost CLI](doc:installing-ghost-via-the-cli#start-and-stop-ghost)), the next step is to setup a web server as a proxy to serve your blog with your domain.\n\nWe do not recommend configuring Ghost to run on port 80 directly, as this requires Ghost to be run as a root level user and is a security risk. Always run Ghost with a web server, both NGINX and apache work, we recommend and document how to use NGINX.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"In this example we assume you are using **Ubuntu 14.04** and use **NGINX** as a web server. It also assumes that Ghost is running in the background with one of the above mentioned ways.\",\n  \"title\": \"Note\"\n}\n[/block]\n## Install NGINX\n\n`$ sudo apt-get install nginx`\n\nThis will install nginx and setup all necessary directories and basic configurations.\n\n## Configure NGINX\n\n1. Create a new file in `/etc/nginx/sites-available/` called `ghost.conf`\n2. Open the file with a text editor (e.g. `sudo nano /etc/nginx/sites-available/ghost.conf`) and paste the following:\n\n    <pre><code>server {\n    listen 80;\n    server_name example.com;\n\n    location / {\n        proxy_set_header   X-Real-IP $remote_addr;\n        proxy_set_header   Host      $http_host;\n        proxy_pass         http://127.0.0.1:2368;\n    }\n}</code></pre>\n\n3. Change `server_name` to your domain\n4. Symlink your configuration in `sites-enabled`:\n\n    `$ sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf`\n\n5. Restart nginx\n\n    `$ sudo service nginx restart`\n\n\n## Point your custom domain at your blog\n\nThe final step in configuring a custom domain is to login to your domain management control panel and create a new DNS record. The most common method is to use an A record to point your domain to the IP address of your web server.\n\n**Next:** Once you have setup nginx it is strongly recommended that you also configure [Ghost to run over SSL](doc:how-to-setup-ssl-for-self-hosted-ghost) ].","excerpt":"How to setup NGINX for self-hosted Ghost","slug":"basic-nginx-config-self-hosted-with-custom-domain","type":"basic","title":"NGINX Config"}

NGINX Config

How to setup NGINX for self-hosted Ghost

[block:callout] { "type": "info", "title": "Note", "body": "The [Ghost-CLI](doc:installing-ghost-via-the-cli) is able to take over NGINX setup for you **soon**. Pretty cool, hm? ๐Ÿ˜€" } [/block] If you have setup up Ghost to run in the background (see [Ghost CLI](doc:installing-ghost-via-the-cli#start-and-stop-ghost)), the next step is to setup a web server as a proxy to serve your blog with your domain. We do not recommend configuring Ghost to run on port 80 directly, as this requires Ghost to be run as a root level user and is a security risk. Always run Ghost with a web server, both NGINX and apache work, we recommend and document how to use NGINX. [block:callout] { "type": "info", "body": "In this example we assume you are using **Ubuntu 14.04** and use **NGINX** as a web server. It also assumes that Ghost is running in the background with one of the above mentioned ways.", "title": "Note" } [/block] ## Install NGINX `$ sudo apt-get install nginx` This will install nginx and setup all necessary directories and basic configurations. ## Configure NGINX 1. Create a new file in `/etc/nginx/sites-available/` called `ghost.conf` 2. Open the file with a text editor (e.g. `sudo nano /etc/nginx/sites-available/ghost.conf`) and paste the following: <pre><code>server { listen 80; server_name example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:2368; } }</code></pre> 3. Change `server_name` to your domain 4. Symlink your configuration in `sites-enabled`: `$ sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf` 5. Restart nginx `$ sudo service nginx restart` ## Point your custom domain at your blog The final step in configuring a custom domain is to login to your domain management control panel and create a new DNS record. The most common method is to use an A record to point your domain to the IP address of your web server. **Next:** Once you have setup nginx it is strongly recommended that you also configure [Ghost to run over SSL](doc:how-to-setup-ssl-for-self-hosted-ghost) ].