码迷,mamicode.com
首页 > 其他好文 > 详细

LNMP

时间:2017-12-13 23:22:32      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:ide   分享图片   浏览器   style   font   html   images   /usr   create   

???? ?

目录

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

    技术分享图片

    ?

    ?

    ?

LNMP

标签:ide   分享图片   浏览器   style   font   html   images   /usr   create   

原文地址:http://www.cnblogs.com/kazihuo/p/8034496.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!