タグ: PHP

  • メモ:さくらのレンタルサーバもPHP2Shell対応済みとのこと

    さくらのレンタルサーバも使っているので、そのPHPのバージョンの話。さくらインターネットがPHP2Shellの対応をさくっと実行してくれたので、影響なくできた。早い対応で助かった。

    【重要】PHPの脆弱性に関する当社の対応状況について
    https://www.sakura.ad.jp/corporate/information/announcements/2026/10/22/1968226117

    アップロード機能の制限とかは検討して制限したけれど、さっさと戻せてよかった。

  • UbuntuのPHP2Shell対策VerのPHP

    めも。Ubuntu 24.04で、php2shellが対応されているPHPのパッケージバージョン。(Ubuntuの他のVerのPHPも対応されてる。)

    Noble (24.04) php8.3 Fixed in 8.3.6-0ubuntu0.24.04.13

    https://ubuntu.com/blog/php2shell-vulnerability-fixes-available

  • FreeBSDのPKGのリポジトリを最新版リポジトリに変更する方法

    PHP2Shellの対応で、FreeBSDのPKGでPHPのバージョンを変更したのだが、PKGに最新のPHPのバージョンが追加されているはずなのに、pkg updateしても、更新できなかった。それで調べてみると、PKGのリポジトリがQuarterly(四半期安定版)になっており、最新のアップデートを受け取れるLatestになっていないことがわかった。これの対応として、pkgのリポジトリを切り替えたので、その方法のメモを残す。

    sudoコマンドを設定している場合は、sudoで。そうでない場合は、suして作業を行う。

    設定ファイルを置くディレクトリを作成する

    sudo mkdir -p /usr/local/etc/pkg/repos

    設定ファイルをコピーして、カスタムの設定ファイルを設定する。

    sudo sed -e 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf

    リポジトリ情報を更新して、パッケージを最新に更新する。-fのオプションは強制アップデート。

    sudo pkg update -f
    sudo pkg upgrade

    これで更新ができたかを確認する。

  • Ubuntu ServerのOSをアップグレードしたら、WordPressでエラー

    Ubuntu ServerのOSを、20.04から、22.04、24.04と同じ日にアップデートを実施した。実施のときにPHPのバージョンも変わったので、いろいろと対処した。Wordpressの表示もできるようになったのだが・・・管理画面にログインしようとしたら、下記のエラーが。

    エラー詳細
    ===============
    エラータイプ E_ERROR が /var/www/html/sitename/wp-content/themes/muum_tcd085/functions/theme-setup.php ファイルの 65 行目で発生しました。 エラーメッセージ: Uncaught Error: Call to undefined function simplexml_load_string() in /var/www/html/sitename/wp-content/themes/muum_tcd085/functions/theme-setup.php:65
    Stack trace:
    #0 /var/www/html/sitename/wp-content/themes/muum_tcd085/functions/update_notifier.php(15): get_tcd_update_notifier_xml()
    #1 /var/www/html/sitename/wp-includes/class-wp-hook.php(324): tcd_update_notifier_admin_menu()
    #2 /var/www/html/sitename/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #3 /var/www/html/sitename/wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 /var/www/html/sitename/wp-admin/includes/menu.php(161): do_action()
    #5 /var/www/html/sitename/wp-admin/menu.php(423): require_once('...')
    #6 /var/www/html/sitename/wp-admin/admin.php(159): require('...')
    #7 /var/www/html/sitename/wp-admin/index.php(10): require_once('...')
    #8 {main}
      thrown

    この65行目をみると、

     $xml = simplexml_load_string( $cache_data );

    なので、XML関連ということがわかった。

    php8.3の状況を調べてみると、「php8.3-xml」がインストールされていない。なので、

    sudo apt install php8.3-xml

    で、インストールを行って、再起動。これで管理画面に入れるようになった。

    あと、Wordpressのサイトヘルスから足りていない推奨モジュールを表示して、aptでインストールした。

  • Pukiwiki 1.5.4へのバージョンアップをした

    PHPのバージョン変更に伴って、Pukiwiki 1.5.2 から、Pukiwiki 1.5.4にアップデートを行ったのでメモ。

    Pukiwiki 1.5.2 からPukiwiki 1.5.4へは、いきなりバージョンアップはできなくて、Pukiwiki 1.5.3へのバージョンアップ用のパッチを実行して、一度、Pukiwiki 1.5.3にしてから、Pukiwiki 1.5.4のパッチを当てて、バージョンアップした。

    パッチを当てるだけなので、段階アップデートだけど、つらくはなかった。一番大変だったのは、先にPHPのバージョンを上げてしまって、使っていたPukiwikiが白くなってしまい、バージョンがわからなくなったこと。先にバージョンを調べておくか、パッチを当てておけばよかった。

  • Nginx上のPHPのページにアクセスすると「File not found.」と表示される

    NginxにPHPを動作させるための設定をいれたのだが、アクセスすると、「File not found.」と表示されて、PHPの処理がされない。Nginxのエラーログを見てみると、下記の表示があった。

    FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,

    Nginxの「/etc/nginx/sites-available/default」のPHPに関連する設定は、下記のように設定していた。

         # pass PHP scripts to FastCGI server 
            # 
            location ~ \.php$ { 
                        include snippets/fastcgi-php.conf; 
            # 
            #       # With php-fpm (or other unix sockets): 
                    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; 
            #       # With php-cgi (or other tcp sockets): 
            #       fastcgi_pass 127.0.0.1:9000; 
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
            }

    上記を、次のように修正したところ、正常にPHPの処理が行われた。

         # pass PHP scripts to FastCGI server 
            # 
            location ~ \.php$ { 
                     root     /var/www/html; 
                     include snippets/fastcgi-php.conf; 
            # 
            #       # With php-fpm (or other unix sockets): 
                    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; 
            #       # With php-cgi (or other tcp sockets): 
            #       fastcgi_pass 127.0.0.1:9000; 
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                    include fastcgi_params; 
            }

    そもそものエラーが、ファイルの場所がわからないということなので、「root  path」でドキュメントルートを指定したことにより、正常に処理ができるようになった。Nginxの設定は、何回やっても難解でどこからしらで躓く。

  • WordPressのテンプレートのバージョンをあげたら、エラーになった

    WordPressで、独自インストールしていたテンプレートのバージョンをあげたところ、下記のエラーになった。

    Warning: file_exists(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /*********/wp-content/themes/simplicity2/functions.php on line 214
    

    PHPにOpenSSLのモジュールが入っていなかったのが原因。なので、インストールして、解消した。

    pkg search php73 | grep openssl
    pkg install php73-openssl-7.3.27
    apachectl restart
    
  • WordPress5.6にしたら、投稿画面がエラーになった

    WordPress 5.6にアップデートしたら、投稿画面の表示でエラーになった。ブラウザの画面には、エラーになったことしか表示されないので、詳しいエラー内容をコピーして確認した。

    確認したところ、Javascriptばかりがエラーになっていた。なので、ブラウザのキャッシュに残っているものが悪さをしている。ブラウザのキャッシュを削除して、再度Wordpressの管理画面にアクセスしたところ、正常に投稿画面が使えるようになった。このアップデート後の問題は、忘れたことに発生するので、少しびっくりする。

    エラー内容は下記。

    TypeError: Object(...) is not a function
        at WithSpokenMessages(WithInstanceId(WithFilters(n))) (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/components.min.js:7:280912)
        at we (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:84:293)
        at zj (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:226:496)
        at Th (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:152:223)
        at tj (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:152:152)
        at Te (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:146:151)
        at https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:61:68
        at unstable_runWithPriority (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react.min.js:26:340)
        at Da (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:60:280)
        at Pg (https://www.xenos.jp/xxxxxxx/wp-includes/js/dist/vendor/react-dom.min.js:61:14)
  • Magento 2.3.5で初期セットアップに繰り返したら、LogicExceptionエラーになった

    Magento 2.3.5で、ウェブ上から初期セットアップを行って、インストールの部分で躓く。いろいろと対処をしていく中で、何回も行っていたのだが、突然、成功していたインストールの部分(というか最初)で、エラーが出るようになってしまった。

    Unknown module in the requested list: 'Magento_CatalogRuleSampleData'
    [ERROR] exception 'LogicException' with message 'Unknown module in the requested list: 'Magento_BundleSampleData'' in setup\src\Magento\Setup\Model\Installer.php:403
    Stack trace:

    原因は、ブラウザのキャッシュだった。キャッシュをクリアしたところ、正常な動作(というか、もともとの別の場所で躓く)に戻った。なかなか、Magento2のインストールは大変。

  • Magento2.3.5のインストール後に管理ページが404エラーになる

    Ubuntuに、Magento 2.3.5をインストールした後に、管理ページにアクセスしたところ、ページが404エラーになった。他にも、いくつかのページが404エラーになった。

    原因は、Apacheのmod_rewriteの設定がMagentoのディレクトリで有効になっていないからだった。

    Apacheには、mod_rewriteを入れているし、読み込ませてもいるが、肝心のMagentoのディレクトリで使うように設定されていなかったのが原因。

    • .htaccess がMagentoのフォルダになかった
    • apache.confで、.htaccessによる設定の上書きができないようになっていた

    対処としては、後述の参考ページの設定をいれただけだ。

    まずMagentoのインストールディレクトリに下記の .htaccessを保存する。

    ###############################################
    ## overrides deployment configuration mode value
    ## use command bin/magento deploy:mode:set to switch modes
    #   SetEnv MAGE_MODE developer
    ############################################
    ## uncomment these lines for CGI mode
    ## make sure to specify the correct cgi php binary file name
    ## it might be /cgi-bin/php-cgi
    #    Action php5-cgi /cgi-bin/php5-cgi
    #    AddHandler php5-cgi .php
    ############################################
    ## GoDaddy specific options
    #   Options -MultiViews
    ## you might also need to add this line to php.ini
    ##     cgi.fix_pathinfo = 1
    ## if it still doesn't work, rename php.ini to php5.ini
    ############################################
    ## this line is specific for 1and1 hosting
        #AddType x-mapp-php5 .php
        #AddHandler x-mapp-php5 .php
    ############################################
    ## default index file
        DirectoryIndex index.php
    <IfModule mod_php5.c>
    ############################################
    ## adjust memory limit
        php_value memory_limit 768M
        php_value max_execution_time 18000
    ############################################
    ## disable automatic session start
    ## before autoload was initialized
        php_flag session.auto_start off
    ############################################
    ## enable resulting html compression
        #php_flag zlib.output_compression on
    ###########################################
    ## disable user agent verification to not break multiple image upload
        php_flag suhosin.session.cryptua off
    </IfModule>
    <IfModule mod_php7.c>
    ############################################
    ## adjust memory limit
        php_value memory_limit 768M
        php_value max_execution_time 18000
    ############################################
    ## disable automatic session start
    ## before autoload was initialized
        php_flag session.auto_start off
    ############################################
    ## enable resulting html compression
        #php_flag zlib.output_compression on
    ###########################################
    ## disable user agent verification to not break multiple image upload
        php_flag suhosin.session.cryptua off
    </IfModule>
    <IfModule mod_security.c>
    ###########################################
    ## disable POST processing to not break multiple image upload
        SecFilterEngine Off
        SecFilterScanPOST Off
    </IfModule>
    <IfModule mod_deflate.c>
    ############################################
    ## enable apache served files compression
    ## http://developer.yahoo.com/performance/rules.html#gzip
        # Insert filter on all content
        ###SetOutputFilter DEFLATE
        # Insert filter on selected content types only
        #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
        # Netscape 4.x has some problems...
        #BrowserMatch ^Mozilla/4 gzip-only-text/html
        # Netscape 4.06-4.08 have some more problems
        #BrowserMatch ^Mozilla/4\.0[678] no-gzip
        # MSIE masquerades as Netscape, but it is fine
        #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        # Don't compress images
        #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
        # Make sure proxies don't deliver the wrong content
        #Header append Vary User-Agent env=!dont-vary
    </IfModule>
    <IfModule mod_ssl.c>
    ############################################
    ## make HTTPS env vars available for CGI mode
        SSLOptions StdEnvVars
    </IfModule>
    ############################################
    ## workaround for Apache 2.4.6 CentOS build when working via ProxyPassMatch with HHVM (or any other)
    ## Please, set it on virtual host configuration level
    ##    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    ############################################
    <IfModule mod_rewrite.c>
    ############################################
    ## enable rewrites
        Options +FollowSymLinks
        RewriteEngine on
    ############################################
    ## you can put here your magento root folder
    ## path relative to web root
        #RewriteBase /magento/
    ############################################
    ## workaround for HTTP authorization
    ## in CGI environment
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    ############################################
    ## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
        RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
        RewriteRule .* - [L,R=405]
    ############################################
    ## redirect for mobile user agents
        #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
        #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
        #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
    ############################################
    ## never rewrite for existing files, directories and links
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-l
    ############################################
    ## rewrite everything else to index.php
        RewriteRule .* index.php [L]
    </IfModule>
    ############################################
    ## Prevent character encoding issues from server overrides
    ## If you still have problems, use the second line instead
        AddDefaultCharset Off
        #AddDefaultCharset UTF-8
    <IfModule mod_expires.c>
    ############################################
    ## Add default Expires header
    ## http://developer.yahoo.com/performance/rules.html#expires
        ExpiresDefault "access plus 1 year"
        ExpiresByType text/html A0
        ExpiresByType text/plain A0
    </IfModule>
    ###########################################
    ## Deny access to root files to hide sensitive application information
        RedirectMatch 404 /\.git
        <Files composer.json>
            order allow,deny
            deny from all
        </Files>
        <Files composer.lock>
            order allow,deny
            deny from all
        </Files>
        <Files .gitignore>
            order allow,deny
            deny from all
        </Files>
        <Files .htaccess>
            order allow,deny
            deny from all
        </Files>
        <Files .htaccess.sample>
            order allow,deny
            deny from all
        </Files>
        <Files .php_cs>
            order allow,deny
            deny from all
        </Files>
        <Files .travis.yml>
            order allow,deny
            deny from all
        </Files>
        <Files CHANGELOG.md>
            order allow,deny
            deny from all
        </Files>
        <Files CONTRIBUTING.md>
            order allow,deny
            deny from all
        </Files>
        <Files CONTRIBUTOR_LICENSE_AGREEMENT.html>
            order allow,deny
            deny from all
        </Files>
        <Files COPYING.txt>
            order allow,deny
            deny from all
        </Files>
        <Files Gruntfile.js>
            order allow,deny
            deny from all
        </Files>
        <Files LICENSE.txt>
            order allow,deny
            deny from all
        </Files>
        <Files LICENSE_AFL.txt>
            order allow,deny
            deny from all
        </Files>
        <Files nginx.conf.sample>
            order allow,deny
            deny from all
        </Files>
        <Files package.json>
            order allow,deny
            deny from all
        </Files>
        <Files php.ini.sample>
            order allow,deny
            deny from all
        </Files>
        <Files README.md>
            order allow,deny
            deny from all
        </Files>
    ################################
    ## If running in cluster environment, uncomment this
    ## http://developer.yahoo.com/performance/rules.html#etags
        #FileETag none
    ############################################
    ## Add custom headers
    <IfModule mod_headers.c>
        Header set X-Content-Type-Options "nosniff"
        Header set X-XSS-Protection "1; mode=block"
    </IfModule>

    次に、/etc/apache/の中のconfファイル(vhosts.confやapache.confなどから適切なものを書き換え)に下記を追加する。ディレクトリは、Magentoをインストールしたディレクトリに変える。

    <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                allow from all
     </Directory>

    最後に、Apacheの再起動を行う。

    参考: https://qastack.jp/magento/89125/how-to-fix-magento-2-2-0-0-rc-admin-page-not-found-after-installation