zoukankan      html  css  js  c++  java
  • 本地虚拟机部署线上php程序---不需要修改数据库信息

    1、特别注意:拿来线上php程序后一般是不需要修改config.php里面的数据库连接信息的,如果修改了会报错:站点已关闭。所以 2、5 步骤是需要省略的。
    如果拿来的是最开始的php源码,需要配置原始数据库信息,2、5 步骤就需要做,但是一般也是研发配置里面的数据库信息,
    2、创建php程序的数据库用户(可省略)
    mysql> create database itshop;
    
    mysql> grant all privileges on *.* to'itshop'@'%' identified by 'mysql@123';
    
    mysql> flush privileges;
    
     
    
    3、导入数据库
    
    find / -name *.sql
    
    /www/wwwroot/default/pma_6a8f9f27/examples/create_tables.sql
    /www/wwwroot/default/pma_6a8f9f27/examples/upgrade_tables_mysql_4_1_2+.sql
    /www/wwwroot/default/pma_6a8f9f27/examples/create_tables_drizzle.sql
    
     
    
    mysql> use itshop;
    Database changed
    
    mysql> source /www/wwwroot/default/pma_6a8f9f27/examples/create_tables.sql
    
    mysql> source /www/wwwroot/default/pma_6a8f9f27/examples/upgrade_tables_mysql_4_1_2+.sql
    
    mysql> source /www/wwwroot/default/pma_6a8f9f27/examples/create_tables_drizzle.sql
    
     
    
    4、拿来代码设置权限
    
    把php代码表放到  /www/wwwroot/default/  目录下
    
    设置权限,否则报错
    
    [root@bogon ~]# ls /www/wwwroot/default/
    Addons Application doc favicon.ico info.php Public ThinkPHP wx
    api Data errpage index.php pma_6a8f9f27 Runtime Uploads
    [root@bogon ~]# cd /www/wwwroot/
    [root@bogon wwwroot]# chmod -R 777 default/
    
    
    
    
    5、修改配置文件里面的数据库信息(可省略)
    
    [root@bogon ~]# find / -name config.php
    
    /www/wwwroot/default/Application/Common/Conf/config.php
    
    [root@bogon ~]# vi /www/wwwroot/default/Application/Common/Conf/config.php
    
    /* 数据库配置 */
    'DB_TYPE' => 'mysqli', // 数据库类型
    'DB_HOST' => '192.168.0.204', // 服务器地址
    'DB_NAME' => 'itshop', // 数据库名
    'DB_USER' => 'itshop', // 用户名
    'DB_PWD' => 'mysql@123', // 密码
    'DB_PORT' => '3306', // 端口
    'DB_PREFIX' => 't_', // 数据库表前缀
    
    
    6、配置nginx配置文件
    
    [root@bogon conf.d]# cat test4.conf 
    server
        {
            listen       8083;
            server_name 192.168.0.204;
            index index.html index.htm default.html index.php;
            root  /www/wwwroot/default;
    
            if (!-e $request_filename) {                                   #访问路径的文件不存在则重写URL转交给ThinkPHP处理
                rewrite  ^/(.*)$  /index.php/$1  last;
                break;
            }
            
    
    	location ~ [^/].php(/|$)
    	    {
            	try_files $uri =404;
    		fastcgi_pass  127.0.0.1:9000;                           # 如果端口不存在就需要写成 unix:/tmp/php-cgi-54.sock
    		fastcgi_index index.php;
    		include fastcgi.conf;                                   # 注意这个include 这个配置文件是nginx自带的,一定要有
    	
    
    		set $real_script_name $fastcgi_script_name;             # 下面这 8 行统称为fastcgi_params的配置,nginx也有自带的fastcgi_params,但是报错,按照下面的就行
    		if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {       #  宝塔面板里面 直接把这 8 行写到了一个pathinfo.conf文件里面,用一句话include pathinfo.conf代替
                    	set $real_script_name $1;
                    	set $path_info $2;
     		}
    		fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    		fastcgi_param SCRIPT_NAME $real_script_name;
    		fastcgi_param PATH_INFO $path_info;
    
    
        	}       
    
    
            location /status {
                stub_status on;
                access_log   off;
            }
    
    	location /favicon.ico {
    	    root html;
    	}
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
                {
                    expires      15d;
                }
    
            location ~ .*.(js|css)?$
                {
                    expires      6h;
                }
            access_log  /var/www/ceshi.access.log  access;
            error_log  /var/www/ceshi.error.log;                        # 错误日志的路径
        }
    
    
    7、检查nginx、重新加载nginx
    
    nginx -t
    
    nginx -s reload
    8、打开浏览器访问 http://192.168.0.204:8083

      

  • 相关阅读:
    从Ecma规范深入理解js中的this的指向
    js中继承的几种用法总结(apply,call,prototype)
    缓存 Array.length 是老生常谈的小优化
    spark app
    source code spark
    spark dev by IDEA
    编译spark-0.9.1
    图解GIT,ZT
    Spark分布式安装
    倒排索引(Inverted Index)
  • 原文地址:https://www.cnblogs.com/effortsing/p/10124054.html
Copyright © 2011-2022 走看看