preface

This process basically took me three weeks to get right, and I copied and pasted some of the deployment files directly from the project. Now that I’ve sorted it out, IT’s not that difficult, so why did it take three weeks? Most probably because of my ignorance and ignorance of centos.

For example, when I started the database, it told me that I could not start as root, and when I switched to the normal account, it told me that I had no write permission on the folder, which made me really conflicted.

Yum install Libs-devel, yum install libs-devel, yum install Libs-devel, yum install Libs-devel, yum install Libs-devel, yum install Libs-devel I can’t find pg_config. The pg_config file is usually in /usr/bin, but it is not in….

Install ruby

If you install Ruby using Yum, the version is too low. To manage the Ruby version, I use Rbenv to manage the installation reference links

Install postgresql

Modify the /etc/yum.repos. D/centos-base. repo file

sudo vi /etc/yum.repos.d/CentOS-Base.repo
exclude=postgresql*    // Add this line to the [base] and [updates] blocks
Copy the code

Install postgresql

sudo rpm -Uvh http:/ / yum.postgresql.org/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-1.noarch.rpm
sudo yum install postgresql95 postgresql95-devel postgresql95-server postgresql95-libs postgresql95-contrib
Copy the code

Initialize the database go to the bin folder of the PSQL installation directory (XXXX),

xxxx/bin/pg_ctl -D xxxx/data initdb // Initialize the database
xxxx/bin/pg_ctl -D xxxx/data start  // Start the database
Copy the code

In initDB, you may not have enough permissions. In this case, check the permissions of data and discover that you should switch the user to Postgres

sudo su postgres
Copy the code

In this step, you will be prompted for your password. If you do not know the password, use the following command to change it

passwd postgres
Copy the code

To initialize and start the database, switch the user to Postgres, or use the following command

sudo service postgresql9.5 start               // Start the database
sudo chkconfig --levels 235 postgresql9.5 on   // PSQL starts automatically after startup
Copy the code

Create the PSQL link username and password

sudo su postgres
psql
alter user username with password 'password';
create database testdb owner=username;
Copy the code

Add agents for PUMA

cap production puma:restar
Copy the code

Access port at this time, found themselves unable to visit, check the log of puma, find puma in a production environment is to use the socket links, did the agent can only use nginx, edit/etc/nginx/conf. D/default. The conf file, Replace username and deploy_PATH in the code below

upstream app {
    # Path to Puma SOCK file, as defined previously
    server unix:///home/username/deploy_path/shared/sockets/puma.sock fail_timeout=0;
}

server {
    listen 80;
    server_name localhost;

    root /home/username/deploy_path/current/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_pass http://app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}
Copy the code

As for pumA sock address, please check pumA log to confirm

Problems you may encounter

  1. Gem install pg –with-pg-config= PSQL installation directory /bin/pg_config

  2. Error: the ActiveRecord: : StatementInvalid: PG: : InsufficientPrivilege: error: create an extension “uuid – ossp” permissions not enough answer: need for the establishment of a new username in PSQL super permissions

  3. /var/log/nginx/nginx/nginx_error. log: nginx/nginx/root