LNMP

      

目录

1.    Nginx配置    1

2.    PHP解析    2

2.1    Mysql    3

2.2    服务安装    3

2.3    连接测试    3

2.4    数据配置    4

3.    Blogs    4

 

环境:

Mysql:192.168.10.10

Nginx、PHP:192.168.10.11

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

相关操作命令:

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

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

  1. 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;

    }

     

  2. 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

     

  3. Mysql

  4. 服务安装

    略;

  5. 连接测试

    [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();

            }

    // 单行注释

    /* 多行注释 */

    ?>

     

    测试结果:

  6. 数据配置

    # 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 |

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

     

  7. 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

     

     

     

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

作者: 罗穆瑞

转载请保留此段声明,且在文章页面明显位置给出原文链接,谢谢!

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

如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值