007环境搭建--iwebshop安装

调试 iwebshop部署

1.查看环境是否启动

netstat -tnulp | grep 80 netstat -tnulp | grep 3306 netstat -tnulp | grep 9000

2.配置Nginx主配置文件

[root@localhost etc]# vim /data/server/nginx/conf/nginx.conf 先设置粘贴模式:冒号set paste 进入编辑模式a 然后粘贴 # 在http配置段内容增加下面的内容     

server {
        listen       80;
        server_name iwebshop.itcast.com;
        #静态请求处理的location
        location / {
            root   html/iwebshop;
            index index.php  index.html index.htm;
        }
        #动态请求处理的location
        location ~* .*\.(php|php5)?$ {
            root html/iwebshop;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
    }

3.修该hosts文件,添加 配置域名解析

vim /etc/hosts

...

127.0.0.1 iwebshop.itcast.com

4.修改完配置文件后,检查语法并重启nginx服务

[root@localhost etc]# /data/server/nginx/sbin/nginx -t
nginx: the configuration file /data/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data/server/nginx/conf/nginx.conf test is successful
[root@localhost etc]# /data/server/nginx/sbin/nginx -s reload

5.生成一个php测试文件

生成一个php的测试文件到blog站点目录下

cd /data/server/nginx/html
mkdir iwebshop
echo '<?php phpinfo(); ?>'  >/data/server/nginx/html/iwebshop/test_info.php


另外的方法:iwebshop已创建好
cd /data/server/nginx/html/iwebshop
vim test_info.php
输入:
<?php phpinfo(); ?>
浏览器访问iwebshop.itcast.com/test_info.php

此时blog站点目录下应该有一个主页文件和php测试文件

[root@localhost html]# ll /data/server/nginx/html/blog/
total 4
-rw-r--r--. 1 root root 20 Nov  3 22:22 test_info.php

测试nginx与php的连通性

浏览器访问iwebshop.itcast.com/test_info.php

 

 

PHP和数据库之间的链接:

mysql -uroot -p123456          #登录数据库
show databases;                   #查看数据库
drop database iwebshop;
create database  iwebshop;       #创建一个数据库

创建数据库用户:

grant all on wordpress.* to iwebshop@'localhost' identified by '123456';     
flush privileges;
select user,host from mysql.user;

#创建一个用户iwebshop,权限为全部,并且设置允许登录的网段,和最后设置密码

#flush privileges  创建完用户后,更新一下数据库的信息

#查看数据库内的用户信息,和对应可以登录的主机

 

生成一个mysql的测试文件

到blog的站点目录下,生成一个mysql测试文件

cd /data/server/nginx/html/iwebshop/
vim test_mysql.php

:set paste
输入下面:黏贴
<?php
//$link_id=mysql_connect('主机名','用户','密码');
//mysql -u用户 -p密码 -h 主机
$link_id=mysql_connect('localhost','iwebshop','123456') or mysql_error();
if($link_id){
       echo "mysql successful by wangshusen !\n";
    }else{
       echo mysql_error();
    }
?>

测试PHP与MySQL的连通性

访问http://iwebshop.itcast.com/test_mysql.php出现下面的内容就是测试成功

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值