Vagrantで立てたCnetOS7にLAMP環境を構築する


Vagrantで立てたCnetOS7にLAMP環境を構築する | Bamboo lath 日々の記録Vagrantで立てたCnetOS7にLAMP環境を構築する

ざっくりとローカル環境を構築する手順。

【とりあえず】

# yum update

【時間】

# timedatectl status
      Local time: Wed 2015-05-27 00:34:51 EDT
  Universal time: Wed 2015-05-27 04:34:51 UTC
        Timezone: America/New_York (EDT, -0400)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2015-03-08 01:59:59 EST
                  Sun 2015-03-08 03:00:00 EDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2015-11-01 01:59:59 EDT
                  Sun 2015-11-01 01:00:00 EST

# timedatectl set-timezone Asia/Tokyo

# timedatectl status
      Local time: Wed 2015-05-27 13:35:36 JST
  Universal time: Wed 2015-05-27 04:35:36 UTC
        Timezone: Asia/Tokyo (JST, +0900)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

# date
Wed May 27 13:35:46 JST 2015

【日本語化】

# yum -y install ibus-kkc vlgothic-* 

# localectl list-locales | grep -i ja
ja_JP
ja_JP.eucjp
ja_JP.ujis
ja_JP.utf8
japanese
japanese.euc

# localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: jp106
      X11 Layout: jp

# localectl set-locale LANG=ja_JP.utf8

# localectl status
   System Locale: LANG=ja_JP.utf8
       VC Keymap: jp106
      X11 Layout: jp

# source /etc/locale.conf

# echo $LANG
ja_JP.utf8

# date
2015年  5月 27日 水曜日 13:42:59 JST

【NTP】

# yum install chrony

# systemctl start chronyd.service

# systemctl enable chronyd.service

# systemctl status chronyd.service
chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled)
   Active: active (running) since 水 2015-05-27 13:53:36 JST; 7min ago
 Main PID: 4658 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─4658 /usr/sbin/chronyd -u chrony

 5月 27 13:53:36 localhost.localdomain chronyd[4658]: chronyd version 1.29.1 starting
 5月 27 13:53:36 localhost.localdomain chronyd[4658]: Linux kernel major=3 minor=10 patch=0
 5月 27 13:53:36 localhost.localdomain chronyd[4658]: hz=100 shift_hz=7 freq_scale=1.00000000 nominal_tick=10000 slew_delta_tick=833 max_tick_bias=1000 shift_pll=2
 5月 27 13:53:36 localhost.localdomain chronyd[4658]: Generated key 1
 5月 27 13:53:36 localhost.localdomain systemd[1]: Started NTP client/server.
 5月 27 13:53:41 localhost.localdomain chronyd[4658]: Selected source 157.7.235.92
 5月 27 13:53:41 localhost.localdomain chronyd[4658]: System clock wrong by 404.387741 seconds, adjustment started
 5月 27 14:00:25 localhost.localdomain chronyd[4658]: System clock was stepped by 404.388 seconds

・状態確認
# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ y.ns.gin.ntt.net              2   6    37    29   +714us[  -30ms] +/-   49ms
^+ li528-174.members.linode.     3   6    37    29   +111us[  -30ms] +/-   59ms
^+ chobi.paina.jp                2   6    37    29   -321us[  -31ms] +/-   47ms
^* v157-7-235-92.z1d6.static     2   6    37    29   -727us[  -32ms] +/-   38ms

「*」が現在同期をとっているサーバ

【SELinux】

# getenforce 
Enforcing

ローカルの開発環境なので無効にする
# vim /etc/selinux/config  
SELINUX=disabled

# reboot

# getenforce
Disabled

【Webサーバ】

# yum install httpd httpd-devel httpd-tools

# systemctl status httpd.service
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
   Active: inactive (dead)

# systemctl start httpd.service

# systemctl enable httpd.service

# systemctl status httpd.service
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Tue 2015-05-26 21:12:03 EDT; 1min 10s ago
 Main PID: 7308 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─7308 /usr/sbin/httpd -DFOREGROUND
           ├─7309 /usr/sbin/httpd -DFOREGROUND
           ├─7310 /usr/sbin/httpd -DFOREGROUND
           ├─7311 /usr/sbin/httpd -DFOREGROUND
           ├─7312 /usr/sbin/httpd -DFOREGROUND
           └─7313 /usr/sbin/httpd -DFOREGROUND

