Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VagrantでWorpressを構築する #1

Open
RVIRUS0817 opened this issue Mar 23, 2019 · 14 comments
Open

VagrantでWorpressを構築する #1

RVIRUS0817 opened this issue Mar 23, 2019 · 14 comments

Comments

@RVIRUS0817
Copy link

RVIRUS0817 commented Mar 23, 2019

  • Vagrantをインストール
  • mentaユーザーの作成とssh公開鍵認証をする
  • Apache/Nginx/H2Oのインストール それぞれの設定と比較
  • PHP7,php-fpm最新のインストールと設定
  • Mysql最新のインストールと設定(wordpress DBとwordpressユーザの作成)
  • Wordpress最新のインストール
  • menta.meでアクセスできるようにする
  • https オレオレ証明書でアクセスできるように
@so-suke
Copy link
Owner

so-suke commented Apr 8, 2019

Vagrantfileです。「menta.meでアクセスできるようにする」のためにhostnameを定義しております。

35c35,36
<   # config.vm.network "private_network", ip: "192.168.33.10"
---
>   config.vm.network "private_network", ip: "192.168.33.10", auto_config:true
>   config.vm.hostname = "menta.me"

@so-suke
Copy link
Owner

so-suke commented Apr 8, 2019

/etc/sudoers です。mentaユーザに全ての権限を与えております。(まずいでしょうか?)

> menta	ALL=(ALL) 	ALL

@so-suke
Copy link
Owner

so-suke commented Apr 8, 2019

ssh設定ファイル(/etc/ssh/sshd_config) です。

< #PermitRootLogin yes
---
> PermitRootLogin no
43c43,44
< #PubkeyAuthentication yes
---
> RSAAuthentication yes
> PubkeyAuthentication yes
63,64c64,65
< #PasswordAuthentication yes
< #PermitEmptyPasswords no
---
> PasswordAuthentication no
> PermitEmptyPasswords no

@so-suke
Copy link
Owner

so-suke commented Apr 8, 2019

apacheの設定ファイル(/etc/httpd/conf/httpd.conf) です。
検索で出てきたページのものを真似させて頂きました。

95c95
< #ServerName www.example.com:80
---
> ServerName www.example.com:80
144c144
<     Options Indexes FollowSymLinks
---
>     Options -Indexes
151c151
<     AllowOverride None
---
>     AllowOverride All
164c164
<     DirectoryIndex index.html
---
>     DirectoryIndex index.html index.php
217a218,235
> 	#画像とスタイルシートをログに記録しない。
> 	SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(css)$" no_log
> 	#Worm(ウイルス)系のログは worm_logに書き出す。
> 	SetEnvIf Request_URI "^/_mem_bin/" worm no_log
> 	SetEnvIf Request_URI "^/_vti_bin/" worm no_log
> 	SetEnvIf Request_URI "^/c/" worm no_log
> 	SetEnvIf Request_URI "^/d/" worm no_log
> 	SetEnvIf Request_URI "^/msadc/" worm no_log
> 	SetEnvIf Request_URI "^/MSADC/" worm no_log
> 	SetEnvIf Request_URI "^/scripts/" worm no_log
> 	SetEnvIf Request_URI "^/default.ida" worm no_log
> 	SetEnvIf Request_URI "root\.exe" worm no_log
> 	SetEnvIf Request_URI "cmd\.exe" worm no_log
> 	SetEnvIf Request_URI "NULL\.IDA" worm no_log
> 	#wormログを記録する。
> 	CustomLog "logs/worm_log" combined env=worm
> 	#no_log以外をaccess_logに記録する。
> 	CustomLog "logs/access_log" combined env=!no_log

@so-suke
Copy link
Owner

so-suke commented Apr 8, 2019

apacheのセキュリティ設定ファイル(/etc/httpd/conf.d/security.conf)です。
元々無いファイルですので、新しく作成しました。

# バージョン情報の隠蔽
ServerTokens Prod
Header unset X-Powered-By
# サーバ署名(バージョンとサーバ名)のOFF
ServerSignature Off
# httpoxy 対策
RequestHeader unset Proxy
# クリックジャッキング対策
Header append X-Frame-Options SAMEORIGIN
# XSS対策
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff
# XST対策
TraceEnable Off

@so-suke
Copy link
Owner

so-suke commented Apr 12, 2019

phpの設定比較
(/etc/php.ini を編集)

開発用にエラーを出力するようにしております。

96c96
< ; display_errors
---
> display_errors On
151c151
< ; short_open_tag
---
> short_open_tag Off
376c376
< expose_php = On
---
> expose_php = Off
406c406
< memory_limit = 128M
---
> memory_limit = 32M
479c479
< display_errors = Off
---
> display_errors = On
490c490
< display_startup_errors = Off
---
> display_startup_errors = On
586a587
> error_log = /var/log/php_error.log
894c895,896
< ;   extension=mysqli
---
> extension=mysqli
> extension=msql.so
922c924
< ;date.timezone =
---
> date.timezone = Asia/Tokyo
1535c1537
< ;mbstring.language = Japanese
---
> mbstring.language = Japanese
1546a1549
> mbstring.encoding_translation = Off
1573c1576
< ;mbstring.detect_order = auto
---
> mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII

@so-suke
Copy link
Owner

so-suke commented Apr 12, 2019

php-fpmの設定比較
(/etc/php-fpm.d/www.conf を編集)

