さくらVPSサーバ設定メモ(4)

2011年5月14日 オフ 投稿者: KYO
Table of Contents

おおよその初期設定は終わったので、以後各パッケージ、サービスの設定。

  • fastestmirror
  • vim
  • php
  • apache

  • fastestmirror

[shell]

# yum install yum-fastestmirror

# yum install yum-allowdowngrade

[/shell]

 

  • vim

[shell]

$ sudo yum install vim-X11 vim-common vim-enhanced vim-minimal

[/shell]

 

  • php

[shell]

$ sudo yum install php php-devel php-mbstring php-pgsql php-mysql php-cli php-xml php-common php-pdo php-gd php-jpgraph

$ sudo vim /etc/php.ini

 

[PHP]

engine = On

zend.ze1_compatibility_mode = Off

short_open_tag = Off

asp_tags = Off

precision = 14

y2k_compliance = On

output_buffering = 4096

zlib.output_compression = Off

implicit_flush = Off

unserialize_callback_func=

serialize_precision = 100

allow_call_time_pass_reference = Off

safe_mode = Off

safe_mode_gid = Off

safe_mode_include_dir =

safe_mode_exec_dir =

safe_mode_allowed_env_vars = PHP_

safe_mode_protected_env_vars = LD_LIBRARY_PATH

disable_functions =

disable_classes =

expose_php = On

max_execution_time = 30 ; Maximum execution time of each script, in seconds

max_input_time = 60 ; Maximum amount of time each script may spend parsing request data

memory_limit = 128M ; Maximum amount of memory a script may consume

error_reporting = E_ALL

display_errors = Off

display_startup_errors = Off

log_errors = On

log_errors_max_len = 1024

ignore_repeated_errors = Off

ignore_repeated_source = Off

report_memleaks = On

track_errors = Off

variables_order = “EGPCS”

register_globals = Off

register_long_arrays = Off

register_argc_argv = Off

auto_globals_jit = On

post_max_size = 8M

magic_quotes_gpc = Off

magic_quotes_runtime = Off

magic_quotes_sybase = Off

auto_prepend_file =

auto_append_file =

default_mimetype = “text/html”

doc_root =

user_dir =

extension_dir = “/usr/lib/php/modules”

enable_dl = On

file_uploads = On

upload_max_filesize = 2M

allow_url_fopen = On

default_socket_timeout = 60

[Date]

[Syslog]

define_syslog_variables = Off

[mail function]

SMTP = localhost

smtp_port = 25

sendmail_path = /usr/sbin/sendmail -t -i

[SQL]

sql.safe_mode = Off

[ODBC]

odbc.allow_persistent = On

odbc.check_persistent = On

odbc.max_persistent = -1

odbc.max_links = -1

odbc.defaultlrl = 4096

odbc.defaultbinmode = 1

[MySQL]

mysql.allow_persistent = On

mysql.max_persistent = -1

mysql.max_links = -1

mysql.default_port =

mysql.default_socket =

mysql.default_host =

mysql.default_user =

mysql.default_password =

mysql.connect_timeout = 60

mysql.trace_mode = Off

[MySQLi]

mysqli.max_links = -1

mysqli.default_port = 3306

mysqli.default_socket =

mysqli.default_host =

mysqli.default_user =

mysqli.default_pw =

mysqli.reconnect = Off

[mSQL]

msql.allow_persistent = On

msql.max_persistent = -1

msql.max_links = -1

[PostgresSQL]

pgsql.allow_persistent = On

pgsql.auto_reset_persistent = Off

pgsql.max_persistent = -1

pgsql.max_links = -1

pgsql.ignore_notice = 0

pgsql.log_notice = 0

[Sybase]

sybase.allow_persistent = On

sybase.max_persistent = -1

sybase.max_links = -1

sybase.min_error_severity = 10

sybase.min_message_severity = 10

sybase.compatability_mode = Off

[Sybase-CT]

sybct.allow_persistent = On

sybct.max_persistent = -1

sybct.max_links = -1

sybct.min_server_severity = 10

sybct.min_client_severity = 10

[bcmath]

bcmath.scale = 0

