[root@linuxprobe ~]# yum -y install centos-release-scl-rh centos-release-scl# set [priority=10]
[root@linuxprobe ~]# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
[root@linuxprobe ~]# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo# for another way, change to [enabled=0] and use it only when needed
[root@linuxprobe ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
[root@linuxprobe ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo# if [enabled=0], input a command to use the repository
[root@linuxprobe ~]# yum --enablerepo=centos-sclo-rh install [Package]
[root@linuxprobe ~]# yum --enablerepo=centos-sclo-sclo install [Package]# 安裝ruby
yum --enablerepo=centos-sclo-rh -y install rh-ruby22
安裝Ruby on Rails 4來(lái)構(gòu)建Ruby Framework環(huán)境
添加EPEL軟件存儲(chǔ)庫(kù)
[root@linuxprobe ~]# yum -y install epel-release
# set [priority=5]
[root@linuxprobe ~]# sed -i -e "s/\]$/\]\npriority=5/g" /etc/yum.repos.d/epel.repo
# for another way, change to [enabled=0] anduse it only when needed
[root@linuxprobe ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
# if [enabled=0], input a command touse the repository
[root@linuxprobe ~]# yum --enablerepo=epel install [Package]
[root@linuxprobe ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order tologinto MariaDB to secure it, we'll need the current
password forthe root user. If you've just installed MariaDB, and
you haven't setthe root password yet, the password will be blank,
so you should just press enter here.Enter current password for root (enter for none):
OK, successfully used password, moving on...Setting the root password ensures that nobody can logintothe MariaDB
root user withoutthe proper authorisation.# set root password
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyone
tologinto MariaDB without having to have a user account created for
them. This is intended only for testing, andto make the installation
go a bit smoother. You should remove them before moving into a
production environment.
# remove anonymous users
Remove anonymous users? [Y/n] y... Success!Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess atthe root password fromthe network.# disallow root login remotely
Disallow root login remotely? [Y/n] y... Success!By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.# remove test database
Remove test database and access toit? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.# reload privilege tables
Reload privilege tables now? [Y/n] y... Success!Cleaning up...All done! If you've completed all oftheabove steps, your MariaDB
installation should now be secure.Thanks for using MariaDB!# connect to MariaDB with root
[root@linuxprobe ~]# mysql -u root -p
Enter password:
Welcome tothe MariaDB monitor. Commands endwith ; or \g.
Your MariaDB connection idis11
Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.# show user list
MariaDB [(none)]> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 |
| root | 127.0.0.1 | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 |
| root | ::1 | *E2ACEC2F2DA384EE6753673365DFEF35F0C272C9 |
+------+-----------+-------------------------------------------+3 rows inset (0.00 sec)# show database list
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+3 rows inset (0.00 sec)MariaDB [(none)]> exit
Bye
創(chuàng)建測(cè)試應(yīng)用程序
[root@linuxprobe ~]# gem install mysql2 --no-ri --no-rdoc -- --with-mysql-config=/usr/bin/mysql_config
[root@linuxprobe ~]# rails new SampleApp -d mysql
[root@linuxprobe ~]# cd SampleApp
[root@linuxprobe SampleApp]# vi config/database.ymldefault: &defaultadapter: mysql2encoding: utf8pool: 5username: rootpassword: password # MariaDB passwordsocket: /var/lib/mysql/mysql.sock
# create test application
[root@dlp SampleApp]# rails db:create
Created database 'SampleApp_development'
Created database 'SampleApp_test'
[root@dlp SampleApp]# rails generate scaffold testapp name:string title:string body:text
[root@dlp SampleApp]# rails db:migrate
[root@dlp SampleApp]# rails server --binding=0.0.0.0
=> Booting Puma
=> Rails 5.0.2 application starting in development onhttp://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.8.2 (ruby 2.3.1-p112), codename: Sassy Salamander
* Min threads: 5, max threads: 5
* Environment: development
* Listening ontcp://0.0.0.0:3000
Use Ctrl-C to stop