LoginSignup
5
6

More than 5 years have passed since last update.

サーバー構築・LAMP設定(メモ)

Last updated at Posted at 2015-05-24

 サクラVPS CentOS release 6.5 2015/05/21
 参考
 http://qiita.com/junki0605/items/6ce3df1933ef6d31ddfa

root権限で作業する。

$ su

Apache(webサーバー)設定

Apacheをインストールする

$ yum -y install httpd

Apacheが常に自動で起動するようにする

$ chkconfig httpd on

設定ファイルをいじってセキュリティを高める

$ cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
$ vim /etc/httpd/conf/httpd.conf

下記を変更

ServerTokens OS
  |
ServerTokens Prod
ServerSignature On
  |
ServerSignature Off
Options Indexes FollowSymLinks
  |
Options -Indexes FollowSymLinks

保存したら、下記コマンドで構文チェック

Service httpd configtest

Apacheを起動する

$ service httpd start

IPアドレスをブラウザからたたいてテストページが表示されれば成功!
OS起動時にApacheも自動で起動されるかチェック

$ chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

の様になればオッケー

phpの設定

phpのインストール

$ yum -y install php php-mbstring php-mysql php-gd

設定ファイルをいじる

$ cp /etc/php.ini/ /etc/php.ini.org
$ vim /etc/php.ini

以下を変更

;error_log = php_errors.log
  |
error_logs = /var/log/php_errors.log
;mbstring.language = japanese
  |
mbstring.language = Japanese
;mbstring.internal_encoding = EUC-JP
  |
mbstring.internal_encoding = UTF-8
;mbstring.http_input = auto
  |
mbstring.http_input = auto
;mbstring.detect_order = auto
  |
mbstring.detect_order = auto
expose_php = on
  |
expose_php = off
;date.timezone = 
  |
date.timezone = Asia/Tokyo

保存したら、設定を反映

$ service httpd restart

Mysqlの設定

mysqlをインストール

$ yum -y install mysql-server
$ rpm -qa mysql-server

設定ファイルをいじる

$ vim /etc/my.cnf

以下を記述
```
[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
skip-character-set-client-handshake
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
```
設定を反映

$ service mysqld start
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6