質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

2600閲覧

Uncaught Error: Call to undefined function idn_to_utf8()

ByronHasegawa

総合スコア255

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

1グッド

0クリップ

投稿2017/07/12 06:30

編集2017/09/05 08:35

###問題
下記のソースでエラーがでる

<?php echo idn_to_utf8('xn--tst-qla.de'); ?>

エラー内容
Uncaught Error: Call to undefined function idn_to_utf8()

###やってみたこと
いろいろとphpの拡張モジュールをインストールしました。

yum install php-intl yum --enablerepo=remi install php-intl yum --enablerepo=remi,remi-php56 install php-intl

phpのバージョンは5.6.31で、nginxで動いています。

###nginx設定ファイル

user httpd www; worker_processes auto; worker_rlimit_nofile 20000; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 4096; multi_accept on; use epoll; } http { server_tokens off; include /etc/nginx/mime.types; default_type application/octet-stream; charset UTF-8; server_names_hash_bucket_size 128; log_format main '$request_time $sent_http_x_f_cache $sent_http_x_b_cache ' '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; client_max_body_size 20M; client_body_buffer_size 768k; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 5; connection_pool_size 1024; request_pool_size 8k; gzip on; gzip_http_version 1.0; gzip_disable "msie6"; gzip_proxied any; gzip_min_length 1024; gzip_comp_level 2; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json; brotli on; brotli_static on; brotli_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json; brotli_comp_level 3; brotli_min_length 1024; open_file_cache max=100000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; fastcgi_cache_path /var/cache/nginx/wordpress levels=1:2 keys_zone=wpcache:30m max_size=512M inactive=600m; fastcgi_ignore_headers "Vary" "Cache-Control" "Expires"; include /etc/nginx/conf.d/*.conf; }

###*.confのファイル

#======================================= # xn--testtesttest.com SSL #--------------------------------------- server { listen 443 ssl http2; server_name xn--testtesttest.com www.xn--testtesttest.com; ssl_certificate /etc/letsencrypt/live/xn--testtesttest.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/xn--testtesttest.com/privkey.pem; ssl_dhparam /etc/kusanagi.d/ssl/dhparam.key; ssl_session_tickets on; ssl_session_ticket_key /etc/kusanagi.d/ssl_sess_ticket.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #ssl_ct on; #ssl_ct_static_scts /etc/pki/tls/certs/scts; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ## OCSP stapling #ssl_stapling on; #ssl_stapling_verify on; #resolver 8.8.4.4 8.8.8.8 valid=300s; #resolver_timeout 10s; access_log /home/kusanagi/testtesttest/log/nginx/ssl_access.log main; error_log /home/kusanagi/testtesttest/log/nginx/ssl_error.log warn; charset UTF-8; client_max_body_size 16M; root /home/kusanagi/testtesttest/DocumentRoot; index index.php index.html index.htm; rewrite /wp-admin$ $scheme://$host$uri/ permanent; location / { try_files $uri $uri/ /index.php?$args; } location = /favicon.ico { log_not_found off; access_log off; } location ~* /.well-known { allow all; } location ~* /. { deny all; } location ~* /(?:uploads|files)/.*.php$ { deny all; } #include templates.d/multisite.conf; location ~* .(jpg|jpeg|gif|png|css|js|swf|ico|pdf|svg|eot|ttf|woff)$ { access_log off; } location ~* /wp-login.php|/wp-admin/((?!admin-ajax.php).)*$ { satisfy any; allow 153.168.29.119; allow 127.0.0.1; deny all; auth_basic "basic authentication"; auth_basic_user_file "/home/kusanagi/.htpasswd"; location ~ [^/].php(/|$) { fastcgi_split_path_info ^(.+?.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffers 256 128k; fastcgi_buffer_size 128k; fastcgi_intercept_errors on; fastcgi_read_timeout 120s; } } location ~ [^/].php(/|$) { fastcgi_split_path_info ^(.+?.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffers 256 128k; fastcgi_buffer_size 128k; fastcgi_intercept_errors on; fastcgi_read_timeout 120s; #add_header Strict-Transport-Security "max-age=31536000"; set $do_not_cache 0; ## page cache set $device "pc"; if ($request_method = POST) { set $do_not_cache 1; } if ($query_string != "") { set $do_not_cache 1; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $do_not_cache 1; } if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $do_not_cache 1; } if ($http_user_agent ~* " Android |(iPad|Android; Tablet; .+Firefox") { set $device "tablet"; } if ($http_user_agent ~* " Android .+ Mobile |(iPhone|(iPod|IEMobile|Android; Mobile; .+Firefox|Windows Phone") { set $device "smart"; } fastcgi_cache wpcache; fastcgi_cache_key "$device:$request_method:$scheme://$host$request_uri"; fastcgi_cache_valid 200 10m; fastcgi_no_cache $do_not_cache; fastcgi_cache_bypass $do_not_cache; add_header X-F-Cache $upstream_cache_status; add_header X-Signature KUSANAGI; } location ~ /fcache-purge/([^/]+)(/.*) { allow 127.0.0.1; deny all; fastcgi_cache_purge wpcache "$1:GET:$scheme://$host$2"; } }
KiyoshiMotoki👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

bash

1$ rpm -qa|grep ^php

の結果を教えてください。なんとなく、複数の php バージョンが混在している気がします。
念のため手元で試してみたら、ちゃんと動いているように見えます。

bash

1$ sudo yum install php71w-intl php71w-cli 2$ rpm -qa|grep ^php 3php71w-common-7.1.6-1.w7.x86_64 4php71w-intl-7.1.6-1.w7.x86_64 5php71w-cli-7.1.6-1.w7.x86_64 6$ cat idn_test.php 7<?php 8echo idn_to_utf8('xn--tst-qla.de').PHP_EOL; 9$ php idn_test.php 10täst.de

投稿2017/07/12 06:58

hotta

総合スコア1613

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ByronHasegawa

2017/07/12 08:32 編集

結果は下記の通りです。 php-pecl-jsonc-1.3.10-1.el7.remi.5.6.x86_64 php-xml-5.6.31-1.el7.remi.x86_64 php-mcrypt-5.6.31-1.el7.remi.x86_64 php-pecl-apcu-4.0.11-2.el7.remi.5.6.x86_64 php-pecl-jsonc-devel-1.3.10-1.el7.remi.5.6.x86_64 php-xmlrpc-5.6.31-1.el7.remi.x86_64 php-opcache-5.6.31-1.el7.remi.x86_64 php-common-5.6.31-1.el7.remi.x86_64 php-mysqlnd-5.6.31-1.el7.remi.x86_64 php-intl-5.6.31-1.el7.remi.x86_64 php-gd-5.6.31-1.el7.remi.x86_64 php-pear-1.10.1-7.el7.remi.noarch php-pdo-5.6.31-1.el7.remi.x86_64 php-devel-5.6.31-1.el7.remi.x86_64 php-mbstring-5.6.31-1.el7.remi.x86_64 php-5.6.31-1.el7.remi.x86_64 php-process-5.6.31-1.el7.remi.x86_64 php-pecl-zip-1.13.5-1.el7.remi.5.6.x86_64 php-cli-5.6.31-1.el7.remi.x86_64 php-fpm-5.6.31-1.el7.remi.x86_64
hotta

2017/07/12 13:58

RPM パッケージに関しては、混ざっている感じはないですね。。 (nginx から呼ばれているバイナリが野良ビルド等でない限り) 私がやったように、コマンドラインからやっても Undefined function になりますか?
ByronHasegawa

2017/07/13 04:17

ありがとうございます。 やってみたところ、エラーになりませんでした! しかし、これを実際のサイト(Wordpress)で使うとエラーが表示されてしまいます。。。
hotta

2017/07/13 06:15

php-intl-5.6.31-1.el7.remi.x86_64 を導入した後、nginx の再起動が必要です。 あとは、phpinfo() を表示するコンテンツを Web 経由で表示してみて、 php-intl が有効になっているかどうかチェックするくらいでしょうか。
hotta

2017/09/05 08:06

↑そのサイトのやり方だと『混ぜるな危険』状態になって、状況が悪化します。 $ rpm -ql php-intl | grep -E '(ini|so)$' の結果を貼ってください。
ByronHasegawa

2017/09/05 08:08

そうなんですね。。。 こちらです。 ------------------------------------- /etc/php-zts.d/20-intl.ini /etc/php.d/20-intl.ini /usr/lib64/php-zts/modules/intl.so /usr/lib64/php/modules/intl.so -------------------------------------
hotta

2017/09/05 08:10 編集

問題なく導入されています。次は、php -m | grep intl の結果を教えてください。
ByronHasegawa

2017/09/05 08:11

こちらです。 ----------------------- intl -----------------------
hotta

2017/09/05 08:12

OK です。 CLI からはうまく呼び出せているので、あとは Web サーバとの連携です。 nginx の設定ファイルを貼ってください。 コメント欄は文字修飾ができないので、質問欄に追記してください。
ByronHasegawa

2017/09/05 08:21

追加しました。 よろしくお願いします。
hotta

2017/09/05 08:26

php と連携している部分がないですね。 /etc/nginx/conf.d/*.conf を見せてください。
hotta

2017/09/05 12:40

127.0.0.1:9000 で php-fpm が listen していて、nginx がそこに接続に行っているようです。 $ sudo netstat -tlnp | grep 127.0.0.1 で 127.0.0.1:9000 が LISTEN になっていることを確認してください。 また、 php-intl を入れた後で serivce php-fpm restart またはリブートはやってみましたか?
ByronHasegawa

2017/09/06 01:31

$ sudo netstat -tlnp | grep 127.0.0.1 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2312/master tcp 0 0 127.0.0.1:2812 0.0.0.0:* LISTEN 932/monit tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14069/php-fpm: pool $ service php-fpm restart Redirecting to /bin/systemctl restart php-fpm.service Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details. という結果でした。
ByronHasegawa

2017/09/06 01:33

追記ですが、 # systemctl status php-fpm.service ● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 水 2017-09-06 10:31:13 JST; 55s ago Process: 15641 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78) Main PID: 15641 (code=exited, status=78) 9月 06 10:31:13 test-web01 php-fpm[15641]: [06-Sep-2017 10:31:13] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98) 9月 06 10:31:13 test-web01 php-fpm[15641]: [06-Sep-2017 10:31:13] ERROR: FPM initialization failed
hotta

2017/09/06 01:37

php-fpm の起動に失敗しています。 systemctl stop php-fpm してから netstat -tlnp | grep 127.0.0.1 してみて、 127.0.0.1:9000 を誰も LISTEN していないことを確認します。その後、 systemctl start php-fpm してみてください。
ByronHasegawa

2017/09/06 01:54 編集

# systemctl stop php-fpm # netstat -tlnp | grep 127.0.0.1 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2312/master tcp 0 0 127.0.0.1:2812 0.0.0.0:* LISTEN 932/monit tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14161/php-fpm: pool # systemctl start php-fpm ● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since 水 2017-09-06 10:52:56 JST; 7s ago Process: 16007 ExecStart=/usr/sbin/php-fpm --nodaemonize (code=exited, status=78) Main PID: 16007 (code=exited, status=78) 9月 06 10:52:56 test-web01 php-fpm[16007]: [06-Sep-2017 10:52:56] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98) 9月 06 10:52:56 test-web01 php-fpm[16007]: [06-Sep-2017 10:52:56] ERROR: FPM initialization failed 同じ結果になります。 STOPをしても、誰もLISTENの状態にはならないです。
hotta

2017/09/06 02:01

出力をよく見てください。 # systemctl stop php-fpm # netstat -tlnp | grep 127.0.0.1 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2312/master tcp 0 0 127.0.0.1:2812 0.0.0.0:* LISTEN 932/monit tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14161/php-fpm: pool ↑ここで、php-fpm を止めているのに 127.0.0.1:9000 を LISTEN している奴がいます。この pid=14161 が悪さをしているようです。 パッケージ以外で php-fpm をインストールしたり、手動で php-fpm を上げたりしていませんか?よくわからなければ、 # systemctl stop php-fpm した後、 kill 14161 します。その後、再び netstat -tlnp | grep 127.0.0.1 して、127.0.0.1:9000 が LISTEN 「されていない」ことを確認します。 その後、再度 systemctl start php-fpm して、 netstat -tlnp | grep 127.0.0.1 で、再度 LISTEN されるようになったこと、およびその pid が異なることを確認してください。
ByronHasegawa

2017/09/06 02:41

無事に表示できました! とても助かりました。 ご丁寧にありがとうございます。
hotta

2017/09/06 02:43

よかったです。 元の悪さをするヤツが自動起動になっていたら同じことになるので、いったんリブートしてから再確認した方がよいと思います。
ByronHasegawa

2017/10/18 06:37

これをやることにより、PHPのバージョンが[PHP 5.6]になってしまいました。 PHP7でブラウザにidn_to_utf8を対応させることはできますか?
hotta

2017/10/18 12:59

PHP7 以前に、OS がからむのでなんとも言えません。 私はいつもこの手順に従っています。これで CentOS-7.x + PHP-7.1x になります。 https://github.com/hotta/ansible-centos7 もし完全に一から環境を作り直すのであれば、試してみてもよいかも。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問