0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu 26.04 LTSにてWordPressを構築する(備忘録)

0
Posted at

Ubuntu 26.04 LTSにて、WordPressを構築する際の備忘録です。

AWSの調整(必要な場合)

ロードバランサー

接続アイドルタイムアウトを180秒に変更する

Ubuntuの環境構築

ユーザー追加(キーでログインする)

sudo adduser new_user --disabled-password // Ubuntuの場合
sudo adduser new_user // Amazon Linuxの場合
sudo su - new_user
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
ssh new_user@localhost // パスワードを入力しないようになっているか確認
exit
sudo gpasswd -a new_user sudo // sudoを許可する場合(Amazon Linuxは不要)
sudo visudo

# 下記の文を書き換える
%sudo ALL=(ALL:ALL) ALL
# 書き換え後
%sudo ALL=(ALL:ALL) NOPASSWD:ALL

デフォルトユーザーの削除(必要な場合)

sudo userdel -r ubuntu

仮想メモリを作成する

# fallocateではなく、ddの方がいいらしい https://www7390uo.sakura.ne.jp/wordpress/archives/1349
sudo dd if=/dev/zero of=/swapfile bs=128K count=16384 status=progress
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo vim /etc/fstab

# どこでも良いので以下の1行を追加
~
/swapfile none swap sw 0 0
~

プログラムの更新

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

タイムゾーンをJSTに変更する

sudo timedatectl set-timezone Asia/Tokyo

//成功している場合、「timedatectl」を実行すると下記の内容が表示される
timedatectl
Local time: Thu 2019-01-10 17:37:44 JST
Universal time: Thu 2019-01-10 08:37:44 UTC
RTC time: Thu 2019-01-10 08:37:44
Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no

// タイムゾーンが変更できない場合
sudo apt-get install tzdata

nginxのインストール

PHPのインストール

sudo apt-get install php php-mysql

Apacheのアンインストール

dpkg -l | grep apache
sudo apt-get purge apache2 apache2-utils apache2-bin apache2-data
sudo apt-get autoremove
whereis apache2
apache2: /etc/apache2
sudo rm -rf /etc/apache2

nginxのインストール

sudo apt-get install nginx

nginxでIPアドレスでのアクセスを拒否する

参考

※直IPをドロップする
/etc/nginx/sites-avairable/default を編集する

変更前

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

変更後

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                return 444;
        }
        
        location = /healthcheck.html {
                empty_gif;
                access_log off;
                break;
        }

WordPressのインストール

必要なライブラリをインストールする

sudo apt-get install php-gd php-curl php-xml php-mbstring php-imagick php-zip

WordPressのインストールを進める

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?