Centos 7 安装KDE桌面 VNC SERVER CHROME

安装KDE桌面

yum groupinstall "KDE Plasma Workspaces"
yum install ibus-table-chinese.noarch kde-l10n-Chinese.noarch
yum install ibus-libpinyin

设置启动进入KDE

# 查询默认终端命令 multi-user.target 相当于以前的 level 3,也就是命令行终端;而 graphical.target 相当于以前的 level 5,也就是图形界面
systemctl get-defaul

# 设置默认启动图型界面
systemctl set-default graphical.target

安装VNC

yum install tigervnc
yum install tigervnc-server

配置VNC SERVER

# 配置窗口一
tee /usr/lib/systemd/system/vncserver@:1.service <<-'EOF'
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
EOF

# 加载配置
systemctl daemon-reload

启用配置文件

# 设置密码
vncpasswd

# 启动服务
systemctl start vncserver@:1.service

# 查看服务状态
systemctl status vncserver@:1.service

# 开机自启动
systemctl enable vncserver@:1.service

如Type=forking报错 上面配置文件改为Type=simple

[Service]
Type=simple

vnc viewer客户端连接黑屏

chmod 777 /root/.vnc/xstartup

加入防火墙

# 开启防火墙
systemctl start firewalld
# 自启动防火墙
systemctl enable firewalld
# 添加窗口一用的5901端口
firewall-cmd --add-port=5901/tcp --permanent
# 重载防火墙
sudo firewall-cmd --reload

安装CHROME

CentOS/RedHat 7以上安装google-chrome可以完全参考https://intoli.com/blog/installing-google-chrome-on-centos/

# This installs Chrome on any RHEL/CentOS/Amazon Linux variant.
curl https://intoli.com/install-google-chrome.sh | bash

安装完成会显示 Successfully installed Google Chrome!

检查是否还缺乏依赖

ldd /opt/google/chrome/chrome | grep "not found"

返回为空,说明CentOS下chrome依赖问题基本解决。

不允许ROOT权限启动

修改/usr/bin/google-chrome文件 最下面

# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome"  "$@" 
# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir
2018/11/12 17:48 下午 posted in  CentOs

批量提取不规则文件中帐号密码不在同一行的数据进行合并

#!/bin/bash
filename="./input.txt"
num=0
cat $filename | while read line
do
    if [[ `echo $line | grep '帐号'` != "" ]]; then
        user=`echo $line | awk '{print $2}'`
        num=$(expr $num + 1)
    elif [[ `echo $line | grep '密码'` != "" ]]; then
        pass=`echo $line | awk '{print $2}'`
        num=$(expr $num + 1)
    fi

    if [[  $num == 2 ]]; then
        echo "匹配到: $user, $pass"
        echo "$user,$pass" >> ./output.txt
        num=0
    fi
done

----------------------------
afdkjakdsjfkja
adsfkdasjfk
网址  http://www.a.com
帐号  userA
密码  passA
afdkjakdsjfkja
adsfkdasjfk
网址  http://www.b.com
帐号  userB
密码  passB
----------------------------
http://www.test.com
网址  http://www.c.com
帐号  userC
密码  passC
http://www.test.com
2018/8/23 21:53 下午 posted in  Shell

OSX 10.11重置Launchpad icon

defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
2018/7/16 10:44 上午 posted in  Mac

安装oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

自动提示命令

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

# 开启插件
nano ~/.zshrc
# 修改添加zsh-autosuggestions
plugins=(
  zsh-autosuggestions
  git
)

语法高亮

brew install zsh-syntax-highlighting

echo "source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc

source ~/.zshrc
2018/7/15 13:42 下午 posted in  Mac

MAC下BREW安装NGINX+PHP+MYSQL环境

安装BREW 先安装XCODE

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
xcode-select --install