24c24,25
< user = apache
---
> ;user = apache
> user = nginx
26c27,28
< group = apache
---
> ;group = apache
> group = nginx
38c40,41
< listen = 127.0.0.1:9000
---
> ;listen = 127.0.0.1:9000
> listen = /var/run/php-fpm/php-fpm.sock
48,49c51,52
< ;listen.owner = nobody
< ;listen.group = nobody
---
> listen.owner = nginx
> listen.group = nginx

@so-suke
Copy link
Owner

so-suke commented Apr 12, 2019

mysql設定比較 (/etc/my.cnf を編集)
文字コードがutf-8になるように編集しました。

32a33,35
> 
> character_set_server=utf8
> skip-character-set-client-handshake

※併せて、mysql_secure_installationコマンドを実行しました。

@so-suke
Copy link
Owner

so-suke commented Apr 12, 2019

・mysql設定比較(/etc/my.cnf を編集)
文字コードがutf-8になるように編集しました。

32a33,35
> 
> character_set_server=utf8
> skip-character-set-client-handshake

※併せて、mysql_secure_installationコマンドを実行しました。

@so-suke
Copy link
Owner

so-suke commented Apr 12, 2019

wordpress設定比較(wp-config-sample.php をコピーして編集)

29c29
< define('DB_NAME', 'database_name_here');
---
> define('DB_NAME', 'wordpress');
32c32
< define('DB_USER', 'username_here');
---
> define('DB_USER', 'wordpress');
35c35
< define('DB_PASSWORD', 'password_here');
---
> define('DB_PASSWORD', 'f3Dd3<Diz');
38c38
< define('DB_HOST', 'localhost');
---
> define('DB_HOST', 'localhost:/var/lib/mysql/mysql.sock');
55,63c55,62
< define('AUTH_KEY',         'put your unique phrase here');
< define('SECURE_AUTH_KEY',  'put your unique phrase here');
< define('LOGGED_IN_KEY',    'put your unique phrase here');
< define('NONCE_KEY',        'put your unique phrase here');
< define('AUTH_SALT',        'put your unique phrase here');
< define('SECURE_AUTH_SALT', 'put your unique phrase here');
< define('LOGGED_IN_SALT',   'put your unique phrase here');
< define('NONCE_SALT',       'put your unique phrase here');
< 
---
> define('AUTH_KEY',         'Y8`ddI|A}lqO<?e1:68(=OmxVjVxZf.8;mfM*[.L|_XvDzQrl5Vnn4~|I/Zsca[C');
> define('SECURE_AUTH_KEY',  '0vGMK>^eLs7&+Vd;oXr+m8_h+jL,<-&M;+mum|[HOVUjs&kS5.A$AK^7v/WBH_mk');
> define('LOGGED_IN_KEY',    ';Ga<>FlfyNW,v&PE=]A_+koFo72!E[SEN-jEiqD||TV9g;9*V3Z#f5si:6RO-vQ9');
> define('NONCE_KEY',        '-(/VJ[wC%}#NdeaU-4D<mw$BwdAi[6K0bFR>M0Y--HGWBDSX5<yp]k3%U8TKOn85');
> define('AUTH_SALT',        '7u w{`f+MU/!*t}l1zZQ,q?PR4gaVB;pc){2qIVyqXu[Rab+gxxT?[2HtH|u s!t');
> define('SECURE_AUTH_SALT', 'rexH&};|7: V4zd|!I^nmcDKJChOP:WR* 4TWQ,G88t:62S^Qb*uaI=TaQg~9NOT');
> define('LOGGED_IN_SALT',   '{lmv+PIby6tIBHE`s|w0@?*D?D<uS jxOzz%?*a`-WSdMg]Opa|+TWDu%QGG4LkP');
> define('NONCE_SALT',       '._m+/vOe2!,B[z)066u>hUAf@FVcKl|r_~D]D4WYfV,sM-`p-+<okx<@YZmKEi7r');
84c83,85
< define('WP_DEBUG', false);
---
> define('WP_DEBUG', true);
> define('WP_DEBUG_LOG', true); //debug.logファイルに記録
> define('WP_DEBUG_DISPLAY', true); //開発中のみ: ブラウザにエラーを出力する

@so-suke
Copy link
Owner

so-suke commented Apr 12, 2019

nginxの設定ファイルとして、 /etc/nginx/conf.d/wordpress.conf を作成しました。
以下、wordpress.conf の内容です。

server {
	listen 443 ssl;
	server_name  menta.me;
	root         /usr/share/nginx/html/wordpress;
	ssl on;
	ssl_certificate /usr/share/nginx/conf/server.crt;
	ssl_certificate_key /usr/share/nginx/conf/server.key;
	index index.php index.html index.htm;

	# Load configuration files for the default server block.
	include /etc/nginx/default.d/*.conf;
	location ~ .php$ {
		fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
		include fastcgi_params;
	}

	error_page 404 /404.html;
		location = /40x.html {
	}

	error_page 500 502 503 504 /50x.html;
		location = /50x.html {
	}
}

@so-suke
Copy link
Owner

so-suke commented Apr 15, 2019

投稿記事が表示されております。
Screenshot from 2019-04-15 16-40-29

@so-suke
Copy link
Owner

so-suke commented Apr 15, 2019

プラグインのインストールが出来ているかと思います。
Screenshot from 2019-04-15 16-42-01

@so-suke
Copy link
Owner

so-suke commented Apr 15, 2019

テーマのインストールが出来ているかと思います。
Screenshot from 2019-04-15 16-43-18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants