月度存档: 6 月 2018

proftpd启动报错 error: no valid servers configured

通过SSH连接到客户VPS,发现 proftpd 服务没有启动。 运行启动命令提示错误:
[root@MyVPS proftpd]# service proftpd restart
Shutting down proftpd: [FAILED]
Starting proftpd: [FAILED]

因为proftpd默认没有开启日志的记录,所以/var/log/proftpd/ 这个目录下是空的,所以没法查看错误日志。运行:
proftpd –configtest

可以看到
– warning: unable to determine IP address of ‘MyVPS’
– error: no valid servers configured
– Fatal: error processing configuration file ‘/etc/proftpd.conf’

根据错误提示,是主机名和IP解析没法对应。

解决方法:

1,在配置文件/etc/proftpd.conf里面增加VPS IP;

DefaultAddress 173.231.28.140

2,修改主机名 /etc/hosts

vi /etc/hosts
173.231.28.140 MyVPS
保存退出后就OK了,service proftpd start可以成功启动

yii2页面引入js及获取下拉列表的值

1.advanced\backend\web目录下新建js文件夹用来放js文件

//myjs.js
$(function(){
   $('.link').change(function(){
        getSalutationValue(this.value); 
    });
   function getSalutationValue(value) {

      if(value == 1){
       $("#abc").html('ok');
      // $("#abc").hide();
      }
      if(value == 2){
       $("#abc").html('nopass');
     //  $("#abc").show();
      }
      if(value == 'Unspecified'){
        $("#abc").html('nothing');
      }
  }

});

2.修改advanced\backend\assets\AppAsset.php,添加自定义的js文件的路径,我这就是js/myjs.js

<?php

namespace backend\assets;

use yii\web\AssetBundle;

/**
 * Main backend application asset bundle.
 */
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.css',
    ];
    public $js = [
    'js/myjs.js'
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];
}

3.打开要引入js的views里面的某个页面,在title定义后加入AppAsset::register($this);

4. 下拉列表需要定义一个名字,用来被js控制

<?= $form->field($model,'status')->dropDownList([1=>'ok',2=>'nopass'],['class'=>'form-control link','prompt'=>'choose'
]);?>

这里是form-control link

整个视图页面代码如下:

<?php

/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use backend\assets\AppAsset;
$this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title;
AppAsset::register($this);
?>

<div class="site-login">
    <h1><?= Html::encode($this->title) ?></h1>

    <p>Please fill out the following fields to login:</p>

    <div class="row">
        <div class="col-lg-5">
            <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>

 <?= $form->field($model,'status')->dropDownList([1=>'ok',2=>'nopass'],['class'=>'form-control link','prompt'=>'choose'
]);?>

<div id="abc">1q2w3e4r</div>
            <?php ActiveForm::end(); ?>
        </div>
    </div>
</div>

xampp的相关命令

将下载的XAMPP安装包文件上传到Linux服务器,以系统管理员用户登录,通过下面的命令将其安装到/opt,安装后的目录为/opt/lampp。
##补充:mac下安装目录是: /Applications/XAMPP/xamppfiles/

tar xvfz XAMPP-xxxx-x.x.x.tar.gz -C /opt

安装完毕后,输入下面的命令就可以启动XAMPP了:

/opt/lampp/lampp start
mac下是
/Applications/XAMPP/xamppfiles/xampp start

这时你会看到如下信息:

Starting XAMPP for Linux 1.5.1…

XAMPP: Starting Apache with SSL (and PHP5)…

XAMPP: Starting MySQL…

XAMPP: Starting ProFTPD…

XAMPP for Linux started.

这里需要注意:XAMPP从 1.4.7版开始支持PHP 5与PHP 4可选启动,便于用户根据PHP程序的需要做出选择。

切换到php4的命令为:

/opt/lampp/lampp php4

切换到php5的命令为:

/opt/lampp/lampp php5

如果忘记了当前正在使用的PHP版本,可以通过下面的命令查看:

/opt/lampp/lampp phpstatus

其他启动参数如下:

start 启动 XAMPP。
stop 停止 XAMPP。
restart 重新启动 XAMPP。
startapache 只启动 Apache。
startssl 启动 Apache 的 SSL 支持。该命令将持续激活 SSL 支持,例如:执行该命令后,如果您关闭并重新启动 XAMPP,SSL 仍将处于激活状态。
startmysql 只启动 MySQL 数据库。
startftp 启动 ProFTPD 服务器。通过 FTP,您可以上传文件到您的网络服务器中(用户名“nobody”,密码“lampp”)。该命令将持续激活 ProFTPD,例如:执行该命令后,如果您关闭并重新启动 XAMPP,FTP 仍将处于激活状态。
stopapache 停止 Apache。
stopssl 停止 Apache 的 SSL 支持。该命令将持续停止 SSL 支持,例如:执行该命令后,如果您关闭并重新启动 XAMPP,SSL 仍将处于停止状态。
stopmysql 停止 MySQL 数据库。
stopftp 停止 ProFTPD 服务器。该命令将持续停止 ProFTPD,例如:执行该命令后,如果您关闭并重新启动 XAMPP,FTP 仍将处于停止状态。
security 启动一个小型安全检查程序。

停止方法:

sudo /opt/lampp/lampp stop

以上资料来源于网络,经过了一定的整理。更多的信息请访使用搜索引擎或访问官方网站:

http://www.apachefriends.org/zh_cn/index.html

React初探

最好的教程就是看开源程序了
https://github.com/zuiidea/antd-admin
下载后先跑起来
安装运行
1.下载或克隆项目源码
2.npm安装相关包文件(国内用户推荐yarn或者cnpm)
npm i 或者 yarn install
3.启动项目
npm start
4.打包项目
npm run build
5.打开 http://localhost:8000

参考文档:https://segmentfault.com/a/1190000009379222#articleHeader0

快速上手:
https://ant.design/docs/react/getting-started-cn

继承ActiveRecord的模型类 添加自定义属性

一、你在前期开发过程中,如果继承ActiveRecord的话,你应该是通过gii自动生成代码的

但是你在开发中,由于业务逻辑的一致改变,有可能会在之前的数据库中加一些字段

那么现在就需要注意了

二、你想将刚刚加入的字段也运用在代码中—很简单 跟我来

1.首先在数据库中加入你的字段(以oracle为例)

2.模型的操作

2.1 rules规则中加入字段

2.2 attributeLables中加入含义

2.3继承父类的方法用来整合自定义字段

public function attributes(){

$attributes = parent::attributes();

$attributes[] = “字段1”;

$attributes[] = “字段2”;

return $attributes;

}

三、在你添加或修改的地方

使用

$model->字段1 = 值1;

$model->字段2 = 值2;

$model->save();

就ok了!!!大笑