分类目录归档:Linux

How to convert lantern debian/ubuntu deb package to CentOS/fedora rpm/yum package

Install deb to rpm tool

sudo dnf install alien

Download ubuntu deb file

Download url :https://github.com/getlantern/lantern/releases/tag/latest

Convert deb to rpm

sudo alien -r lantern-installer-64-bit.deb

Install rpm

sudo dnf install lantern-4.0.1-2.x86_64.rpm

Get Error:“conflicts with file from package filesystem”

Rebuild RPM

sudo dnf install rpmrebuild
sudo rpmrebuild -pe lantern-4.0.1-2.x86_64.rpm

Comment lines in rebuild file

(Converted from a deb package by alien version 8.95.)
%files
#%dir %attr(0755, root, root) "/"
#%dir %attr(0755, root, root) "/usr"
#%dir %attr(0755, root, root) "/usr/bin"
%attr(0777, root, root) "/usr/bin/lantern"
#%dir %attr(0755, root, root) "/usr/lib"
%dir %attr(0755, root, root) "/usr/lib/lantern"
%attr(0644, root, root) "/usr/lib/lantern/.packaged-lantern.yaml"
%attr(0644, root, root) "/usr/lib/lantern/lantern-binary"
%attr(0755, root, root) "/usr/lib/lantern/lantern.sh"
%attr(0644, root, root) "/usr/lib/lantern/lantern.yaml"
#%dir %attr(0755, root, root) "/usr/share"
#%dir %attr(0755, root, root) "/usr/share/applications"
%attr(0644, root, root) "/usr/share/applications/lantern.desktop"
#%dir %attr(0755, root, root) "/usr/share/doc"
%dir %attr(0755, root, root) "/usr/share/doc/lantern"
%doc %attr(0644, root, root) "/usr/share/doc/lantern/changelog.gz"
%doc %attr(0644, root, root) "/usr/share/doc/lantern/copyright"
#%dir %attr(0755, root, root) "/usr/share/icons"
#%dir %attr(0755, root, root) "/usr/share/icons/hicolor"
#%dir %attr(0755, root, root) "/usr/share/icons/hicolor/128x128"
#%dir %attr(0755, root, root) "/usr/share/icons/hicolor/128x128/apps"
%attr(0644, root, root) "/usr/share/icons/hicolor/128x128/apps/lantern.png"
%changelog

Install again

sudo rpm -i /root/rpmbuild/RPMS/x86_64/lantern-4.0.1-2.x86_64.rpm

Install libappindicator

sudo dnf install libappindicator-gtk3

Refs

alien:deb(ubuntu/debian)与rpm(centos/fedora)转换工具

deb 与 rpm 是GNU/Linux 流行的软件包格式。我们“alien”可以在rpm\dpkg\slackware tgz\deb\slp 格式见进行转换。

Debian/Ubuntu 可使用下面命令安装alien:

sudo apt-get install alien

从RPM转到DEB

举例:假设在目录/tmp 有myprogram.rpm 文件,使用下面命令转换:

sudo alien /tmp/myprogram-1.10-2.i386.rpm

myprogram-1.10-3.i386.deb generated

这时,在/tmp 目录下就会发现有 myprogram.deb ,这时就可以使用dpkg安装:

dpkg -i /tmp/miprogramma.deb

从DEB转到RPM

直接添加参数-r进行转换即可:

sudo alien -r pytube_0.0.8.1-1_all.deb

pytube-0.0.8.1-2.noarch.rpm generated

使用帮助

输入alien可以查看帮助

Usage: alien [options] file [...]
  file [...]                Package file or files to convert.
  -d, --to-deb              Generate a Debian deb package (default).
     Enables these options:
       --patch=<patch>      Specify patch file to use instead of automatically
                            looking for patch in /var/lib/alien.
       --nopatch        Do not use patches.
       --anypatch           Use even old version os patches.
       -s, --single         Like --generate, but do not create .orig
                            directory.
       --fixperms           Munge/fix permissions and owners.
       --test               Test generated packages with lintian.
  -r, --to-rpm              Generate a Red Hat rpm package.
      --to-slp              Generate a Stampede slp package.
  -l, --to-lsb              Generate a LSB package.
  -t, --to-tgz              Generate a Slackware tgz package.
     Enables these options:
       --description=<desc> Specify package description.
       --version=<version>  Specify package version.
  -p, --to-pkg              Generate a Solaris pkg package.
  -i, --install             Install generated package.
  -g, --generate            Generate build tree, but do not build package.
  -c, --scripts             Include scripts in package.
      --target=<arch>       Set architecture of the generated package.
  -v, --verbose             Display each command alien runs.
      --veryverbose         Be verbose, and also display output of run commands.
  -k, --keep-version        Do not change version of generated package.
      --bump=number         Increment package version by this number.
  -h, --help                Display this help message.
  -V, --version         Display alien's version number.

设置virtualbox linux客户端共享文件夹权限

在virtualbox中设置共享目录以及共享名

打开virtualbox“设置”菜单》“共享文件家”,设置共享目录以及共享名

设置linux客户端mount用户

通过id查看用户和用户组的id,然后通过mount的-o选项设置客户端用户以及用户组

sudo mount -t vboxsf -o uid=1000,gid=1000 share /share

centos 7 + php 7 + nginx + wordpress之yum最简单安装办法

安装eple库

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

安装webtatic库

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

更新yum源

yum update

安装php7以及扩展

yum install php71w-gd php71w-pdo php71w-opcache php71w-fpm php71w-pecl-redis php71w-mysql php71w-mcrypt php71w-mbstring php71w-intl php71w-cli

安装nginx

yum install nginx1w -y

系统启动时自动启动nginx以及php-fpm

systemctl enable nginx php-fpm
systemctl start nginx php-fpm

修改php程序目录权限

chown -R apache:apache /data/web/www.c4ys.com/

修改ngingx配置(以为wordpress例)

vim /etc/nginx/conf.d/www.c4ys.com.conf

server {
    server_name  www.c4ys.com c4ys.com;
    root   /data/phpproject/www.c4ys.com;
    location / {
        index  index.html index.php;
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

sphinx-jieba试用笔记

实际使用中发现parse耗时很多,而且经常搜索不到词。弃坑。

下载并安装sphinx-jieba

$ git clone https://github.com/c4ys/sphinx-jieba
$ cd sphinx-jieba
$ git submodule update --init --recursive
$ sudo apt install gcc cmake automake g++
$ sudo apt install libmysqld-dev
$ ./configure --prefix=/usr/local/sphinx-jieba
$ cp cppjieba/include/cppjieba src/ -r
$ cp cppjieba/deps/limonp src/ -r
$ sudo make install

建立数据库

sql如下

CREATE TABLE documents ( id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT, title VARCHAR(255) NOT NULL );

REPLACE INTO documents ( title ) VALUES
('广州狗场直销泰迪边牧阿拉斯加等各名犬 微信视频同步'),
('出售阿拉金毛拉多泰迪萨摩哈士奇等30多个品种 保健康可送货'),
('广州哪里买纯种哈士奇 雪橇犬哈士奇多少钱'),
('广州边境牧羊犬狗场 广州哪里有卖边牧犬小狗 边境牧羊犬小狗'),
('广州跳跳犬舍 纯种憨厚老实巴哥幼犬 小型短毛犬 纯种健康'),
('广州地区金毛多少钱一只巡回犬赛级品质 签协议 健康血统有保'),
('广州狗场直销阿拉斯加金毛泰迪哈士奇萨摩耶秋田德牧等各种名犬');

建立sphinx配置

source src1
{
        type                    = mysql
        sql_query_pre = SET NAMES utf8
        sql_host                = localhost
        sql_user                = test
        sql_pass                = 
        sql_db                  = test
        sql_port                = 3306  # optional, default is 3306
        sql_query               =   SELECT id,  title   FROM documents
        sql_field_string = title
}


index test1
{
        source                  = src1
        path                    = /usr/local/sphinx-jieba/var/data/test1
        charset_type = utf-8
        chinese_dictionary = /usr/local/sphinx/etc/xdict
}



indexer
{
        mem_limit               = 128M
}


searchd
{
        listen                  = 9312
        listen                  = 9306:mysql41
        log                     = /usr/local/sphinx-jieba/var/log/searchd.log
        query_log               = /usr/local/sphinx-jieba/var/log/query.log
        read_timeout            = 5
        max_children            = 30
        pid_file                = /usr/local/sphinx-jieba/var/log/searchd.pid
        seamless_rotate         = 1
        preopen_indexes         = 1
        unlink_old              = 1
        workers                 = threads # for RT to work
        binlog_path             = /usr/local/sphinx-jieba/var/data
}

复制词典

sudo cp cppjieba/dict/* /usr/local/sphinx-jieba/etc/ -r
cd /usr/local/sphinx-jieba/
sudo cp etc/jieba.dict.utf8 etc/xdictjieba.dict.utf8
sudo cp etc/user.dict.utf8 etc/xdictuser.dict.utf8
sudo cp etc/hmm_model.utf8 etc/xdicthmm_model.utf8
sudo cp etc/idf.utf8 etc/xdictidf.utf8
sudo cp etc/stop_words.utf8 etc/xdictstop_words.utf8

建立索引,并启动sphinx服务

sudo bin/indexer --all
sudo bin/searchd

测试

mysql -h 127.0.0.1 -P 9306

连接mysql

select * from test1 where match('宠物狗') limit 1000;

linux crontab 与 anacrontab

Crontab 用于固定的时间做某件事。Anacrontab 用于crontab因为任何原因没有执行时,进行补充执行

Crontab的配置入口在/etc/crontab,日志在/var/log/

Anacrontab的配置入口在/etc/anacrontab,日志在/var/spool/cron记录了上次crontab运行的时间。

举例:
任务a在crontab定义为每周日晚上0点执行。因为某种原因本周0点服务器没有启动,那么crontab没有执行成功/var/spool/cron记录的时间还是上周末,Anacrontab发现了上次执行时间超过了一周,那么会进行补执行。