• LNMP详解


    环境

    Mysql:192.168.10.10

    Nginx、PHP:192.168.10.11

    在服务都部署好之后,对其进行关联;

    相关操作命令:

    # /usr/local/nginx/sbin/nginx -t

    # /usr/local/nginx/sbin/nginx -s reload

    Nginx配置

    [root@c1 /usr/local/nginx/conf]# cat nginx.conf

    worker_processes 1;

    events {

    worker_connections 1024;

    }

    http {

    include mime.types;

    default_type application/octet-stream;

    sendfile on;

    keepalive_timeout 65;

    server {

    listen 80;

    server_name localhost;

    location / {

    root html;

    index index.html index.htm;

    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {

    root html;

    }

    }

    include extra/kazihuo.conf;

    }

    PHP解析

    [root@c1 /usr/local/nginx/conf/extra]# cat kazihuo.conf

    server {

        listen 80;

        server_name www.kazihuo.com;

        location / {

        root html/kazihuo;

         index index.php index.html index.htm;

        }    

     

        location ~ .*.(php|php5)?$ {

         root html/kazihuo;

         fastcgi_pass 127.0.0.1:9000;

         fastcgi_index index.php;

         include fastcgi.conf;

        }

    }

    [root@c1 /usr/local/nginx/html/kazihuo]# cat index.php

    <?php phpinfo(); ?>

    # 以上代码是显示PHP配置信息

    测试:

    现在本地电脑做好解析,打开浏览器http://www.kazihuo.com/index.php

    Mysql操作

    服务安装

    详细步骤见博文MYSQL汇总;

    连接测试

    [root@c1 /usr/local/nginx/html/kazihuo]# cat test_mysql.php

    <?php

        //$link_id=mysql_connect('主机名','用户','密码');

        $link_id=mysql_connect('192.168.10.10','root','000000') or mysql_error();

        if ($link_id) {

            echo "mysql successful by kazihuo !";

        }

        else{

            echo mysql_error();

            }

    // 单行注释

    /* 多行注释 */

    ?>

    测试结果:

    数据配置

    # mysql -uroot -p000000

    > create database wordpress;

    > grant all on wordpress.* to wordpress@'192.168.10.%' identified by '123456';6';

    > flush privileges;

    > show grants for wordpress@'192.168.10.%';

    +---------------------------------------------------------------------+

    | Grants for wordpress@192.168.10.% |

    +---------------------------------------------------------------------+

    | GRANT USAGE ON *.* TO 'wordpress'@'192.168.10.%' |

    | GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpress'@'192.168.10.%' |

    +---------------------------------------------------------------------+

    > select user,host from mysql.user;

    +-----------+--------------+

    | user | host |

    +-----------+--------------+

    | root | % |

    | root | 127.0.0.1 |

    | wordpress | 192.168.10.% |

    | mysql.sys | localhost |

    | root | localhost |

    +-----------+--------------+

    Blogs建立

    # wget https://cn.wordpress.org/wordpress-4.9.1-zh_CN.tar.gz

    # tar -axvf wordpress-4.9.1-zh_CN.tar.gz

    [root@c1 /usr/local/nginx/html/kazihuo]# rm -rf index.php test_mysql.php #此步骤是删除之前的测试文件

    # cd wordpress/

    # mv * /usr/local/nginx/html/kazihuo/

    [root@c1 /usr/local/nginx/html]# chown -R nginx.nginx kazihuo

    测试:

    浏览器输入:www.kazihuo.com

  • 相关阅读:
    一套代码小程序&Web&Native运行的探索05——snabbdom
    一套代码小程序&Web&Native运行的探索04——数据更新
    一套代码小程序&Web&Native运行的探索03——处理模板及属性
    一套代码小程序&Web&Native运行的探索02
    微信小程序开发07-列表页面怎么做
    微信小程序开发06-一个业务页面的完成
    微信小程序开发05-日历组件的实现
    微信小程序开发04-打造自己的UI库
    微信小程序开发03-这是一个组件
    30分钟ES6从陌生到熟悉
  • 原文地址:https://www.cnblogs.com/kazihuo/p/8059711.html
Copyright © 2020-2023  润新知