May 26 21:12:03 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
May 26 21:12:03 localhost.localdomain httpd[7308]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
May 26 21:12:03 localhost.localdomain systemd[1]: Started The Apache HTTP Server.

# firewall-cmd --permanent --add-service=http
success

# firewall-cmd --reload
success

# pwd
/etc/httpd/conf

# cp httpd.conf httpd.conf.org

# vim httpd.conf

# pwd
/etc/httpd/conf.d

# cp userdir.conf userdir.conf.org

# vim userdir.conf

# systemctl restart httpd.service

【PHP】

# yum install php php-cli php-common php-devel php-gd php-mbstring php-mysql php-pdo php-xml php-xmlrpc php-pear

# pwd
/etc

# cp php.ini php.ini.org

# systemctl restart httpd.service

【データベース】

# yum install mariadb-server mariadb-devel mariadb-libs  

# systemctl start mariadb.service

# systemctl enable mariadb.service

# firewall-cmd --permanent --add-service=mysql
success

# firewall-cmd --reload
success

# systemctl status mariadb.service
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled)
   Active: active (running) since Tue 2015-05-26 22:22:28 EDT; 1min 24s ago
 Main PID: 12165 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─12165 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─12323 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: The latest information about MariaDB is available at http://mariadb.org/.
May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: You can find additional information about the MySQL part at:
May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: http://dev.mysql.com
May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: Support MariaDB development by buying support/new features from MariaDB
May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: Corporation Ab. You can contact us about this at sales@mariadb.com.
May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: Alternatively consider joining our community based development effort:
May 26 22:22:26 localhost.localdomain mariadb-prepare-db-dir[12087]: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
May 26 22:22:26 localhost.localdomain mysqld_safe[12165]: 150526 22:22:26 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
May 26 22:22:26 localhost.localdomain mysqld_safe[12165]: 150526 22:22:26 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
May 26 22:22:28 localhost.localdomain systemd[1]: Started MariaDB database server.

# mysqladmin -u root password '******'

# mysqladmin -p -u root -h localhost password '******'
Enter password: 

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

設定ファイルを変更する
# pwd
/etc

# cp my.cnf my.cnf.org

# diff my.cnf.org  my.cnf                                                                                                                                                                                                
10a11,12
> character-set-server = utf8
> 

※[mysqld] に、character-set-server = utf8 を追記。

# systemctl restart mariadb.service

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

【Samba】

# yum install samba samba-client samba-common samba-devel samba-libs

# systemctl start smb.service

# systemctl enable smb.service

# firewall-cmd --permanent --add-service=samba
success

# firewall-cmd --permanent --add-service=samba-client
success

# firewall-cmd --reload
success

・ユーザの追加
# pdbedit -a -u linuxusername
new password:
retype new password:
Unix username:        linuxusername
NT username:          
Account Flags:        [U          ]
User SID:             S-1-5-21-3433598194-894145024-3160967228-1000
Primary Group SID:    S-1-5-21-3433598194-894145024-3160967228-513
Full Name:            
Home Directory:       \\localhost\linuxusername
HomeDir Drive:        
Logon Script:         
Profile Path:         \\localhost\linuxusername\profile
Domain:               LOCALHOST
Account desc:         
Workstations:         
Munged dial:          
Logon time:           0
Logoff time:          Wed, 06 Feb 2036 10:06:39 EST
Kickoff time:         Wed, 06 Feb 2036 10:06:39 EST
Password last set:    Wed, 27 May 2015 00:03:41 EDT
Password can change:  Wed, 27 May 2015 00:03:41 EDT
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

・セクションの追加
# pwd
/etc/samba

# cp smb.conf smb.conf.org

# vim smb.conf

# diff smb.conf.org smb.conf
296a297,306
> 
>       comment = Document Root Directory
>       path = /var/www/html
>       public = yes
>       writable = yes
>       printable = no
> 
>       create mask = 0664
>       directory mask = 0775
> 

【サービスの公開状態確認】

# firewall-cmd  --list-services
dhcpv6-client http mysql samba samba-client ssh

コメントを残す

メールアドレスが公開されることはありません。