MacにVmwareで開発環境(CentOS6)つくりました②
MacにVmwareで開発環境(CentOS6)つくりました①の続きを書いていきます。
①は下記のリンクです。
MacにVmwareで開発環境(CentOS6)つくりました① - otukutunの日記
今回は、
ユーザの作成
まず、rootユーザでログインしてください。それから以下のコマンドを実行します。ここではユーザの追加とパスワードの設定、rootになれるユーザを管理者のみにする設定を行なっています。
# useradd ユーザ名 # passwd ユーザ名 Changing password for user ユーザ名. New password: Retype new password: passwd: all authentication tokens updated successfully. # usermod -G wheel ユーザ名 # vi /etc/pam.d/su #auth required pam_wheel.so use_uid ↓ auth required pam_wheel.so use_uid ← コメント解除 # visudo ←sudoできるように編集 ## Allows people in group wheel to run all commands # %wheel ALL=(ALL) ALL ↓ %wheel ALL=(ALL) ALL
サーバの設定(SELinuxの無効化、パッケージ関係のインストールまで)
selinuxの無効化、パッケージ関連のインストールを行なっています。まず、selinuxの無効化からです。
# getenforce ← SELinux状態確認 Enforcing ← SELinux有効 # setenforce 0 ← SELinux無効化 # getenforce ← SELinux状態確認 Permissive ← SELinux無効 # vi /etc/sysconfig/selinux ← SELinux設定ファイル編集 SELINUX=enforcing ↓ SELINUX=disabled ← システム起動時にSELinuxを無効化
iptablesの設定の無効化、再起動しても起動しないように設定します。
# /sbin/service iptables stop # chkconfig iptables off
パッケージ関連のインストールを行います。
# yum -y update ← インストール済パッケージの一括アップデート ※大量のパッケージのダウンロード/アップデートを行うため時間がかかる # yum -y install yum-cron ← yum-cronインストール # /etc/rc.d/init.d/yum-cron start ← パッケージ自動更新起動 夜間 yum 更新の有効化中: [ OK ] # chkconfig yum-cron on ← パッケージ自動更新自動起動設定 # yum -y groupinstall "Base" "Development tools" ← ベースパッケージ群、開発ツールパッケージ群インストール # yum -y install nkf ← nkfインストール #reboot ←ここまできたら再起動
サーバにWebサーバ、MySQL、PHPを入れます。
webサーバ、MySQL、PHP順番でいれます。はじめにwebサーバからapacheを入れます。再起動したら再度ログインします。今度は先程つくったユーザでろぐいんしてみます。
$ sudo yum -y install httpd $ sudo yum -y install mysql-server $ sudo yum -y install php php-devel php-pear php-mbstring php-gd php-mysql $ sudo vi /etc/httpd/conf/httpd.conf # AllowOverride None ↓ AllowOverride All ← .htaccessの許可 AddDefaultCharset UTF-8 ↓ #AddDefaultCharset UTF-8 ← コメントアウト(文字化け対応) <Directory "/var/www/icons"> Options Indexes MultiViews ↓ Options MultiViews ← iconsディレクトリのファイル一覧を表示しないようにする AllowOverride None Order allow,deny Allow from all </Directory> $ sudo chown ユーザ名. /var/www/html/ ← ドキュメントルート所有者を変更 $ sudo /etc/rc.d/init.d/httpd start ← httpd起動 httpd を起動中: [ OK ] $ sudo chkconfig httpd on ← httpd自動起動設定 $ sudo vi /etc/my.cnf ← MySQL設定ファイル編集 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 character-set-server = utf8 ← 追加(MySQLサーバーの文字コードをUTF-8にする) $ sudo /etc/rc.d/init.d/mysqld start $ sudo chkconfig mysqld on
とりあえず、MySQLのインストールまで終わったので、これからMySQLの設定をします。
$ mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the 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 log into the MySQL root user without the proper authorisation. Set root password? [Y/n] ← 空ENTER New password: ← rootパスワード入力 Re-enter new password: ← rootパスワード入力 Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] ← 空ENTER ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] ← 空ENTER ... Success! By default, MySQL 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 and access to it? [Y/n] ← 空ENTER - 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 now? [Y/n] ← 空ENTER ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
MySQLのユーザ追加と設定についてです。
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.1.67 Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> grant all privileges on *.* to ユーザ名@localhost identified by 'パスワード'; ←ユーザをつくる。 Query OK, 0 rows affected (0.00 sec) mysql> exit Bye
あと、vi /etc/php.iniで時間に関して設定をします。
date.timezone = "Asia/Tokyo"