php代碼上傳到linux伺服器無法正常顯示

來源:互聯網
上載者:User

標籤:php   linux   

     近期接手了一個PHP開發的項目,一直想搞個LVS管理的工具,卻一直沒動力去做,這次就當是學習和為了以後工作的方便吧。開發過程中遇到這麼一個問題,情況如下:


情況:在windows下寫好的代碼,上傳在Linux伺服器上測試不成功,頁面無顯示。


解決辦法:開啟php的error_log,觀察錯誤記錄檔


1. 修改php-fpm.conf中配置 沒有則增加catch_workers_output = yes

error_log = log/error_log


2. 修改php.ini中配置,沒有則增加log_errors = Onerror_log = "/usr/local/lnmp/php/var/log/error.log"

error_reporting=E_ALL&~E_NOTICE


3. 重啟php-fpm

當PHP執行錯誤時就能看到錯誤記錄檔在"/usr/local/lnmp/php/var/log/error.log"中了


查看php 的error.log 報錯資訊如下:[12-May-2014 16:38:22] WARNING: [pool www] child 6961 said into stderr: "NOTICE: PHP message: PHP Fatal error: No such file or directory in /usr/local/nginx/html/connections/conn.php on line 6"

[12-May-2014 16:40:08] WARNING: [pool www] child 6962 said into stderr: "NOTICE: PHP message: PHP Warning: mysql_connect(): No such file or directory in /usr/local/nginx/html/test.php on line 2"


但實際上檔案是存在的,檔案的第二行內容如下:

$id=mysql_connect("localhost","root","123456")or die(mysql_error());


查看mysql.sock檔案的位置[email protected]:/var/mysql# vim /usr/local/mysql/my.cnf socket = /usr/local/mysql/data/mysql.sock[email protected]:~# cd /var/[email protected]:/var# mkdir mysql[email protected]:/var# chmod 755 mysql[email protected]:~# cd /var/mysql/[email protected]:/var/mysql# ln -s /usr/local/mysql/data/mysql.sock mysql.sock[email protected]:/var/mysql# cd /tmp/

[email protected]:/tmp# ln -s /usr/local/mysql/data/mysql.sock mysql.sock


顯示結果正常:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/27/6B/wKiom1Ny0Xmz1z2XAACzW-V_l2Y766.jpg" title="clipboard.png" alt="wKiom1Ny0Xmz1z2XAACzW-V_l2Y766.jpg" />


參考資料:

http://stackoverflow.com/questions/4219970/warning-mysql-connect-2002-no-such-file-or-directory-trying-to-connect-vi




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.