はじめに
magento 2.4.2をインストールしましたが、上手く表示されませんでした。
詰まったところを記載致します。
最終更新日
2021年8月23日
環境の情報
OS
ubuntu 20.04
公式はこちら
https://devdocs.magento.com/
https://devdocs.magento.com/guides/v2.4/install-gde/tutorials/change-docroot-to-pub.html
変更点
If you appended a directory name to your server’s hostname or IP address to create the base URL when you installed Magento (for example http://192.168.33.10/magento2), you’ll need to remove it.
インストールする時に、フォルダ名を付けた場合には、DBのベースURLを更新する必要があるようです。
update core_config_data set value='http://192.168.33.XX' WHERE path='web/unsecure/base_url';
実際に行ってみます
vagrant@ubuntu2004:/var/www/html/magento$ mysql -u magento -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 186
Server version: 8.0.26-0ubuntu0.20.04.2 (Ubuntu)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
ユーザーを使い、mysqlにログインします。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| magento |
+--------------------+
5 rows in set (0.01 sec)
dbを確認します。
mysql> use magento
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
選ぶ。
mysql> select * from core_config_data;
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+---------------------+
| config_id | scope | scope_id | path | value | updated_at |
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+---------------------+
| 4 | default | 0 | web/unsecure/base_url | http://192.168.33.11/magento/ | 2021-08-20 06:16:28 |
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+---------------------+
20 rows in set (0.00 sec)
中身を見ます。
mysql> update core_config_data set value='http://192.168.33.11' WHERE path='web/unsecure/base_url';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
アップデート文を書きます。
mysql> select * from core_config_data;
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+---------------------+
| config_id | scope | scope_id | path | value | updated_at |
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+---------------------+
| 4 | default | 0 | web/unsecure/base_url | http://192.168.33.11 | 2021-08-20 06:30:09 |
+-----------+---------+----------+------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+---------------------+
20 rows in set (0.00 sec)
中身が変更されたのを確認します。
変更されれば問題ありません。
キャッシュを消したり、Apacheを起動し直してみてください。