centos update
- yum install -y epel-release yum-utils
- yum-config-manager --enable epel
- yum clean all && sudo yum update -y
- yum update -y
- yum groupinstall "Development Tools"
- yum install zlib-devel wget openssl-devel pcre pcre-devel readline-devel
- yum install git
- yum install pgsql 9.6
- yum install nodejs
install Passenger packages
- yum install -y pygpgme curl
- curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
- yum install -y nginx passenger || sudo yum-config-manager --enable cr && yum install -y nginx passenger
enable the Passenger Nginx module and restart Nginx
Edit /etc/nginx/conf.d/passenger.conf and uncomment passenger_root, passenger_ruby and passenger_instance_registry_dir. For example, you may see this
- passenger_root /some-filename/locations.ini;
- passenger_ruby /usr/bin/ruby;
- passenger_instance_registry_dir /var/run/passenger-instreg;
When you are finished with this step, restart Nginx:
- service nginx restart
check installation
- /usr/bin/passenger-config validate-install
- /usr/sbin/passenger-memory-stats
Install rvm
- gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable --ruby - rvm user all
Install ruby
- rvm install 2.5
- rvm --default use 2.5.5
- rvm reload
Install gems
- gem install bundler
- gem install rails -v 4.2.10z
Install pgsql 9.6
- yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
- yum install postgresql96-server postgresql96-contrib postgresql96-devel
init db
- /usr/pgsql-9.6/bin/postgresql96-setup initdb
restart postgresql
- service postgresql-9.6 restart
- chkconfig postgresql-9.6 on
Install cube extension
- yum install postgresql96-contrib.x86_64
- sudo -u postgres psql
- postgres=# create extension cube;
- postgres=# \dT
Install postgis extension
- 下面已經(jīng)postgis9.6 為例,
yum install postgis2_96-devel.x86_64 - sudo -u postgres psql
- postgres=# create extension postgis;
- postgres=# \dT
Create new user and db
- Su - postgres
- createuser -s poi_db_admin
- createdb -O poi_db_admin poi_db_pro
- psql -U poi_db_admin -d poi_db_pro
- ALTER USER poi_db_admin WITH PASSWORD ‘Fac';
- create user poi_db_admin with password ‘Factr123!';
- create database poi_db_pro owner poi_db_admin;
- grant all privileges on database poi_db_pro to poi_db_admin;
- vi /var/lib/pgsql/9.6/data/pg_hba.conf
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
create new linux user
- adduser rails
- chmod 775 -R /home/rails m
- usermod -G wheel rails
Deploy source to the server
download source
- git clone git@github.com:roadlaunch/truckbubbaService.git
- cd truckbubbaService/
- git fetch origin rl_dev
- git checkout rl_dev
- vi ~/.bash_profile
bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config
bundle install --path vendor/bundle
bundle exec rake db:create RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=production
- cd /etc/nginx/conf.d
- vi poi_management.conf