Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save josecarlospsh/1687eae04f7ac1969fd9 to your computer and use it in GitHub Desktop.

Select an option

Save josecarlospsh/1687eae04f7ac1969fd9 to your computer and use it in GitHub Desktop.

Revisions

  1. @janikvonrotz janikvonrotz revised this gist Mar 11, 2014. No changes.
  2. @janikvonrotz janikvonrotz revised this gist Mar 5, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -94,7 +94,7 @@ listen 80;
    root /usr/share/nginx/www;
    }
    client_max_body_size 2M;
    client_max_body_size 10M;
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
    @@ -219,6 +219,8 @@ server{
    index index.php index.html index.htm;
    client_max_body_size 10M;
    location ~ .php$ {
    try_files $uri = 404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  3. @janikvonrotz janikvonrotz revised this gist Mar 4, 2014. No changes.
  4. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -66,7 +66,7 @@ And run this command to get the MySQL version
    Install Nginx

    sudo apt-get install nginx

    Create a Nginx site configuration file

    sudo touch /etc/nginx/sites-available/wordpress.conf
    @@ -93,6 +93,8 @@ listen 80;
    location = /50x.html {
    root /usr/share/nginx/www;
    }
    client_max_body_size 2M;
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
    @@ -216,7 +218,7 @@ server{
    root /var/www/;
    index index.php index.html index.htm;
    location ~ .php$ {
    try_files $uri = 404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  5. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -298,6 +298,11 @@ define('DB_USER', 'wordpress');
    define('DB_PASSWORD', '[password]');
    ```

    Update permissions for Nginx user

    sudo chown www-data:www-data * -R
    sudo usermod -a -G www-data www-data

    Open the browser on http://example.com and install you WordPress blog

    ## Source
  6. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Finishing this guide you'll get:

    * A running WordPress installation
    * Nginx proxy with PHP and Fast CGI
    * MySQL server accessiable with phpMyAdmin
    * MySQL server accessible with phpMyAdmin


    Specification of latest running installation:
  7. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Finishing this guide you'll get:

    * A running WordPress installation
    * Nginx proxy with PHP and Fast CGI
    * MySQL server with accessiable with phpMyAdmin
    * MySQL server accessiable with phpMyAdmin


    Specification of latest running installation:
  8. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 64 additions and 5 deletions.
    69 changes: 64 additions & 5 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@ Specification of latest running installation:
    * Date: 03.03.2014
    * OS: Ubuntu 64 bit - 12.04.4 LTS
    * Provider: Amazon EC2
    * Browser: Google Chrome - ?
    * WordPress:?
    * Browser: Google Chrome - 33.0.1750.117
    * WordPress: 3.8.1
    * Nginx: 1.1.19
    * MySQL: 5.5.35
    * PHP: 5.3.10
    @@ -47,12 +47,11 @@ Install the default MySQL databases

    sudo mysql_install_db

    Run the finisher script
    Respond with yes to get a have a secure MySQL installation
    Run the finisher script and respond every prompt with yes to get a secure MySQL installation

    sudo /usr/bin/mysql_secure_installation
    Connect to you new MySQL server
    Connect to your new MySQL server

    mysql -uroot -p

    @@ -239,7 +238,67 @@ Open the browser on http://[YourPublicIP]/phpmyadmin/

    ## WordPress

    Open the WordPress site directory

    cd /var/www/wordpress/

    Download latest WordPress package and untar it

    sudo wget http://wordpress.org/latest.tar.gz
    tar -xzvf latest.tar.gz

    Copy the untared files to the current folder and delete the other files

    sudo cp -r ./wordpress/* ./
    sudo rm -r wordpress
    sudo rm latest.tar.gz

    Let's create the MySQL WordPress user

    mysql -u root -p

    Enter the MySQL root user password

    Create the WordPress database

    CREATE DATABASE wordpress;

    Create the WordPress database user

    CREATE USER wordpress@localhost;

    Set the password for the WordPress database user

    SET PASSWORD FOR wordpress@localhost = PASSWORD("[password]");

    Grant WordPress user full access on WordPress database

    GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost IDENTIFIED BY '[password]';

    Refresh MySQL and exit

    FLUSH PRIVILEGES;
    exit

    Copy the WordPress example config file

    sudo cp wp-config-sample.php wp-config.php

    Edit the config file

    sudo vi wp-config.php

    Set database, database user and his password

    ```
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wordpress');
    define('DB_PASSWORD', '[password]');
    ```

    Open the browser on http://example.com and install you WordPress blog

    ## Source

  9. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 16 additions and 15 deletions.
    31 changes: 16 additions & 15 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -13,8 +13,9 @@ Specification of latest running installation:
    * Browser: Google Chrome - ?
    * WordPress:?
    * Nginx: 1.1.19
    * MySQL: ?
    * PHP: ?
    * MySQL: 5.5.35
    * PHP: 5.3.10
    * phpMyAdmin: 3.4.10.1

    Requirements

    @@ -151,6 +152,10 @@ Uncomment this line and change value to 0

    If this number is kept as 1, the php interpreter will do its best to process the file that is as near to the requested file as possible. This is a possible security risk. If this number is set to 0, conversely, the interpreter will only process the exact file path—a much safer alternative.

    Find the line `; default extension directory.` and insert below

    extension=mcrypt.so

    Update the listening port for the php fpm

    sudo vi /etc/php5/fpm/pool.d/www.conf
    @@ -208,18 +213,13 @@ Paste this config
    server{
    listen 80;
    server_name localhost;
    root /var/www/phpmyadmin;
    server_name [Your Public IP];
    root /var/www/;
    index index.php index.html index.htm;
    if(!-e $request_filename){
    rewrite ^/(.+)$ /index.php?url=$1 last;
    break;
    }
    location ~ .php$ {
    try_files $uri =404;
    try_files $uri = 404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    @@ -229,11 +229,13 @@ server{

    Create a symlink to the config file

    sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/wordpress.conf

    sudo ln -s /etc/nginx/sites-available/phpmyadmin.conf /etc/nginx/sites-enabled/phpmyadmin.conf
    Restart Ngnix

    sudo service nginx restart

    Open the browser on http://[YourPublicIP]/phpmyadmin/

    ## WordPress

    @@ -246,5 +248,4 @@ Restart Ngnix
    [How To Install phpMyAdmin on a LEMP server by Digi](https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/)
    [How To Install Wordpress with nginx on Ubuntu 12.04 by Digital Ocean](https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04)
    [Nginx rewrite rules](http://nginx.org/en/docs/http/converting_rewrite_rules.html)
    [Get MySQL version](https://dev.mysql.com/doc/refman/5.0/en/installation-version.html)
    []()
    [Get MySQL version](https://dev.mysql.com/doc/refman/5.0/en/installation-version.html)
  10. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 101 additions and 45 deletions.
    146 changes: 101 additions & 45 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    Finishing this guide you'll get:

    * A running WordPress installation
    * Nginx proxy with PHP
    * MySQL server
    * Nginx proxy with PHP and Fast CGI
    * MySQL server with accessiable with phpMyAdmin


    Specification of latest running installation:
    @@ -50,10 +50,16 @@ Run the finisher script
    Respond with yes to get a have a secure MySQL installation

    sudo /usr/bin/mysql_secure_installation
    Connect to you new MySQL server

    mysql -uroot -p

    Check MySQL version
    Enter the root password

    [add command]
    And run this command to get the MySQL version

    SHOW variables LIKE "%version%";

    ## Nginx

    @@ -113,10 +119,10 @@ server {
    }
    ```

    Create a symlink to your config file
    Create a symlink to the config file

    sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/wordpress.conf

    Restart Ngnix

    sudo service nginx restart
    @@ -131,64 +137,114 @@ Install PHP with FastCGI support

    sudo apt-get install php5-fpm

    ## WordPress

    configure PHP installaton

    sudo vi /etc/php5/fpm/php.ini
    Find the line `cgi.fix_pathinfo=1` by pressing ESC and enter

    /;cgi.fix_pathinfo=1

    Uncomment this line and change value to 0

    cgi.fix_pathinfo=0

    If this number is kept as 1, the php interpreter will do its best to process the file that is as near to the requested file as possible. This is a possible security risk. If this number is set to 0, conversely, the interpreter will only process the exact file path—a much safer alternative.

    Update the listening port for the php fpm

    sudo vi /etc/php5/fpm/pool.d/www.conf
    Set listen = /var/run/php5-fpm.sock

    Restart the service

    sudo service php5-fpm restart

    Create the website folder

    sudo mkdir -p /var/www/
    cd /var/www/

    Download Ghost with wget

    sudo wget https://ghost.org/zip/ghost-latest.zip

    Unpack Ghost
    sudo mkdir /var/www/wordpress

    Add a PHP info file

    sudo unzip -d ghost ghost-latest.zip
    cd ghost/

    Install Ghost
    sudo vi /var/www/wordpress/info.php

    Set content

    sudo npm install --production
    In case of errors for sqlite3 installation
    ```
    <?php
    phpinfo();
    ?>
    ```

    npm install sqlite3 --build-from-source

    Install forever
    Open your browser on http://example.com/info.php

    sudo npm install forever -g
    Configure Ghost (productive environment only)
    Delete this file if everything works

    ## phpMyAdmin

    sudo cp config.example.js config.js
    sudo vi config.js
    Set url: 'http://[example.com]',
    Install phpMyAdmin

    sudo apt-get install phpmyadmin

    Start Ghost
    When phpMyAdmin prompts you to choose a server (either apache or lighttpd)hit tab, and select neither one.

    When phpMyAdmin asks you wether to configure database for phpmyadmin with dbconfig-common. Chose <Yes> and enter the MySQL root user password

    Hit <OK> on the MySQL application password for phpmyadmin prompt.

    Create a symbolic link for the phpMyAdmin website

    sudo NODE_ENV=production forever start index.js
    sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www

    Start Ghost without forever
    Create a Nginx configuration file

    sudo npm start --production

    Check if Ghost is running
    sudo touch /etc/nginx/sites-available/phpmyadmin.conf
    sudo vi /etc/nginx/sites-available/phpmyadmin.conf

    Paste this config

    forever list

    ```
    server{
    listen 80;
    server_name localhost;
    root /var/www/phpmyadmin;
    index index.php index.html index.htm;
    if(!-e $request_filename){
    rewrite ^/(.+)$ /index.php?url=$1 last;
    break;
    }
    Stop Ghost
    location ~ .php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    }
    }
    ```

    Create a symlink to the config file

    forever stop index.js
    sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/wordpress.conf

    Restart Ngnix

    sudo service nginx restart

    ## WordPress

    Register your Ghost Account

    Open your browser on http://[example.com]/ghost

    ## Source

    [Install MySQL](http://dev.mysql.com/doc/refman/5.7/en/linux-installation-native.html)
    [How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 12.04 by Digital Ocean](https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04)
    [How To Install phpMyAdmin on a LEMP server by Digi](https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/)
    [How To Install Wordpress with nginx on Ubuntu 12.04 by Digital Ocean](https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04)
    [Nginx rewrite rules](http://nginx.org/en/docs/http/converting_rewrite_rules.html)
    [How To Install Wordpress with nginx on Ubuntu 12.04 by Digital Ocean](https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04)
    [Nginx rewrite rules](http://nginx.org/en/docs/http/converting_rewrite_rules.html)
    [Get MySQL version](https://dev.mysql.com/doc/refman/5.0/en/installation-version.html)
    []()
  11. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 78 additions and 184 deletions.
    262 changes: 78 additions & 184 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ Specification of latest running installation:
    * Provider: Amazon EC2
    * Browser: Google Chrome - ?
    * WordPress:?
    * Nginx: ?
    * Nginx: 1.1.19
    * MySQL: ?
    * PHP: ?

    @@ -34,6 +34,27 @@ Install additional packages

    sudo aptitude install build-essential zip git

    ## MySQL

    Install MySQL server and php5 MySQL module

    sudo apt-get install mysql-server php5-mysql

    Set the mysql root user password during the installation

    Install the default MySQL databases

    sudo mysql_install_db

    Run the finisher script
    Respond with yes to get a have a secure MySQL installation

    sudo /usr/bin/mysql_secure_installation

    Check MySQL version

    [add command]

    ## Nginx

    Install Nginx
    @@ -47,34 +68,68 @@ Create a Nginx site configuration file

    Paste this config

    server {
    listen 80;
    server_name [example.com];
    ```
    server {
    listen 80;
    root /var/www/wordpress;
    index index.php index.html index.htm;
    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;
    }
    location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/www;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
    try_files $uri = 404;
    #fastcgi_pass 127.0.0.1:9000;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }
    }
    ```

    Optionally you can rewrite false urls to a specified canonical url

    ```
    server {
    listen 80;
    server_name www.example.com example.com;
    if ($http_host = www.example.org) {
    rewrite (.*) http://[example.com]$1;
    }
    ...
    }
    ```

    Create a symlink to your config file

    sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf
    sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/wordpress.conf

    Restart Ngnix

    sudo service nginx restart

    In case you'll get this error
    Check Nginx version

    Restarting nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64
    Do
    nginx -v

    ## PHP

    sudo vi /etc/nginx/nginx.conf
    Set server_names_hash_bucket_size 128;
    sudo service nginx restart
    Install PHP with FastCGI support

    sudo apt-get install php5-fpm

    ## WordPress

    @@ -129,172 +184,11 @@ Stop Ghost
    Register your Ghost Account

    Open your browser on http://[example.com]/ghost

    ## Ghost Mail

    Ghost uses [Nodemailer](https://github.com/andris9/Nodemailer) to send e-mails, this modules has to be configured.
    Ghost supports various mail providers, you can see all of them in the [Ghost mail documentation](http://docs.ghost.org/mail/)

    ### SES

    Amazon's SES (Simple EMail Service) provides a reliable service to send mails.

    Requirements

    * Amazon Account
    * Verified domain and mail address on SES

    Create a new user in the [IAM service console](https://console.aws.amazon.com/iam/#users) and store the access keys in a secure place.

    Allow new user to send mail via SES with this policy configuration

    ```
    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Effect": "Allow",
    "Action": "ses:SendRawEmail",
    "Resource": "*"
    }
    ]
    }
    ```

    Edit the Ghost config

    sudo vi config.js

    Add this mail configuration

    ```
    mail: {
    transport: 'SES',
    options: {
    AWSAccessKeyID: '[acccess key]',
    AWSSecretKey: '[secret key]'
    }
    },
    ```
    Update mail settings

    http://[example.com]/ghost/settings/general/
    Set Email Address: [verified SES mail address]

    Or

    sudo vi config.js

    And add this mail configuration

    mail: {
    fromaddress: '[verified SES mail address]',
    }

    Now you should be able to reset your Ghost password

    However at the time of writting this mail configuration doesn't seem to work despite it's an offical Ghost configuration

    In case you'll get this error when trying to reset your password

    Email Error: Email failed: 400 Sender MessageRejected Email address is not verified. 5a07d838-8381-11e3-ad96-5f67c4a04b97

    Replace the the Ghost mail configuration with
    ```
    mail: {
    transport: 'SMTP',
    fromaddress: '[verified SES mail address]',
    host: 'ssl://[SES smpt server address]',
    options: {
    port: 465,
    service: 'SES',
    auth: {
    user: '[acccess key]',
    pass: '[secret key]'
    }
    }
    },
    ```

    You can get your smtp settings [here](https://console.aws.amazon.com/ses/home?#smtp-settings:)

    ## Source

    [Install Node](https://github.com/joyent/node/wiki/Installation)
    [Install Node on Ubuntu](http://davidtsadler.com/archives/2012/05/06/installing-node-js-on-ubuntu/)
    [Install Ghost](http://docs.ghost.org/installation/linux/)
    [Deployment of Ghost](http://docs.ghost.org/installation/deploy/)
    [sqlite3 troubleshooting](http://docs.ghost.org/installation/troubleshooting/)
    [nginx fix hash buck size](http://charles.lescampeurs.org/2008/11/14/fix-nginx-increase-server_names_hash_bucket_size)
    [Install Ghost on Ubuntu, Nginx and MySQL](http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql/#.Ut5q2RBwZaQ)
    [Fail2Ban SSH Hardening](https://www.digitalocean.com/community/articles/how-to-protect-ssh-with-fail2ban-on-ubuntu-12-04)
    [Amazon EC2 Node Stack](https://github.com/niftylettuce/amazon-ec2-node-stack)
    [SES mail configuration](https://blog.ls20.com/install-ghost-0-3-3-with-nginx-and-modsecurity/#settingupemailonghost)

    ## Todo

    * Add Backup tutorial
    * ModSecurity for Nginx
    * PageSpeed for Nginx

    ## Issues

    [SES configuratio doesn't now working, even with a provided fix](https://ghost.org/forum/installation/4885-my-mail-ses-configuration-doesn-t-seem-to-work/)

    ## Issues solved

    [Sign up for a Ghost account might not possible](https://ghost.org/forum/installation/4627-can-t-sign-up-for-an-account-after-installation/)

    ## Backup (coming soon)
    http://manpages.ubuntu.com/manpages/intrepid/man1/s3cmd.1.html
    http://mikerogers.io/2013/08/01/backing-up-site-to-s3-on-ubuntu.html
    http://9ol.es/TheEmperorsNewClothes.html

    ```
    {
    "Backup": {
    "Name": "[FileBackupName]",
    "OutputName": "[FileBackup.Name]#[TimeStamp]",
    "TimeStampFormat": "YYYY-MM-DD",
    "WeekStartsOn": "Monday",
    "Database": {},
    "File": {
    "Path": [
    "/var/www/ghost/",
    "/etc/nginx/sites-available/ghost"
    ]
    },
    "Store": [
    {
    "Name": "Local Backup",
    "Provider": "LocalDisk",
    "Path": "/var/backup/",
    "RetentionTime": "7 Days",
    "BackupType": "Daily",
    "Options": ""
    },
    {
    "Name": "Remote Backup to S3",
    "Provider": "S3",
    "ConfigFile": "/etc/s3cmd/GhostBackup.s3cfg",
    "Url": "http:s3.amazonaws.com/(Bucket Name)/backup/",
    "ID": "",
    "Key": "",
    "RetentionTime": "10 Years",
    "BackupType": [
    "Daily",
    "Weekly",
    "Monthly",
    "Yearly"
    ],
    "Options": [
    "DeleteDailyBackupsAfterOneWeek",
    "DeleteWeeklyBackupsAfterOneMonth",
    "DeleteMonthlyBackupsAfterOneYear",
    "CompressFiles"
    ]
    }
    ]
    }
    }
    ```
    [Install MySQL](http://dev.mysql.com/doc/refman/5.7/en/linux-installation-native.html)
    [How To Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 12.04 by Digital Ocean](https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04)
    [How To Install phpMyAdmin on a LEMP server by Digi](https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/)
    [How To Install Wordpress with nginx on Ubuntu 12.04 by Digital Ocean](https://www.digitalocean.com/community/articles/how-to-install-wordpress-with-nginx-on-ubuntu-12-04)
    [Nginx rewrite rules](http://nginx.org/en/docs/http/converting_rewrite_rules.html)
  12. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 12 additions and 198 deletions.
    210 changes: 12 additions & 198 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,20 @@
    Finishing this guide you'll get:

    * A running WordPress installation
    * Amazon SES mail configuration
    * Simple ssh hardenings
    * Nginx proxy
    * Node.js configured with forever
    * Nginx proxy with PHP
    * MySQL server


    Specification of latest running installation:

    * Date: 21.01.2014
    * Date: 03.03.2014
    * OS: Ubuntu 64 bit - 12.04.4 LTS
    * Provider: Amazon EC2
    * Mail service: Amazon SES
    * Browser: Google Chrome - 31.0.1650.63
    * Ghost: 0.4
    * Node: 0.10.24
    * npm: 1.3.21
    * Browser: Google Chrome - ?
    * WordPress:?
    * Nginx: ?
    * MySQL: ?
    * PHP: ?

    Requirements

    @@ -34,191 +33,6 @@ Update Ubuntu
    Install additional packages

    sudo aptitude install build-essential zip git

    ## SSH

    Change the default ssh port and disable root login

    sudo vi /etc/ssh/sshd_config
    Set Port [custom ssh port number]
    Set PermitRootLogin no

    Restart the ssh service

    sudo /etc/init.d/ssh restart

    Update firewall rules now to enable ssh connection with your custom port

    Reconnect your ssh host with the new port number

    ssh -p [custom ssh port number] user@host

    ## Fail2Ban

    Install Fail2Ban

    sudo apt-get install fail2ban

    Copy the configuration file

    sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

    Edit the config file

    sudo vi /etc/fail2ban/jail.local

    Make the following changes:

    [ssh]
    port = [custom ssh port number]

    And

    [ssh-ddos]
    enabled = true
    port = [custom ssh port number]

    Finish editing and restart fail2ban service

    sudo service fail2ban restart

    ## Network

    Edit the network configuration file

    sudo vi /etc/sysctl.conf

    Paste the this configuration file to improve network security

    ```
    #
    # /etc/sysctl.conf - Configuration file for setting system variables
    # See /etc/sysctl.d/ for additional system variables
    # See sysctl.conf (5) for information.
    #
    # Uncomment the next two lines to enable Spoof protection (reverse-path filter)
    # Turn on Source Address Verification in all interfaces to
    # prevent some spoofing attacks
    net.ipv4.conf.default.rp_filter=1
    net.ipv4.conf.all.rp_filter=1
    # Uncomment the next line to enable TCP/IP SYN cookies
    net.ipv4.tcp_syncookies=1
    net.ipv4.tcp_max_syn_backlog = 2048
    net.ipv4.tcp_synack_retries = 2
    net.ipv4.tcp_syn_retries = 5
    # Do not accept ICMP redirects (prevent MITM attacks)
    net.ipv4.conf.all.accept_redirects = 0
    net.ipv6.conf.all.accept_redirects = 0
    net.ipv4.conf.default.accept_redirects = 0
    net.ipv6.conf.default.accept_redirects = 0
    # Do not send ICMP redirects (we are not a router)
    net.ipv4.conf.all.send_redirects = 0
    net.ipv4.conf.default.send_redirects = 0
    # Do not accept IP source route packets (we are not a router)
    net.ipv4.conf.all.accept_source_route = 0
    net.ipv6.conf.all.accept_source_route = 0
    net.ipv4.conf.default.accept_source_route = 0
    net.ipv6.conf.default.accept_source_route = 0
    # Log Martian Packets
    net.ipv4.conf.all.log_martians = 1
    net.ipv4.icmp_ignore_bogus_error_responses = 1
    # Ignore ICMP broadcast requests
    net.ipv4.icmp_echo_ignore_broadcasts = 1
    # Ignore Directed pings
    net.ipv4.icmp_echo_ignore_all = 1
    ```

    ## Node.js

    You can install node either from website or the from the git repo.

    ### Install from source

    Download Node.js with wget

    wget http://nodejs.org/dist/node-latest.tar.gz

    Unpack Node.js

    tar -xzf node-latest.tar.gz
    cd [node folder]

    Install Node.js

    sudo ./configure
    sudo make
    sudo make install

    Check version of Node.js and npm

    node -v
    npm -v

    ### Install with Git

    Clone the Node.js repo

    cd /usr/local/src
    sudo git clone git://github.com/joyent/node.git

    Check git tags to find the latest version

    cd node
    git tag

    See the latest stable version on http://nodejs.org/

    Checkout the latest version

    sudo git checkout vX.X.X

    Install Node.js

    sudo ./configure
    sudo make
    sudo make install

    Check version of Node.js and npm

    node -v
    npm -v

    ## Update Node.js

    Depending on how you've installed Node.js theres an update strategy

    ### from source

    Repeat the installation process above

    ### with Git

    Pull down the latest source code

    cd /usr/local/src/node
    sudo git checkout master
    sudo git pull origin master

    Check git tags to find the latest version

    git tag

    See the latest stable version on http://nodejs.org/

    Compile the latest version

    sudo git checkout vx.x.x
    sudo ./configure
    sudo make
    sudo make install

    ## Nginx

    @@ -228,8 +42,8 @@ Install Nginx

    Create a Nginx site configuration file

    sudo touch /etc/nginx/sites-available/ghost.conf
    sudo vi /etc/nginx/sites-available/ghost.conf
    sudo touch /etc/nginx/sites-available/wordpress.conf
    sudo vi /etc/nginx/sites-available/wordpress.conf

    Paste this config

    @@ -262,7 +76,7 @@ Do
    Set server_names_hash_bucket_size 128;
    sudo service nginx restart

    ## Ghost
    ## WordPress

    Create the website folder

  13. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. No changes.
  14. @janikvonrotz janikvonrotz revised this gist Mar 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    Finishing this guide you'll get:

    * A running Ghost installation
    * A running WordPress installation
    * Amazon SES mail configuration
    * Simple ssh hardenings
    * Nginx proxy
  15. @janikvonrotz janikvonrotz created this gist Mar 3, 2014.
    486 changes: 486 additions & 0 deletions Install WordPress Blog.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,486 @@
    Finishing this guide you'll get:

    * A running Ghost installation
    * Amazon SES mail configuration
    * Simple ssh hardenings
    * Nginx proxy
    * Node.js configured with forever

    Specification of latest running installation:

    * Date: 21.01.2014
    * OS: Ubuntu 64 bit - 12.04.4 LTS
    * Provider: Amazon EC2
    * Mail service: Amazon SES
    * Browser: Google Chrome - 31.0.1650.63
    * Ghost: 0.4
    * Node: 0.10.24
    * npm: 1.3.21

    Requirements

    * Server is behind a firewall, that only allows http, https and ssh
    * The server is accessed with ssh keys (user password authentication must be disabled)
    * Server is not accessed with the root user
    * You're able to edit files with [VI](http://www.cheatography.com/ericg/cheat-sheets/vi-editor/)


    ## Ubuntu

    Update Ubuntu

    sudo apt-get update && sudo apt-get upgrade

    Install additional packages

    sudo aptitude install build-essential zip git

    ## SSH

    Change the default ssh port and disable root login

    sudo vi /etc/ssh/sshd_config
    Set Port [custom ssh port number]
    Set PermitRootLogin no

    Restart the ssh service

    sudo /etc/init.d/ssh restart

    Update firewall rules now to enable ssh connection with your custom port

    Reconnect your ssh host with the new port number

    ssh -p [custom ssh port number] user@host

    ## Fail2Ban

    Install Fail2Ban

    sudo apt-get install fail2ban

    Copy the configuration file

    sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

    Edit the config file

    sudo vi /etc/fail2ban/jail.local

    Make the following changes:

    [ssh]
    port = [custom ssh port number]

    And

    [ssh-ddos]
    enabled = true
    port = [custom ssh port number]

    Finish editing and restart fail2ban service

    sudo service fail2ban restart

    ## Network

    Edit the network configuration file

    sudo vi /etc/sysctl.conf

    Paste the this configuration file to improve network security

    ```
    #
    # /etc/sysctl.conf - Configuration file for setting system variables
    # See /etc/sysctl.d/ for additional system variables
    # See sysctl.conf (5) for information.
    #
    # Uncomment the next two lines to enable Spoof protection (reverse-path filter)
    # Turn on Source Address Verification in all interfaces to
    # prevent some spoofing attacks
    net.ipv4.conf.default.rp_filter=1
    net.ipv4.conf.all.rp_filter=1
    # Uncomment the next line to enable TCP/IP SYN cookies
    net.ipv4.tcp_syncookies=1
    net.ipv4.tcp_max_syn_backlog = 2048
    net.ipv4.tcp_synack_retries = 2
    net.ipv4.tcp_syn_retries = 5
    # Do not accept ICMP redirects (prevent MITM attacks)
    net.ipv4.conf.all.accept_redirects = 0
    net.ipv6.conf.all.accept_redirects = 0
    net.ipv4.conf.default.accept_redirects = 0
    net.ipv6.conf.default.accept_redirects = 0
    # Do not send ICMP redirects (we are not a router)
    net.ipv4.conf.all.send_redirects = 0
    net.ipv4.conf.default.send_redirects = 0
    # Do not accept IP source route packets (we are not a router)
    net.ipv4.conf.all.accept_source_route = 0
    net.ipv6.conf.all.accept_source_route = 0
    net.ipv4.conf.default.accept_source_route = 0
    net.ipv6.conf.default.accept_source_route = 0
    # Log Martian Packets
    net.ipv4.conf.all.log_martians = 1
    net.ipv4.icmp_ignore_bogus_error_responses = 1
    # Ignore ICMP broadcast requests
    net.ipv4.icmp_echo_ignore_broadcasts = 1
    # Ignore Directed pings
    net.ipv4.icmp_echo_ignore_all = 1
    ```

    ## Node.js

    You can install node either from website or the from the git repo.

    ### Install from source

    Download Node.js with wget

    wget http://nodejs.org/dist/node-latest.tar.gz

    Unpack Node.js

    tar -xzf node-latest.tar.gz
    cd [node folder]

    Install Node.js

    sudo ./configure
    sudo make
    sudo make install

    Check version of Node.js and npm

    node -v
    npm -v

    ### Install with Git

    Clone the Node.js repo

    cd /usr/local/src
    sudo git clone git://github.com/joyent/node.git

    Check git tags to find the latest version

    cd node
    git tag

    See the latest stable version on http://nodejs.org/

    Checkout the latest version

    sudo git checkout vX.X.X

    Install Node.js

    sudo ./configure
    sudo make
    sudo make install

    Check version of Node.js and npm

    node -v
    npm -v

    ## Update Node.js

    Depending on how you've installed Node.js theres an update strategy

    ### from source

    Repeat the installation process above

    ### with Git

    Pull down the latest source code

    cd /usr/local/src/node
    sudo git checkout master
    sudo git pull origin master

    Check git tags to find the latest version

    git tag

    See the latest stable version on http://nodejs.org/

    Compile the latest version

    sudo git checkout vx.x.x
    sudo ./configure
    sudo make
    sudo make install

    ## Nginx

    Install Nginx

    sudo apt-get install nginx

    Create a Nginx site configuration file

    sudo touch /etc/nginx/sites-available/ghost.conf
    sudo vi /etc/nginx/sites-available/ghost.conf

    Paste this config

    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;
    }
    }

    Create a symlink to your config file

    sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf

    Restart Ngnix

    sudo service nginx restart

    In case you'll get this error

    Restarting nginx: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64

    Do

    sudo vi /etc/nginx/nginx.conf
    Set server_names_hash_bucket_size 128;
    sudo service nginx restart

    ## Ghost

    Create the website folder

    sudo mkdir -p /var/www/
    cd /var/www/

    Download Ghost with wget

    sudo wget https://ghost.org/zip/ghost-latest.zip

    Unpack Ghost

    sudo unzip -d ghost ghost-latest.zip
    cd ghost/

    Install Ghost

    sudo npm install --production
    In case of errors for sqlite3 installation

    npm install sqlite3 --build-from-source

    Install forever

    sudo npm install forever -g

    Configure Ghost (productive environment only)

    sudo cp config.example.js config.js
    sudo vi config.js
    Set url: 'http://[example.com]',

    Start Ghost

    sudo NODE_ENV=production forever start index.js

    Start Ghost without forever

    sudo npm start --production

    Check if Ghost is running

    forever list

    Stop Ghost

    forever stop index.js

    Register your Ghost Account

    Open your browser on http://[example.com]/ghost

    ## Ghost Mail

    Ghost uses [Nodemailer](https://github.com/andris9/Nodemailer) to send e-mails, this modules has to be configured.
    Ghost supports various mail providers, you can see all of them in the [Ghost mail documentation](http://docs.ghost.org/mail/)

    ### SES

    Amazon's SES (Simple EMail Service) provides a reliable service to send mails.

    Requirements

    * Amazon Account
    * Verified domain and mail address on SES

    Create a new user in the [IAM service console](https://console.aws.amazon.com/iam/#users) and store the access keys in a secure place.

    Allow new user to send mail via SES with this policy configuration

    ```
    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Effect": "Allow",
    "Action": "ses:SendRawEmail",
    "Resource": "*"
    }
    ]
    }
    ```

    Edit the Ghost config

    sudo vi config.js

    Add this mail configuration

    ```
    mail: {
    transport: 'SES',
    options: {
    AWSAccessKeyID: '[acccess key]',
    AWSSecretKey: '[secret key]'
    }
    },
    ```
    Update mail settings

    http://[example.com]/ghost/settings/general/
    Set Email Address: [verified SES mail address]

    Or

    sudo vi config.js

    And add this mail configuration

    mail: {
    fromaddress: '[verified SES mail address]',
    }

    Now you should be able to reset your Ghost password

    However at the time of writting this mail configuration doesn't seem to work despite it's an offical Ghost configuration

    In case you'll get this error when trying to reset your password

    Email Error: Email failed: 400 Sender MessageRejected Email address is not verified. 5a07d838-8381-11e3-ad96-5f67c4a04b97

    Replace the the Ghost mail configuration with
    ```
    mail: {
    transport: 'SMTP',
    fromaddress: '[verified SES mail address]',
    host: 'ssl://[SES smpt server address]',
    options: {
    port: 465,
    service: 'SES',
    auth: {
    user: '[acccess key]',
    pass: '[secret key]'
    }
    }
    },
    ```

    You can get your smtp settings [here](https://console.aws.amazon.com/ses/home?#smtp-settings:)

    ## Source

    [Install Node](https://github.com/joyent/node/wiki/Installation)
    [Install Node on Ubuntu](http://davidtsadler.com/archives/2012/05/06/installing-node-js-on-ubuntu/)
    [Install Ghost](http://docs.ghost.org/installation/linux/)
    [Deployment of Ghost](http://docs.ghost.org/installation/deploy/)
    [sqlite3 troubleshooting](http://docs.ghost.org/installation/troubleshooting/)
    [nginx fix hash buck size](http://charles.lescampeurs.org/2008/11/14/fix-nginx-increase-server_names_hash_bucket_size)
    [Install Ghost on Ubuntu, Nginx and MySQL](http://0v.org/installing-ghost-on-ubuntu-nginx-and-mysql/#.Ut5q2RBwZaQ)
    [Fail2Ban SSH Hardening](https://www.digitalocean.com/community/articles/how-to-protect-ssh-with-fail2ban-on-ubuntu-12-04)
    [Amazon EC2 Node Stack](https://github.com/niftylettuce/amazon-ec2-node-stack)
    [SES mail configuration](https://blog.ls20.com/install-ghost-0-3-3-with-nginx-and-modsecurity/#settingupemailonghost)

    ## Todo

    * Add Backup tutorial
    * ModSecurity for Nginx
    * PageSpeed for Nginx

    ## Issues

    [SES configuratio doesn't now working, even with a provided fix](https://ghost.org/forum/installation/4885-my-mail-ses-configuration-doesn-t-seem-to-work/)

    ## Issues solved

    [Sign up for a Ghost account might not possible](https://ghost.org/forum/installation/4627-can-t-sign-up-for-an-account-after-installation/)

    ## Backup (coming soon)
    http://manpages.ubuntu.com/manpages/intrepid/man1/s3cmd.1.html
    http://mikerogers.io/2013/08/01/backing-up-site-to-s3-on-ubuntu.html
    http://9ol.es/TheEmperorsNewClothes.html

    ```
    {
    "Backup": {
    "Name": "[FileBackupName]",
    "OutputName": "[FileBackup.Name]#[TimeStamp]",
    "TimeStampFormat": "YYYY-MM-DD",
    "WeekStartsOn": "Monday",
    "Database": {},
    "File": {
    "Path": [
    "/var/www/ghost/",
    "/etc/nginx/sites-available/ghost"
    ]
    },
    "Store": [
    {
    "Name": "Local Backup",
    "Provider": "LocalDisk",
    "Path": "/var/backup/",
    "RetentionTime": "7 Days",
    "BackupType": "Daily",
    "Options": ""
    },
    {
    "Name": "Remote Backup to S3",
    "Provider": "S3",
    "ConfigFile": "/etc/s3cmd/GhostBackup.s3cfg",
    "Url": "http:s3.amazonaws.com/(Bucket Name)/backup/",
    "ID": "",
    "Key": "",
    "RetentionTime": "10 Years",
    "BackupType": [
    "Daily",
    "Weekly",
    "Monthly",
    "Yearly"
    ],
    "Options": [
    "DeleteDailyBackupsAfterOneWeek",
    "DeleteWeeklyBackupsAfterOneMonth",
    "DeleteMonthlyBackupsAfterOneYear",
    "CompressFiles"
    ]
    }
    ]
    }
    }
    ```