so-suke / menta

0 stars 0 forks source link

VagrantでWorpressを構築する #1

Open RVIRUS0817 opened 5 years ago

RVIRUS0817 commented 5 years ago
so-suke commented 5 years ago

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 commented 5 years ago

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

> menta ALL=(ALL)   ALL
so-suke commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

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

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

so-suke commented 5 years ago

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

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

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

so-suke commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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

so-suke commented 5 years ago

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

so-suke commented 5 years ago

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