おもしろ雑学集

WEBサーバの建て方(序盤)

日付
編集
分類
画像0枚
PV日0 月371 年2779
50%

連休は暇な人が多いのでWEBサーバの建て方を私が普段やっている手順でざっくりご紹介します。
Amazon Web Service(AWS)かGoogle Cloud Compute Platform(GCP)を使います。

このやり方でHTTPSとHTTP/2のセキュリティ万全で高速なWEBサイトを構築することができます。


SSHログインのポートを22から30000~59999の間に変更します。




sudo su -
yum update -y
vi /etc/ssh/sshd_config
# Port 22
Port 51843 # 3万から6万以下の数値に変更(覚えておくこと)
:wq で保存して終了
semanage port -a -t ssh_port_t -p tcp 51843
vi /etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled

自身が無い方はdisabledにします。enforcingで有効状態だと、稀に変なエラーがでてなかなか解決できない場合があり、原因がSELINUXであることが多いです。

reboot

ここでAWSならセキュリティグループ、GCPならVPCからIPファイヤーウォールでPort22をPort51843にします。

yum install gcc pcre-devel zlib-devel gcc-c++ git wget -y
cd /usr/local/src/
useradd --shell /sbin/nologin nginx

最新バージョンを各ページでチェックします
https://nginx.org/download
https://ftp.pcre.org/pub/pcre
http://www.zlib.net/
https://www.openssl.org/source

wget https://nginx.org/download/nginx-1.15.9.tar.gz && tar xzvf nginx-1.15.9.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz && tar xzvf pcre-8.42.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz && tar xzvf openssl-1.1.1a.tar.gz
rm -rf *.tar.gz
cd nginx*


./configure --prefix=/usr/share/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-openssl=../openssl-1.1.1a \
--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
--with-openssl-opt=no-nextprotoneg \
--with-openssl-opt=no-weak-ssl-ciphers \
--with-openssl-opt=no-ssl3 \
--with-pcre=../pcre-8.42 \
--with-pcre-jit \
--with-zlib=../zlib-1.2.11 \
--with-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-http_secure_link_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-debug \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --with-ld-opt=-Wl,-E

make
make install
nginx -t
vi /etc/systemd/system/nginx.service

:set pasteで貼り付けモードにしてiで挿入モードにしてからCtrl+Pでコピペします↓

[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on;master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on;master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on;master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target


:wqで保存して終了します


systemctl enable nginx
systemctl start nginx

yum install vim -y
cd /usr/share/vim/vim74/syntax

curl -Lkvf https://www.vim.org/scripts/download_script.php?src_id=19394 -o nginx.vim

[飽きた疲れたので記事を終わります]

  • 🥰抜けました
    2
  • 🥹感動しました
    1
  • 😆笑いました
    2
  • 🤔意味わからんです
    1
  • 😡胸糞悪かったです
    1
  • 😣萎えてしまいました
    3
  • 投票する
この記事をブックマーク
    日付
    編集
    分類
    画像0枚
    PV日0 月371 年2779
    50%
    お読み頂きありがとうございました!
    Thanks Good Read again!
    コメントを書き込め
    本文必須 最低2字 最大400字 名前空欄可 最大20字
    コメント一覧
    1
    a3d55c

    ee

    0
    0
    返信
    2
    da7ede

    ee

    0
    0
    返信
    3
    da7ede

    ee

    0
    0
    返信
    4
    4a3798

    I'm waiting for you on bed f1nd me on megangoldberg_mooo_com change _ to dot

    0
    0
    返信
    関連記事
    2019年10月22日の即位礼正殿の日に集めたやっつけクソ画像集150枚のサムネイル画像
    2019年10月22日の即位礼正殿の日に集めたやっつけクソ画像集150枚
    日0 月3.83k 年16.39k
    110
    14

    52はクソだな35件

    【200枚】今保存した最高の画像を転載する記事【重い】のサムネイル画像
    【200枚】今保存した最高の画像を転載する記事【重い】
    日0 月1.13k 年4.86k
    29
    14

    ee3件

    【えろ同人誌】ピトーにスケベするゴレイヌとゴンさん【ハンターハンター】のサムネイル画像
    【えろ同人誌】ピトーにスケベするゴレイヌとゴンさん【ハンターハンター】
    日539 月7.88k 年64.41k
    3681
    1463

    ee38件

    【えろどうじんし】蛍光フィルタ【らんち】のサムネイル画像
    【えろどうじんし】蛍光フィルタ【らんち】
    日1.11k 月11.18k 年126.36k
    946
    256

    ee18件

    いつか保存しようと企んでいた108枚の貴重な画像集のサムネイル画像
    いつか保存しようと企んでいた108枚の貴重な画像集
    日0 月798 年5.64k
    65
    15

    ee43件

    世界一の美少女ロシア人(8さい)wwwwwwwwのサムネイル画像
    世界一の美少女ロシア人(8さい)wwwwwwww
    日329 月3.93k 年28.2k
    28
    21

    ee2件

    【画像】ナルトとヒナタの子供が公開される あたいたちはサスナルを絶対にあきらめないのサムネイル画像
    【画像】ナルトとヒナタの子供が公開される あたいたちはサスナルを絶対にあきらめない
    日0 月448 年3.1k
    10
    4

    ee2件

    おま○んこ「男は電車のエロ広告が男体エロばっかりだったらどう思うの?」のサムネイル画像
    おま○んこ「男は電車のエロ広告が男体エロばっかりだったらどう思うの?」
    日0 月343 年1.93k
    15
    9

    ee3件

    通学中のバス内で毛の生えてないJSとDSが性交を始めてしまうのサムネイル画像
    通学中のバス内で毛の生えてないJSとDSが性交を始めてしまう
    日1.18k 月12.12k 年144.52k
    356
    97

    ee18件

    ドイツ人「小学校の性教育で避妊具の付け方を実践するけど皆真剣で茶化したり笑ったりしない。日本の生徒はなぜ笑うんだい?」のサムネイル画像
    ドイツ人「小学校の性教育で避妊具の付け方を実践するけど皆真剣で茶化したり笑ったりしない。日本の生徒はなぜ笑うんだい?」
    日434 月2.79k 年18.66k
    69
    15

    ee12件

    広告