Ubuntu 24.04
エラー (CakePHP 2)
- php7ではクラス名に
String
という class名が使えなくなった。 - php7ではクラス名に
Object
という class名が使えなくなった。
対応
php5.6を使うことにする。
add-apt-repository ppa:ondrej/php
apt update
apt install -y php5.6 php5.6-pgsql php5.6-mbstring php5.6-xml
a2enmod php5.6
systemctl restart apache2
postgresqlのインストール例
# インストール
apt install -y postgresql-16
/var/lib/postgresql/16/main/
が作成される。
# 接続
sudo -u postgres bash
# dbuser1というアカウントを作成し、パスワードをpass1にする
createuser -d -r -s user1
psql
ALTER USER dbuser1 with encrypted password 'pass1';
# cakedb1を作成
create database cakedb1;
# database一覧を表示
\l
CakePHP2の設定修正
- ./app/Config/database.php
の接続情報を修正。cakedb1とユーザー・パスワードをdbuser1:pass1にする。
apache2のmod_rewrite を有効にする
a2enmod rewrite
systemctl restart apache2
- /etc/apache2/mods-enabled/rewrite.load が生成されることを確認。
AllowOverride Allする
mod_rewrite を有効にするためにディレクトリに対してAllowOverride設定をする。
- /etc/apache2/sites-enabled/000-default.conf
<Directory "/var/www">
AllowOverride All
</Directory>
systemctl restart apache2
certbot
sudo apt install -y \
certbot python3-certbot-apache
sudo certbot --apache