[browscap]

[Informix]

ifx.default_host =

ifx.default_user =

ifx.default_password =

ifx.allow_persistent = On

ifx.max_persistent = -1

ifx.max_links = -1

ifx.textasvarchar = 0

ifx.byteasvarchar = 0

ifx.charasvarchar = 0

ifx.blobinfile = 0

ifx.nullformat = 0

[Session]

session.save_handler = files

session.save_path = “/var/lib/php/session”

session.use_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

session.serialize_handler = php

session.gc_probability = 1

session.gc_divisor = 1000

session.gc_maxlifetime = 1440

session.bug_compat_42 = 0

session.bug_compat_warn = 1

session.referer_check =

session.entropy_length = 0

session.entropy_file =

session.cache_limiter = nocache

session.cache_expire = 180

session.use_trans_sid = 0

session.hash_function = 0

session.hash_bits_per_character = 5

url_rewriter.tags = “a=href,area=href,frame=src,input=src,form=fakeentry”

[MSSQL]

mssql.allow_persistent = On

mssql.max_persistent = -1

mssql.max_links = -1

mssql.min_error_severity = 10

mssql.min_message_severity = 10

mssql.compatability_mode = Off

mssql.secure_connection = Off

[Assertion]

[Verisign Payflow Pro]

pfpro.defaulthost = “test-payflow.verisign.com”

pfpro.defaultport = 443

pfpro.defaulttimeout = 30

[COM]

[mbstring]

mbstring.language = Japanese

mbstring.internal_encoding = UTF-8

mbstring.http_input = auto

mbstring.http_output = UTF-8

mbstring.encoding_translation = Off

mbstring.detect_order = auto

mbstring.substitute_character = none;

mbstring.func_overload = 0

mbstring.strict_encoding = Off

[FrontBase]

[gd]

[exif]

[Tidy]

tidy.clean_output = Off

[soap]

soap.wsdl_cache_enabled=1

soap.wsdl_cache_dir=”/tmp”

soap.wsdl_cache_ttl=86400

[/shell]

 

  • apache(install)

[shell]

# sudo yum install -y httpd httpd-devel httpd-manual openssl mod_ssl mod_rewrite mod_python openssl-devel

$ sudo vim /etc/httpd/conf/httpd.conf

 

ServerTokens OS

ServerRoot “/etc/httpd”

PidFile run/httpd.pid

Timeout 120

KeepAlive Off

MaxKeepAliveRequests 100

KeepAliveTimeout 15

<IfModule prefork.c>

StartServers 8

MinSpareServers 5

MaxSpareServers 20

ServerLimit 256

MaxClients 256

MaxRequestsPerChild 4000

</IfModule>

<IfModule worker.c>

StartServers 2

MaxClients 150

MinSpareThreads 25

MaxSpareThreads 75

ThreadsPerChild 25

MaxRequestsPerChild 0

</IfModule>

Listen 80

LoadModule auth_basic_module modules/mod_auth_basic.so

LoadModule auth_digest_module modules/mod_auth_digest.so

LoadModule authn_file_module modules/mod_authn_file.so

LoadModule authn_alias_module modules/mod_authn_alias.so

LoadModule authn_anon_module modules/mod_authn_anon.so

LoadModule authn_dbm_module modules/mod_authn_dbm.so

LoadModule authn_default_module modules/mod_authn_default.so

LoadModule authz_host_module modules/mod_authz_host.so

LoadModule authz_user_module modules/mod_authz_user.so

LoadModule authz_owner_module modules/mod_authz_owner.so

LoadModule authz_groupfile_module modules/mod_authz_groupfile.so

LoadModule authz_dbm_module modules/mod_authz_dbm.so

LoadModule authz_default_module modules/mod_authz_default.so

LoadModule ldap_module modules/mod_ldap.so

LoadModule authnz_ldap_module modules/mod_authnz_ldap.so

LoadModule include_module modules/mod_include.so

LoadModule log_config_module modules/mod_log_config.so

LoadModule logio_module modules/mod_logio.so

LoadModule env_module modules/mod_env.so

LoadModule ext_filter_module modules/mod_ext_filter.so

