日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

树莓派 php mysql 中文_使用树莓派(raspberry pi)搭建网站(nginx+php+mysql+ddclient)

發布時間:2025/3/8 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 树莓派 php mysql 中文_使用树莓派(raspberry pi)搭建网站(nginx+php+mysql+ddclient) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

標簽: 樹莓派 raspberrypi php 網站 mysql分類: Linux技術

最近在研究學習PHP,有時候想隨時就學習,所以就決定搭建一個網站,隨時可以進行學習,因為要24小時在線,要低功耗和安靜,所以選擇了樹莓派!我們開始吧(nginx+php+mysql)

1.安裝網站系統

sudo apt-get install nginx php5-common php5-fpm php-apc php5-mysql php5-gd mysql-server

2、修改nginx配置文件

sudo vi /etc/nginx/sites-enabled/default

--------------------------------------------------------------------------------

把其中的:

代碼:

location / {

root ? /var/www;

index ?index.html index.htm;

}

改為:

代碼:

location / {

root ? /var/www/nginx-default;

index ?index.php index.html index.htm;

}

----------------------------------------------------------------------------------

其中的:

代碼:

#location ~ \.php$ {

# ? fastcgi_pass 127.0.0.1:9000;

# ? fastcgi_index index.php;

# ? include fastcgi_params;

#}

改為:

location ~ \.php$ {

# fastcgi_split_path_info ^(.+\.php)(/.+)$;

# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

#

# # With php5-cgi alone:

# fastcgi_pass 127.0.0.1:9000;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_param ?SCRIPT_FILENAME ?/usr/share/nginx/www/nginx-default$fastcgi_script_name;

# # With php5-fpm:

# fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

include fastcgi_params;

}

3.測試

sudo vi /var/www/nginx-default/index.php

phpinfo();

?>

http://IP/index.php

4.由于我們用的是樹莓派,所以要優化一下部分的性能

對mysql的調優,打開配置文件/etc/mysql/my.cnf修改以下幾處。

[mysqld]

key_buffer = 16k

max_allowed_packet = 1M

thread_stack = 64K

thread_cache_size = 4

query_cache_limit = 1M

default-storage-engine = InnoDB

優化php.ini,php-fpm,打開配置文件/etc/php5/fpm/php.ini和/etc/php5/fpm/php-fpm.conf修改以下幾處。

memory_limit=16M

process.max=4

5. 為了方便調試PHP代碼,打開PHP的調試

(可能不同的平臺文件的位置是不同的)

vim /usr/local/php5/lib/php.ini

找到

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Error handling and logging ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

部分。開始配置

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Error handling and logging ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

error_reporting = E_ALL

display_errors = On

display_startup_errors = Off

log_errors = On

log_errors_max_len = 1024

ignore_repeated_errors = Off

report_memleaks = On

track_errors = On

error_log = /var/log/php_errors.log

保存退出。

/etc/init.d/apache restart

查看日志:

tail -f /var/log/php_errors.log

6.使用ddclient進行域名的映射

我是在https://www.dnsdynamic.org/這個注冊的一個賬號,獲得是DDNS

使用命令 sudo apt-get install ddclient,中間要設置很多東西,按照提示設置(也可以隨便設置,等會用我的配置)

=============================================================================

修改配置文件

pi@raspberrypi ~ $ sudo cat /etc/ddclient.conf

daemon=30 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# check every 60 seconds

syslog=yes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# log update msgs to syslog

mail=root ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # mail all msgs to root

mail-failure=root ? ? ? ? ? ? ? ? ? ? ? # mail failed update msgs to root

pid=/var/run/ddclient.pid ? ? ? ? ? ? ? # record PID in file.

ssl=yes ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? # use ssl-support. ?Works with

# ssl-library

use=web, web=myip.dnsdynamic.com ? ? ? ?# get ip from server.

server=www.dnsdynamic.org ? ? ? ? ? ? ? # default server

login=你的用戶名 ? ? ? ? ? ? ? ? ? ? ? ?# default login

password=你的密碼 ? ? ? ? ? ? ? ? ? ? ? # default password

server=www.dnsdynamic.org, ? ? ? ? ? ? ?\

protocol=dyndns2 ? ? ? ? ? ? ? ? ? ? ? ?\

你的網站域名 xxxx.dnsd.me

具體的配置選項可以參考 https://www.dnsdynamic.org/api.php

==========================================================================

pi@raspberrypi ~ $ sudo cat /etc/default/ddclient

# Configuration for ddclient scripts

# generated from debconf on Tue Apr 23 22:27:01 CST 2013

#

# /etc/default/ddclient

# Set to "true" if ddclient should be run every time a new ppp connection is

# established. This might be useful, if you are using dial-on-demand.

run_ipup="false"

# Set to "true" if ddclient should run in daemon mode

# If this is changed to true, run_ipup must be set to false.

run_daemon="true"

# Set the time interval between the updates of the dynamic DNS name in seconds.

# This option only takes effect if the ddclient runs in daemon mode.

daemon_interval="30"

===========================================================================

然后在你的路由器上開啟端口映射

開始享受你的網站

總結

以上是生活随笔為你收集整理的树莓派 php mysql 中文_使用树莓派(raspberry pi)搭建网站(nginx+php+mysql+ddclient)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。