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?

Ubuntu24.04でphp5.6を動かす (CakePHP 2)

Last updated at Posted at 2024-12-19

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