公式サイトに Linux のインストレーションガイドが見当たらない。
ユーザーズサイトに記載があるのかもしれませんが、探す気ゼロ。
とりあえず構築手順を備忘録として残します。
権限設定が面倒なのでとりあえず全部 root で実行しています。
(参考サイト)
NetCommons3 (Github版)導入〜インストールまでの手順 - Qiita
構築環境
注意点)メモリが 2GB 以上ないと composer update
で詰まる。
swap 確保で回避可能だが、正常に動作するか怪しいため確保しておく方がいいかも。
root に切り替える
sudo su -
SELinux を無効化
- コマンドで無効化
setenforce 0
- 再起動時に復活しないよう設定で無効化
[/etc/selinux/config] ファイルを編集
SELINUX=disabled
PHP 7.4 と拡張モジュールのインストール
- yum のアップデート
yum -y update
- epel-release と remi のインストール
remi から取得するために先に epel-release をインストール
yum install -y epel-release.noarch yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
- 必要なモジュール をインストール
dnf -y install dnf-utils make
dnf -y module install php:remi-7.4 dnf -y install --enablerepo=remi php-devel php-mysql php-gd php-pear php-mcrypt
- まず ImageMagic をインストールし、PECL で imagick をインストールする。
dnf config-manager --set-enabled PowerTools dnf -y install ImageMagick ImageMagick-devel pecl install imagick > Please provide the prefix of ImageMagick installation [autodetect] : [enter]
php の設定
- php.ini の編集
[/etc/php.ini]
extension=imagick.so
Apache、MySQL、bower のインストール
dnf -y install httpd dnf -y install @mysql dnf -y install tar wget nodejs npm git npm install -g bower > npm WARN deprecated bower@1.8.8:
MySQLのセットアップ
- MySQL のセットアップ
systemctl start mysqld sudo mysql_secure_installation
- MySQL インストレーションのサンプル
Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Please set the password for root here. New password: (set password) Re-enter new password: (confirm password) Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done!
composer の準備
- composer を wget でダウンロードし、インストール&準備
wget https://getcomposer.org/installer php ./installer sudo mv composer.phar /usr/local/bin cd /usr/local/bin sudo ln -s composer.phar composer
NetCommons3 を github からダウンロード、composer のアップデートを実行
cd /var/www/ git clone https://github.com/NetCommons3/NetCommons3 composer update
NetCommons3 のセットアップに必要なファイルを用意
cd /var/www/NetCommons3 touch app/Config/database.php touch app/Config/application.yml chmod -R 666 app/Config/database.php chmod -R 666 app/Config/application.yml chmod -R 777 app/webroot/files chmod -R 777 app/tmp
NetCommons3 のファイルを /ver/www/html 配下に移動
mv /var/www/NetCommons3/* /var/www/html/ cd /var/www/html chown -R apache:apache ./*
apache の設定
- httpd.conf の編集
[httpd.conf]
#ServerName www.example.com:80 ServerName servername.westus2.cloudapp.azure.com:80 ~(中略)~ <Directory "/var/www/html"> AllowOverride All Options FollowSymLinks Require all granted </Directory>
- ルートディレクトリ配下で実行するために .htaccess の作成
(参考)
https://github.com/NetCommons3/NetCommons3/wiki/Let's-Encrypt%E5%AF%BE%E5%BF%9C
[/var/www/html/.htaccess]
<IfModule mod_rewrite.c> RewriteEngine on # /.well-known/ is Let's Encrypt # Let's Encrypt need http(80) and DocumentRoot/.well-known/ RewriteCond %{REQUEST_URI} !(^/.well-known/) RewriteRule ^$ app/webroot/ [L] RewriteCond %{REQUEST_URI} !(^/.well-known/) RewriteRule (.*) app/webroot/$1 [L] </IfModule>
サービスの起動
systemctl start mysqld.service systemctl enable mysqld.service systemctl start httpd.service systemctl enable httpd.service
Azure Virtual Machine の場合は Azure CLI でポートを開ける
az vm open-port --resource-group myResourceGroup --name myVM --port 80