LoadModule mime_magic_module modules/mod_mime_magic.so

LoadModule expires_module modules/mod_expires.so

LoadModule deflate_module modules/mod_deflate.so

LoadModule headers_module modules/mod_headers.so

LoadModule usertrack_module modules/mod_usertrack.so

LoadModule setenvif_module modules/mod_setenvif.so

LoadModule mime_module modules/mod_mime.so

LoadModule dav_module modules/mod_dav.so

LoadModule status_module modules/mod_status.so

LoadModule autoindex_module modules/mod_autoindex.so

LoadModule info_module modules/mod_info.so

LoadModule dav_fs_module modules/mod_dav_fs.so

LoadModule vhost_alias_module modules/mod_vhost_alias.so

LoadModule negotiation_module modules/mod_negotiation.so

LoadModule dir_module modules/mod_dir.so

LoadModule actions_module modules/mod_actions.so

LoadModule speling_module modules/mod_speling.so

LoadModule userdir_module modules/mod_userdir.so

LoadModule alias_module modules/mod_alias.so

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule cache_module modules/mod_cache.so

LoadModule suexec_module modules/mod_suexec.so

LoadModule disk_cache_module modules/mod_disk_cache.so

LoadModule file_cache_module modules/mod_file_cache.so

LoadModule mem_cache_module modules/mod_mem_cache.so

LoadModule cgi_module modules/mod_cgi.so

LoadModule version_module modules/mod_version.so

