-
Notifications
You must be signed in to change notification settings - Fork 52
How to setup a development environment
AIZAWA Hina edited this page Jul 16, 2016
·
33 revisions
- Install Oracle VM VirtualBox or other virtual machine software.
- Download Minimal ISO from CentOS Website.
- Run VirtualBox and create new virtual machine.
- Name: "CentOS 7" or something
- Type: Linux
- Version: Red Hat (64 bit)
- Memory: 1024 MB
- Disk: Create new VDI, 15 GB
- Start it and "insert" downloaded ISO file.
- Choice "Install CentOS 7"
- Install CentOS 7 system. (use Google if needed)
(After this step, I recommend you use a terminal-emulator software like PuTTY.)
- (Re-)boot the machine and login as
root
. - Run some commands to install and update basic packages: (
#
is a prompt, run as root)
-
# yum update -y
: update installed packages -
# yum install -y @base @core
: install basic packages # yum install -y centos-release-scl-rh epel-release scl-utils
# yum-config-manager --enable epel
- Setup Remi-safe RPM repository:
# yum install -y http://rpms.famillecollet.com/enterprise/7/safe/x86_64/remi-release-7.2-1.el7.remi.noarch.rpm
# yum-config-manager --enable remi-safe
- Setup JP3CKI (AIZAWA Hina) RPM repository:
# curl -sL https://rpm.fetus.jp/jp3cki.repo -o /etc/yum.repos.d/jp3cki.repo
# yum-config-manager --enable jp3cki jp3cki-h2o-2.1
- Install packages:
# yum install -y ImageMagick brotli git h2o jpegoptim php70-php-cli php70-php-fpm php70-php-gd php70-php-intl php70-php-json php70-php-mbstring php70-php-mcrypt php70-php-opcache php70-php-pdo php70-php-pecl-msgpack php70-php-pecl-zip php70-php-pgsql php70-php-xml php70-runtime pngcrush rh-nodejs4-npm rh-postgresql95-postgresql rh-postgresql95-postgresql-server
- Create user: (Skip this step if already created at install-time.)
-
# useradd alice
(alice
should replaced to your name)
- Change home directory's permission: (If not, H2O web server returns
403 forbidden
later.)
# chmod 701 /home/alice
- Switch user to
alice
:
-
# su - alice
- The prompt will be changed to
$
.
- The prompt will be changed to
- Setup user's environment to use some application:
$ echo 'source /opt/remi/php70/enable' >> .bashrc
$ echo 'source /opt/rh/rh-nodejs4/enable' >> .bashrc
$ echo 'source /opt/rh/rh-postgresql95/enable' >> .bashrc
- Reload user's environment:
$ source .bashrc
- Test it:
-
$ php -v
("PHP 7.0.8 (cli)" or something will be display.) -
$ node -v
("v4.4.2" or something will be display.) -
$ psql --version
("psql (PostgreSQL) 9.5.2" or something will be display.)
- Clone the source:
-
$ git clone https://github.com/fetus-hina/stat.ink.git
(This URL can replace to your forked project URL)
- Initialize the project:
$ cd stat.ink
-
$ make init
(May take a VERY LONG TIME)
- Get the DB password: (The password is auto-generated in previous step)
-
$ cat config/db.php
- The db configuration will be displayed. Find the password and memorize it.
- Back to
root
account:
$ exit
- Initialize DB structure:
# sudo -u postgres scl enable rh-postgresql95 -- initdb --pgdata=/var/opt/rh/rh-postgresql95/lib/pgsql/data --encoding=UNICODE --locale=en_US.UTF8
- Edit client-authentication settings:
# echo 'local all all peer' > /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf
# echo 'host all all 127.0.0.1/32 md5' >> /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf
-
# echo 'host all all ::1/128 md5' >> /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf
- Note: First command has
>
and other commands have>>
. THIS IS A IMPORTANT THING. (First one is overwrite the file. Second one is append to the file.)
- Note: First command has
- Start the db server:
-
# systemctl enable rh-postgresql95-postgresql.service
(Mark as an auto-started daemon) -
# systemctl start rh-postgresql95-postgresql.service
(Start it)
- Create a db user ("role"):
-
# sudo -u postgres scl enable rh-postgresql95 -- createuser -DRSP statink
- The prompt
Enter password for new role:
will be displayed. You should input the DB password that memorized previous section.
- The prompt
- Create a db:
# sudo -u postgres scl enable rh-postgresql95 -- createdb -E UNICODE -O statink -T template0 statink
- Switch to the user:
# su - alice
- Change "current" directory to project's directory.
$ cd stat.ink
- Run
make
command:
$ make
- DB test: (Update stages information)
-
$ ./yii splapi/map-update
-
If the db works, it will be display like below:
regular... Querying http://splapi.retrorocket.biz/regular ... count(new_data) = 1875 Converting to insert data... inserting... done. gachi... Querying http://splapi.retrorocket.biz/gachi ... count(new_data) = 1875 Converting to insert data... inserting... done. splatfest... Querying http://splapi.retrorocket.biz/fes ... new data for [ボケ vs ツッコミ] new data for [イカ vs タコ] new data for [愛 vs おカネ] new data for [山の幸 vs 海の幸] new data for [赤いきつね vs 緑のたぬき] new data for [カンペキなカラダ vs カンペキな頭脳] new data for [ポケットモンスター 赤vs緑] new data for [ガンガンいこうぜ vs いのちだいじに] new data for [ツナマヨネーズ vs 紅しゃけ] new data for [オシャレなパーティー vs コスプレパーティー] new data for [きのこの山 vs たけのこの里]
-
- Back to
root
user and say "Yay!"
$ exit
- Change directory to
/etc/opt/remi/php70/php-fpm.d
:
# cd /etc/opt/remi/php70/php-fpm.d
- Edit the config file: (Replace process owner name, "apache" to "alice" (i.e. your account name))
# perl -i -pe 's/^user = apache/user = alice/' www.conf
- Start it:
# systemctl enable php70-php-fpm
# systemctl start php70-php-fpm
- Check running:
-
# ps aux | grep php-fpm
- Some lines will be displayed, start with "
alice
(your account name)" and end with "php-fpm: pool www" likealice 13968 0.0 0.6 403688 7116 ? S 04:53 0:00 php-fpm: pool www
- Some lines will be displayed, start with "
-
# netstat -ln | grep ':9000'
- A line will be displayed like
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
- A line will be displayed like
- Copy configuration file from the project:
# cp -n /home/alice/stat.ink/docker/h2o/h2o.conf /etc/h2o/h2o.conf
- Adjust directory name: (
/home/statink
to/home/alice
(your home directory))
# perl -i -pe 's#/home/statink#/home/alice#g' /etc/h2o/h2o.conf
- Start it:
# systemctl enable h2o
# systemctl start h2o
- Switch user to
alice
: (optional, but recommended)
# su - alice
- Request to server:
-
$ curl http://127.0.0.1/
- Raw HTML document will be displayed.