安装NGINX (因官方库更新不支持插件 使用https://github.com/denji/homebrew-nginx)

brew tap denji/nginx
brew install nginx-full --with-geoip2-module --with-headers-more-module --with-lua-module --with-redis2-module --with-subs-filter-module

NGINX 移动配置信息保存到目录(~/Documents/nginx) 更改80端口及运行权限

# 转移配置文件
mv /usr/local/etc/nginx/ ~/Documents/WebSite/nginx/
ln -s ~/Documents/WebSite/nginx /usr/local/etc/nginx

# 创建目录
mkdir -p ~/Documents/WebSite/nginx/vhosts/
mkdir -p ~/Documents/WebSite/default/wwwroot/
mkdir -p ~/Documents/WebSite/default/logs/
mkdir -p ~/Documents/WebSite/logs/

# 创建配置文件
tee ~/Documents/WebSite/nginx/nginx.conf  <<-'EOF'
user  nobody;
worker_processes  1;

pid        /Users/用户名/Documents/WebSite/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        access_log  /Users/用户名/Documents/WebSite/default/logs/access.log  main;
        error_log  /Users/用户名/Documents/WebSite/default/logs/error.log;

        location / {
            root   /Users/用户名/Documents/WebSite/default/wwwroot/;
            index  index.html index.htm;
        }
    }

    include vhosts/*;
}
EOF

# 更改80端口权限
sudo chown root:wheel /usr/local/opt/nginx-full/bin/nginx
sudo chmod u+s /usr/local/opt/nginx-full/bin/nginx

NGINX开机启动

ln -sfv /usr/local/opt/nginx-full/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx-full.plist

安装MYSQL

brew install [email protected]

# 添加环境到/etc/profile
export PATH="$(brew --prefix [email protected])/bin:$PATH"
srouce /etc/profile

修改配置

# 创建目录
mkdir -p ~/Documents/MySql/
mkdir -p ~/Documents/MySql/data/

# 创建配置文件
tee ~/Documents/MySql/my.cnf  <<-'EOF'
[client]
socket = /Users/用户名/Documents/MySql/mysqld.sock
port = 3306
[mysqld]
socket = /Users/用户名/Documents/MySql/mysqld.sock
port = 3306
datadir = /Users/用户名/Documents/MySql/data
skip-external-locking
bind-address = 0.0.0.0
log_error = /Users/用户名/Documents/MySql/mysql-error.log
slow_query_log = on
slow-query-log-file = /Users/用户名/Documents/MySql/mysql-slow.log
EOF

ln -s ~/Documents/MySql/my.cnf /usr/local/etc/my.cnf

初使化MYSQL

mysqld --initialize

MySQL开机启动

ln -sfv /usr/local/opt/[email protected]/*.plist ~/Library/LaunchAgents

# 更改数据目录为/Users/用户名/Documents/MySql/data
nano ~/Library/LaunchAgents/[email protected]
launchctl load ~/Library/LaunchAgents/[email protected]

安装完成之后更改密码

# 查看密码
grep "generated for root@localhost" ~/Documents/MySql/mysql-error.log
# 用密码登陆
mysql -u root -p
# 修改密码
SET PASSWORD = PASSWORD('密码');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;
quit

更新CURL

brew install curl
brew link curl --force

安装PHP

brew update
brew install [email protected]
# 添加PHP到环境(/etc/profile)
export PATH="$(brew --prefix php56)/bin:$PATH"
export PATH="$(brew --prefix php56)/sbin:$PATH"
source /etc/profile
mv /usr/local/etc/php/ ~/Documents/WebSite/php/
ln -s ~/Documents/WebSite/php /usr/local/etc/php

nano ~/Documents/WebSite/php/5.6/php-fpm.conf

#修改内容去掉注释
pid = /Users/用户名/Documents/WebSite/php/php-fpm.pid

PHP-FPM开机启动

ln -sfv /usr/local/opt/[email protected]/*.plist ~/Library/LaunchAgents
# 更改数据目录为/Users/用户名/Documents/WebSite/php/5.6/
launchctl load ~/Library/LaunchAgents/[email protected]
2018/7/15 10:14 上午 posted in  Mac Php Nginx