这次要搭建一个nginx+php+mysql+dnspod动态解析 有路由器的么直接去路由器管理界面把树莓的mac绑定下,再映射这样会方便很多,不用担心ip变掉。 首先sudo su获得root权限后操作会方便很多 先 再 - apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server
复制代码安装期间会提示叫你输入数据库密码(这必须要记住..) 在root权限命令行输入命令 - nano /etc/nginx/nginx.conf
复制代码对照修改如下
开头部分 - user www-data;
- worker_processes 1; 修改这里
- pid /var/run/nginx.pid;
- events {
- worker_connections 64; 修改这里
- # multi_accept on;
- }
复制代码继续向后找到gzip 去掉前面的注释 修改如下 - gzip on;
- gzip_disable "msie6";
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_buffers 16 8k;
- gzip_http_version 1.1;
- gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
复制代码Ctrol+O保存 Ctrl+X退出
在root权限命令行输入命令 - nano /etc/php5/fpm/php.ini
复制代码找到这一段 - ; Maximum amount of memory a script may consume (128MB) ;
- <a href="http://php.net/memory-limit" target="_blank">http://php.net/memory-limit </a>
- memory_limit = 32M 修改这里
复制代码 找到这一段- ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
- ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
- ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
- ; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
- ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
- ;<a href="http://php.net/cgi.fix-pathinfo" target="_blank">http://php.net/cgi.fix-pathinfo </a>
- cgi.fix_pathinfo=1 修改这里
复制代码在root权限命令行输入命令 - nano /etc/php5/fpm/php-fpm.conf
复制代码找到这一段 - ; The maximum number of processes FPM will fork. This has been design to control
- ; the global number of processes when using dynamic PM within a lot of pools.
- ; Use it with caution.
- ; Note: A value of 0 indicates no limit
- ; Default Value: 0 process.max = 4 修改这里
复制代码接着改nginx - nano /etc/nginx/sites-enabled/default
复制代码找到这里 修改如下 - # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
- ##
- server {
- listen 80; ## listen for ipv4; this line is default and implied
- #listen [::]:80 default_server ipv6only=on; ## listen for ipv6root /home/pi/www;
复制代码 #建议放在此文件夹内,以后管理更加方便- # index index.html index.htm;
- index index.php index.html index.htm;
- # Make site accessible from http://localhost/
- server_name localhost;
复制代码在这句后面增加以下内容 - if (!-e $request_filename) {
- rewrite ^(.*)$ /index.php$1 last;
- }
复制代码找到这句
location ~ \.php$ {
连同后续内容修改如下 - 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;
- # # With php5-fpm:fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_index index.php;
- include fastcgi_params;
- }
复制代码完成之后重新加载服务 - service nginx reload
- service php5-fpm reload
- service mysql reload
复制代码接下来安装phpmyadmin - mkdir /home/pi/www
- wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.5.7/phpMyAdmin-3.5.7-all-languages.zip<a href="http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.5.7/phpMyAdmin-3.5.7-all-languages.zipunzip" target="_blank">
- </a>punzip phpMyAdmin-3.5.7-all-languages.zip
复制代码最后给文件夹权限 - chown www-data:www-data /home/pi/www -R
- chmod 755 /home/pi/www -R
复制代码最后是dnspod的设置 https://gist.github.com/chuangbo/833369 这里已有源代码
需要修改的地方如下 - params = dict(
- login_email="email", # dnspod的邮箱
- login_password="password", # 你的密码
- format="json",
- domain_id=100, #domain_id <a href="http://geekpi.cn/dnspod" target="_blank">http://geekpi.cn/dnspod</a>域名编号去左边的连接获取
- record_id=100, # record_id 记录id同上,子域名前面的编号
- sub_domain="www", # 你想要解析的子域名
- record_line="默认",
- )
复制代码保存为dnspod.py
然后输入 nohup python main.py &
就已经在后台运行了按ctrl+c也不会退出,只有用kill才能删除进程 演示 pi.isdiary.com 转自:http://www.isdiary.com/2013/04/490
|