Include conf.d/vhost/*.conf

Include conf.d/*.conf

User apache

Group apache

ServerAdmin root@localhost

ServerName www1107ub.sakura.ne.jp:80

UseCanonicalName Off

DocumentRoot “/var/www/html”

<Directory />

Options FollowSymLinks

AllowOverride None

</Directory>

<Directory “/var/www/html”>

Options Indexes FollowSymLinks ExecCGI MultiViews Includes

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<IfModule mod_userdir.c>

UserDir disable

</IfModule>

DirectoryIndex index.php index.cgi index.shtml index.html index.html.var

AccessFileName .htaccess

<Files ~ “^\.ht”>

Order allow,deny

Deny from all

</Files>

TypesConfig /etc/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>

MIMEMagicFile conf/magic

</IfModule>

HostnameLookups Off

ErrorLog logs/error_log

LogLevel warn

LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined

LogFormat “%h %l %u %t \”%r\” %>s %b” common

LogFormat “%{Referer}i -> %U” referer

LogFormat “%{User-agent}i” agent

CustomLog logs/access_log combined

ServerSignature On

Alias /icons/ “/var/www/icons/”

<Directory “/var/www/icons”>

Options Indexes MultiViews

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<IfModule mod_dav_fs.c>

DAVLockDB /var/lib/dav/lockdb

</IfModule>

ScriptAlias /cgi-bin/ “/var/www/cgi-bin/”

<Directory “/var/www/cgi-bin”>

AllowOverride None

Options None

Order allow,deny

Allow from all

</Directory>

IndexOptions FancyIndexing VersionSort NameWidth=* HTMLTable

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*

AddIconByType (IMG,/icons/image2.gif) image/*

AddIconByType (SND,/icons/sound2.gif) audio/*

AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe

AddIcon /icons/binhex.gif .hqx

AddIcon /icons/tar.gif .tar

AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv

AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip

AddIcon /icons/a.gif .ps .ai .eps

AddIcon /icons/layout.gif .html .shtml .htm .pdf

AddIcon /icons/text.gif .txt

AddIcon /icons/c.gif .c

AddIcon /icons/p.gif .pl .py

AddIcon /icons/f.gif .for

AddIcon /icons/dvi.gif .dvi

AddIcon /icons/uuencoded.gif .uu

AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl

AddIcon /icons/tex.gif .tex

AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..

AddIcon /icons/hand.right.gif README

AddIcon /icons/folder.gif ^^DIRECTORY^^

AddIcon /icons/blank.gif ^^BLANKICON^^

DefaultIcon /icons/unknown.gif

ReadmeName README.html

HeaderName HEADER.html

IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

AddLanguage ca .ca

AddLanguage cs .cz .cs

AddLanguage da .dk

AddLanguage de .de

AddLanguage el .el

AddLanguage en .en

AddLanguage eo .eo

AddLanguage es .es

AddLanguage et .et

AddLanguage fr .fr

AddLanguage he .he

AddLanguage hr .hr

AddLanguage it .it

AddLanguage ja .ja

AddLanguage ko .ko

AddLanguage ltz .ltz

AddLanguage nl .nl

AddLanguage nn .nn

AddLanguage no .no

AddLanguage pl .po

AddLanguage pt .pt

AddLanguage pt-BR .pt-br

AddLanguage ru .ru

AddLanguage sv .sv

AddLanguage zh-CN .zh-cn

AddLanguage zh-TW .zh-tw

LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW

ForceLanguagePriority Prefer Fallback

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddHandler cgi-script .cgi .pl

AddHandler type-map var

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml

Alias /error/ “/var/www/error/”

<IfModule mod_negotiation.c>

<IfModule mod_include.c>

<Directory “/var/www/error”>

AllowOverride None

Options IncludesNoExec

AddOutputFilter Includes html

AddHandler type-map var

Order allow,deny

Allow from all

LanguagePriority en es de fr

ForceLanguagePriority Prefer Fallback

</Directory>

</IfModule>

</IfModule>

BrowserMatch “Mozilla/2” nokeepalive

BrowserMatch “MSIE 4\.0b2;” nokeepalive downgrade-1.0 force-response-1.0

BrowserMatch “RealPlayer 4\.0” force-response-1.0

BrowserMatch “Java/1\.0” force-response-1.0

BrowserMatch “JDK/1\.0” force-response-1.0

BrowserMatch “Microsoft Data Access Internet Publishing Provider” redirect-carefully

BrowserMatch “MS FrontPage” redirect-carefully

BrowserMatch “^WebDrive” redirect-carefully

BrowserMatch “^WebDAVFS/1.[0123]” redirect-carefully

BrowserMatch “^gnome-vfs/1.0” redirect-carefully

BrowserMatch “^XML Spy” redirect-carefully

BrowserMatch “^Dreamweaver-WebDAV-SCM1” redirect-carefully

NameVirtualHost *:80

[/shell]

 

  • apache(service)

[shell]

$ sudo /etc/rc.d/init.d/httpd restart

$ sudo chkconfig httpd on

[/shell]

 

  • apache(virtualhost) — 自ドメイン用

[shell]

$ sudo vim /etc/httpd/conf.d/vhost/thekyo.jp.conf

 

<VirtualHost *:80>

ServerName www.example.com

ServerAdmin admin@example.com

ServerAlias www.example.com

DocumentRoot /home/sites/exmaple.com

ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var

ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var

ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var

ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var

Alias /favicon.ico /var/www/html/favicon.ico

RewriteEngine on

AddHandler application/x-httpd-php .php .php4 .php5

DirectoryIndex dnet.cgi index.php index.pl index.html index.htm

</VirtualHost>

<Directory “/home/sites/example.com”>

Options Indexes FollowSymLinks Includes ExecCGI MultiViews

AllowOverride All

Order allow,deny

Allow from all

</Directory>

[/shell]

 

  • apache(virtualhost) — サーバードメイン用

[shell]

$ sudo vim /etc/httpd/conf.d/vhost/wwwXXXX.sakura.ne.jp.conf

 

 

<VirtualHost *:80>

ServerName wwwXXXX.sakura.ne.jp

ServerAdmin admin@example.com

ServerAlias wwwXXXX.sakura.ne.jp

DocumentRoot /var/www/html

ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var

ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var

ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var

ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var

Alias /favicon.ico /var/www/html/favicon.ico

RewriteEngine on

AddHandler application/x-httpd-php .php .php4 .php5

DirectoryIndex dnet.cgi index.php index.pl index.html index.htm

</VirtualHost>

<Directory “/var/www/html”>

Options Indexes FollowSymLinks Includes ExecCGI MultiViews

AllowOverride All

Order allow,deny

Allow from all

</Directory>

[/shell]