久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='OF778'><style id='OF778'><dir id='OF778'><q id='OF778'></q></dir></style></legend><tfoot id='OF778'></tfoot>

      • <bdo id='OF778'></bdo><ul id='OF778'></ul>

      <small id='OF778'></small><noframes id='OF778'>

    1. <i id='OF778'><tr id='OF778'><dt id='OF778'><q id='OF778'><span id='OF778'><b id='OF778'><form id='OF778'><ins id='OF778'></ins><ul id='OF778'></ul><sub id='OF778'></sub></form><legend id='OF778'></legend><bdo id='OF778'><pre id='OF778'><center id='OF778'></center></pre></bdo></b><th id='OF778'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OF778'><tfoot id='OF778'></tfoot><dl id='OF778'><fieldset id='OF778'></fieldset></dl></div>

      PDO 連接從命令行工作,而不是通過 Apache?

      PDO connection works from command line, but not through Apache?(PDO 連接從命令行工作,而不是通過 Apache?)
    2. <small id='TQ4FZ'></small><noframes id='TQ4FZ'>

    3. <legend id='TQ4FZ'><style id='TQ4FZ'><dir id='TQ4FZ'><q id='TQ4FZ'></q></dir></style></legend>

        • <i id='TQ4FZ'><tr id='TQ4FZ'><dt id='TQ4FZ'><q id='TQ4FZ'><span id='TQ4FZ'><b id='TQ4FZ'><form id='TQ4FZ'><ins id='TQ4FZ'></ins><ul id='TQ4FZ'></ul><sub id='TQ4FZ'></sub></form><legend id='TQ4FZ'></legend><bdo id='TQ4FZ'><pre id='TQ4FZ'><center id='TQ4FZ'></center></pre></bdo></b><th id='TQ4FZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TQ4FZ'><tfoot id='TQ4FZ'></tfoot><dl id='TQ4FZ'><fieldset id='TQ4FZ'></fieldset></dl></div>
          <tfoot id='TQ4FZ'></tfoot>

              <bdo id='TQ4FZ'></bdo><ul id='TQ4FZ'></ul>
                <tbody id='TQ4FZ'></tbody>

                本文介紹了PDO 連接從命令行工作,而不是通過 Apache?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有一個非常簡單的測試腳本:

                I have a very simple test script:

                <?php
                
                $DSN = "mysql:host=db.example.edu;port=3306;dbname=search_data";
                
                try {
                
                    $DB = new PDO($DSN, "username", "super-secret-password!");
                
                } catch (PDOException $e) {
                
                    header('Content-Type: text/plain');
                    print "Could not connect to database, rawr. :-(";
                    exit;
                
                }
                
                
                $SQL = "SELECT phrase FROM search ORDER BY RAND() LIMIT 10";
                
                foreach($DB->query($SQL) as $row){
                
                    print $row['phrase']."
                ";
                
                }
                
                ?>
                

                當我從命令行執行此腳本時,它運行良好:

                When I execute this script from the command line, it works perfectly:

                $ php test.php
                corporal punishment
                Stretches
                voluntary agencies and the resettlement of refugees
                music and learning
                Nike Tiger Woods Scandal
                Hermeneia
                PSYCHINFO
                anthony bourdain
                Black-White Couples and their Social Worlds
                colonization, hodge
                

                但是當我通過網絡瀏覽器訪問完全相同的腳本時,它說:

                But when I access the exact same script through my web browser, it says:

                Could not connect to database, rawr. :-(
                

                我已經嘗試了 var_dump 解決錯誤,消息是:SQLSTATE[HY000] [2003] 無法連接到 MySQL 服務器上的 'db.example.edu' (13)".

                I've tried var_dump on the error, and the message is: "SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'db.example.edu' (13)".

                這令人費解.這是完全相同的服務器上的完全相同的腳本——為什么當我從命令行執行它時它可以工作,但當 Apache 執行它時卻失敗?

                This is puzzling. It's the exact same script on the exact same server -- why does it work when I execute it from the command line, but fail when Apache executes it?

                推薦答案

                如果這是運行 SELinux(或任何使用 SELinux 的任何非 Red Hat 衍生產品)的 Red Hat 衍生發行版(RHEL、CentOS、Fedora、ScientificLinux),則默認撰寫本文時的策略設置是禁止 Apache 與其他服務器或數據庫建立外部連接.作為 root,您必須啟用以下兩個 SELinux 布爾值.使用 -P 選項在重新啟動后保持更改.

                If this is a Red Hat-derived distribution (RHEL, CentOS, Fedora, ScientificLinux) running SELinux (or any non Red Hat derivative using SELinux), the default policy setting at time of this writing is to prohibit Apache from making external connections to other servers or databases. As root, you must enable the following two SELinux booleans. Use the -P option to persist the change across a reboot.

                setsebool -P httpd_can_network_connect=1
                setsebool -P httpd_can_network_connect_db=1
                

                請注意,httpd_can_network_connect 可能不是必需的.首先嘗試僅打開 httpd_can_network_connect_db.

                Note that httpd_can_network_connect may not be necessary. Try it first turning on only httpd_can_network_connect_db.

                這篇關于PDO 連接從命令行工作,而不是通過 Apache?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                  <bdo id='Cy7pV'></bdo><ul id='Cy7pV'></ul>

                    <small id='Cy7pV'></small><noframes id='Cy7pV'>

                    <tfoot id='Cy7pV'></tfoot><legend id='Cy7pV'><style id='Cy7pV'><dir id='Cy7pV'><q id='Cy7pV'></q></dir></style></legend>
                      <i id='Cy7pV'><tr id='Cy7pV'><dt id='Cy7pV'><q id='Cy7pV'><span id='Cy7pV'><b id='Cy7pV'><form id='Cy7pV'><ins id='Cy7pV'></ins><ul id='Cy7pV'></ul><sub id='Cy7pV'></sub></form><legend id='Cy7pV'></legend><bdo id='Cy7pV'><pre id='Cy7pV'><center id='Cy7pV'></center></pre></bdo></b><th id='Cy7pV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Cy7pV'><tfoot id='Cy7pV'></tfoot><dl id='Cy7pV'><fieldset id='Cy7pV'></fieldset></dl></div>

                        <tbody id='Cy7pV'></tbody>

                        1. 主站蜘蛛池模板: 日韩免费一区二区 | 综合另类| 黄色网址在线免费播放 | 男人的天堂在线视频 | 资源首页二三区 | 国产精品久久久久久一区二区三区 | 亚洲 中文 欧美 日韩 在线观看 | 国内久久 | 国产91久久久久蜜臀青青天草二 | 久久国产精品免费一区二区三区 | 国内精品久久久久久久 | 国产资源视频 | 精品中文字幕一区二区 | 久久久综合网 | 一级aaaaaa毛片免费同男同女 | 精品久久久久久久久久久久 | 在线91| 毛片免费看 | 欧美一区二区免费视频 | 久久久噜噜噜www成人网 | 97免费在线观看视频 | 欧美一区视频 | 国产一区二区三区www | 久久成人一区二区三区 | 中文字幕日韩欧美一区二区三区 | 理论片午午伦夜理片影院 | 超碰在线网站 | 91精品一区二区三区久久久久久 | 国产一区二区在线视频 | 91精品在线播放 | 亚洲国产小视频 | av日韩精品| 亚洲成人播放器 | 日韩精品四区 | 国产一区二区在线免费观看 | 午夜精品一区二区三区在线 | 日韩精品视频在线 | 欧美日韩在线一区二区 | 久久中文字幕电影 | 一区二区三区视频在线观看 | 久久美女网 |