CentOS部署部署Edusoho

关闭SELINUX

sudo vi /etc/selinux/config

将内容修改为以下信息:

# SELINUX=enforcing # 禁用该配置
# SELINUXTYPE=targeted # 禁用该配置
SELINUX=disabled # 禁用该配置

修改配置后执行以下命令使其配置生效:

setenforce 0

安装 apache 和 xsendfile 依赖

yum install httpd
rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/m/mod_xsendfile-0.12-10.el7.x86_64.rpm

注意:如果安装的时候,提示与httpd版本不匹配,依赖不足,可以到http://mirrors.opencas.cn/epel 查找合适的安装源

安装PHP和相关插件

yum install -y php php-cli php-curl php-fpm php-intl php-mcrypt php-mysql php-gd php-mbstring php-xml php-dom

修改PHP配置

vim /etc/php.ini

将以下配置参数进行修改:

post_max_size = 1024M             # 672 行
memory_limit = 1024M              # 405 行
upload_max_filesize = 1024M       # 800 行

修改PHP-FPM配置

sudo vi /etc/php-fpm.d/www.conf

添加以下配置参数:

listen.owner = apache
listen.group = apache
listen.mode = 0666

设置PHP-FPM启动脚本

sudo systemctl start php-fpm    # 启动php-fpm
sudo systemctl enable php-fpm   # 开机启动php-fpm

下载安装edusoho

wget http://download.edusoho.com/edusoho-VERSION.tar.gz  (注:将VERSION替换为当前EduSoho最新版本号,可从官网www.edusoho.com查询获取)
tar zxvf edusoho-VERSION.tar.gz
cp -r edusoho /var/www
cd /var/www && sudo chown -R apache:apache ./

创建配置edusoho

sudo vi /etc/httpd/conf.d/edusoho.conf

在文件中添加以下内容:

<VirtualHost *:80>
    ServerName mooc.ttxit.com
    ServerAlias mooc.ttxit.com

    DocumentRoot /edu/edusoho/web
    <Directory /edu/edusoho/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Order allow,deny
        Allow from All
    </Directory>
    ErrorLog /var/log/edusoho_error.log
    CustomLog /var/log/edusoho_access.log combined
</VirtualHost>

配置启动apache服务

sudo systemctl start httpd    # 启动apache
sudo systemctl enable httpd   # 开机启动apache

CentOS 7安装Deluge

未分类

Deluge 支持 Linux (Debian, Fedora, OpenSUSE, Arch, Gentoo )、Win、Mac、FreeBSD 多个平台,非常稳定,而且支持单一种子限速功能。部分 PT 站会对单一种子的速度有限制,如果超速,账号可能会被警告甚至封禁。如果挂的PT站有限速要求,推荐使用Deluge。比较遗憾的是,Deluge没有官方的CentOS源。如果需要在CentOS安装,可尝试下第三方的源。

Deluge 有 GUI for the desktop,Web UI for the browser 和 Console UI for the command line 三个 interfaces,这里安装的是 Web UI for the browser,可以通过浏览器管理 Deluge。

Delgue 在 NUX 源中,因而安装需要添加 NUX。部分依赖包需要 EPEL 源,如果没有安装 EPEL 源,也需要添加。

# 安装 EPEL 源
yum -y install epel-release
# 安装 NUX 源
yum -y install wget
wget http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
rpm -ivh nux-dextop-release-0-5.el7.nux.noarch.rpm

添加源后,接着安装 Deluge:

yum -y install deluge-web

运行

systemctl start deluge-web

访问 http://ip 地址:8112 即可访问 Web 界面。如果开启了防火墙,需要开放 8112 端口:

firewall-cmd --permanent --zone=public --add-port=8112/tcp
firewall-cmd --reload

开机自启动

systemctl enable deluge-web

附带 http://ip 地址:8112,deluge的web页面:

未分类

Ubuntu安装deluge教程可以参考官方:https://dev.deluge-torrent.org/wiki/Installing/Linux/Ubuntu

CentOS简单操作命令及node.js的安装方法

本文实例讲述了CentOS简单操作命令及node.js的安装方法。分享给大家供大家参考,具体如下:

查看centos内核的版本:

uname -a

uname -r

查看linux版本:

cat /etc/issue

查看系统是64位还是32位:

getconf LONG_BIT

安装node.js

因为node.js需要Python2.6以上

Note: Python 2.6 or 2.7 is required to build from source tarballs.

查看Python版本

python -V

安装依赖

yum -y install gcc make gcc-c++ openssl-devel wget

下载node.js源码及安装

wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz

tar -zxf node-v0.12.0.tar.gz

cd node-v0.12.0

./configure && make && make install

CentOS/Debian/Ubuntu系统 TCP-BBR 一键安装脚本

其他BBR一键脚本:『逗比』Debian/Ubuntu系统 TCP拥塞控制技术 ——TCP-BBR 一键安装脚本

本脚本适用环境

系统支持:CentOS 6+,Debian 7+,Ubuntu 12+

虚拟技术:OpenVZ 以外的(KVM、Xen、VMware等)

内存要求:≥128M

日期  :2017 年 01 月 13 日

关于本脚本

  • 本脚本已在 Vultr 上的 VPS 全部测试通过。
  • 当脚本检测到 VPS 的虚拟方式为 OpenVZ 时,会提示错误,并自动退出安装。
  • 某些服务商(如 Linode、DigitalOcean)可能需要首先将 VPS 配置为可自定义内核,然后 grub2 的配置才会生效。
  • 脚本运行完重启发现开不了机的,打开 VPS 后台控制面板的 VNC, 开机卡在 grub 引导, 手动选择内核即可。
  • 由于是使用最新版系统内核,最好请勿在生产环境安装,以免产生不可预测之后果。

使用方法

使用root用户登录,运行以下命令:

wget -N --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && bash bbr.sh

安装完成后,脚本会提示需要重启 VPS,输入 y 并回车后重启。

重启完成后,进入 VPS,验证一下是否成功安装最新内核并开启 TCP BBR,输入以下命令:

uname -r
# 查看内核版本,含有 4.9.0 就表示 OK 了
# ————————————
sysctl net.ipv4.tcp_available_congestion_control
# 返回值一般为:
# net.ipv4.tcp_available_congestion_control = bbr cubic reno
# ————————————
sysctl net.ipv4.tcp_congestion_control
# 返回值一般为:
# net.ipv4.tcp_congestion_control = bbr
# ————————————
sysctl net.core.default_qdisc
# 返回值一般为:
# net.core.default_qdisc = fq
# ————————————
lsmod | grep bbr
# 返回值有 tcp_bbr 模块即说明bbr已启动。

参考链接

更新日志

2017 年 01 月 13 日

1.更新 内核为 4.9.3。

2017 年 01 月 09 日

1.更新 内核为 4.9.1。

centos和ubuntu安装卸载软件(rpm/dpkg)

使用Linux系统,无论是Centos/RHEL/Fedoar系列还是Ubuntu/debian系列,都有独立的包管理体系,在Centos系列,使用rpm包进行软件安装配置管理,在Ubuntu系列,使用deb包进行软件安装配置管理

CentOS:

centos使用yum做自动化包管理,包格式为rpm包,常用命令有:

yum search xxx
yum install xxx
yum groupinstall  "xxx" //以组形式安装软件包组合

直接安装rpm

rpm -ivh xxx.rpm --force (--force表示强制安装)

直接卸载rpm

rpm -e xxx.rpm

查看包内容:

rpm -l xxx.rpm

查看一个文件在哪个rpm包:

rpm -f 文件名

查看系统安装哪些rpm

rpm -qa

Ubuntu:

Ubuntu使用apt做自动化包管理,包格式为deb,常用命令有:

apt-cache search xxx
apt-get install xxx
apt-get remote xxx

直接安装deb包:

dpkg -i xxx.deb

列出包关联:

dpkg -L xxx.deb

显示包版本

dpkg -l xxx.deb

查看系统安装哪些deb包

dpkg -l

卸载包

dpkg -P xxx   //全部卸载,  dpkg -r xxx 只卸载软件,保留配置

显示包信息

dpkg -s xxx

显示包文件

dpkg -L ovmf 
dpkg -c xxx.deb
dpkg-deb -c xxx.deb

查看一个文件在哪个deb包:

dpkg -S 文件

JDK的安装[Centos]

##JDK

给所有用户添加可执行权限

chmod +x jdk-****.rpm

或者直接放掉所有权限

chmod 777 jdk-****.rpm

开始安装程序

rpm -ivh jdk-8u45-linux-x64.rpm

配置环境变量

vi /etc/profile  
export JAVA_HOME=/usr/java/jdk1.*.*_**
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

保存设置并生效

source /etc/profile

例:

jdk-8u131-linux-x64.rpm 我们从Oracle的官网下载了JDK1.8的安装包,我们安装它  

推荐使用

yum localinstall jdk-8u131-linux-x64.rpm

也可以

rpm -ivh jdk-8u131-linux-x64.rpm

这样安装完成之后可以不用修改环境变量

如何测试?

  • 执行 java -version 查看JDK版本
  • 执行 java 测试java命令是否好用和支持的参数列表
  • 执行 javac 测试java编译器是否好用

CentOS 更新 yum 源

设置yum源

将yum源设置为国内yum源,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。 国内源:可以使用wget获取或者直接下载

1.网易:

2.中科大的yum源:

3.sohu的yum源:

安装步骤

1.首先备份CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载对应版本的CentOS-Base.repo, 放入/etc/yum.repos.d/ (可以直接cd /etc/yum.repos.d/ 然后使用wget下载)

3.运行以下命令生成缓存

yum clean all
yum makecache

CentOS安装GraphicsMagick

安装相关依赖

yum install -y gcc libpng libjpeg libpng-devel libjpeg-devel ghostscript libtiff libtiff-devel freetype freetype-devel

下载并解压

wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/1.3/GraphicsMagick-1.3.29.tar.gz
tar -zxvf GraphicsMagick-1.3.29.tar.gz

编译并安装

cd /usr/local/GraphicsMagick-1.3.29
./configure --prefix=/usr/local/GraphicsMagick-1.3.29
make
make install

设置环境变量

echo 'PATH=$PATH:$GMAGICK_HOME/bin' > /etc/profile.d/graphicsmagick.sh && source /etc/profile

检查是否安装成功

gm version

查看支持的图片列表

gm convert -list formats

CentOS的System V init启动脚本

CentOS系统本身自带了说明,在/usr/share/doc/initscripts-(*)/sysvinitfiles,内容如下:

所有System V init脚本都命名为/etc/rc.d/init.d/,其中是服务的名称。必须没有“.init”后缀。

示例脚本:

#!/bin/bash
#
# /etc/rc.d/init.d/<servicename>
#
# <description of the *service*>
# <any general comments about this init script>
#
# <tags -- see below for tag definitions. *Every line* from the top
# of the file to the end of the tags section must begin with a #
# character. After the tags section, there should be a blank line.
# This keeps normal comments in the rest of the file from being
# mistaken for tags, should they happen to fit the pattern.>

# Source function library.
. /etc/rc.d/init.d/functions

<define any local shell functions used by the code that follows>

case "$1" in
    start)
        echo -n "Starting <servicename> services: "
        <start daemons, perhaps with the daemon function>
        touch /var/lock/subsys/<servicename>
    ;;
    stop)
        echo -n "Shutting down <servicename> services: "
        <stop daemons, perhaps with the killproc function>
        rm -f /var/lock/subsys/<servicename>
    ;;
    status)
        <report the status of the daemons in free-form format,
        perhaps with the status function>
    ;;
    restart)
        <restart the daemons, normally with $0 stop; $0 start>
    ;;
    reload)
        <cause the service configuration to be reread, either with
        kill -HUP or by restarting the daemons, possibly with
        $0 stop; $0 start>
    ;;
    probe)
        <optional. If it exists, then it should determine whether
        or not the service needs to be restarted or reloaded (or
        whatever) in order to activate any changes in the configuration
        scripts. It should print out a list of commands to give to
        $0; see the description under the probe tag below.>
    ;;
    *)
        echo "Usage: <servicename> {start|stop|status|reload|restart[|probe]"
        exit 1
    ;;
esac

注意:重启和重载功能可以(通常)组合成一个测试,vis:

restart|reload)

不禁止您添加其他命令; 列出您打算以交互方式使用到使用消息的所有命令。

/etc/rc.d/init.d/functions函数

daemon [+/-nicelevel] program [arguments] [&]

如果守护程序尚未运行,则启动该守护程序。还有其他一些有用的东西,例如,如果守护进程意外终止,则保留守护进程。

killproc program [signal]

向程序发送信号; 默认情况下,它发送一个SIGTERM,如果进程没有死,它会在几秒钟后发送一个SIGKILL。

如果找到pid文件,它还会尝试删除它。

pidofproc program

试图找到一个程序的pid; 检查可能的pidfiles,使用pidof程序,甚至使用ps。主要用于此文件中的其他函数,但也可用于脚本。

status program

打印状态信息。假设程序名称与servicename相同。

Tags.

# chkconfig: <startlevellist> <startpriority> <endpriority>

必须。是默认情况下应启动服务的级别列表。和是优先级编号。例如:

# chkconfig:2345 20 80有关详细信息,请阅读“man chkconfig”。

除非有一个非常好的,显性相反的原因,应该等于 100 –

# description: <multi-line description of service>

必须。几行描述,继续使用’’字符。以下行中的初始注释和后续空格将被忽略。

# description[ln]: <multi-line description of service in the language  # ln, whatever that is>

可选。应将描述翻译成指定的语言。

# processname:

可选,允许多个条目。对于脚本启动的每个进程名称,应该有一个进程名称条目。例如,samba服务启动两个守护进程:

  #processname:smdb 
  #processname:nmdb

# config:

可选,允许多个条目。对于守护程序使用的每个静态配置文件,请使用单个条目。例如:

  # config: /etc/httpd/conf/httpd.conf
  # config: /etc/httpd/conf/srm.conf

(可选)如果服务器将自动重新加载配置文件(如果已更改),则可以在行中附加“autoreload”一词:

  # config: /etc/foobar.conf autoreload

#pidfile:

可选,允许多个条目。使用就像配置条目一样,除了它指向pidfiles。假设pidfiles仅在进程创建时更新,而不是更晚。该文件的第一行应该是PID的ASCII表示; 终止换行符是可选的。不检查除第一行以外的任何行。

#project: true

可选,使用IN PLACE的processname,config和pidfile。如果存在,则可以通过运行以下命令来实现正确的重新加载 – 如果必要的循环:

command = $(/ etc / rd.d / init.d / SCRIPT probe)
[ -  n“$ command”] && /etc/rc.d/init.d/SCRIPT $ command

其中SCRIPT是服务的sysv init脚本的名称。

作为示例,需要执行复杂处理的脚本可以返回“run /var/tmp/<servicename.probe.$$”并实现“run”命令,该命令将执行命名脚本然后将其删除。

请注意,如果不需要执行任何操作使服务与其配置文件同步,则probe命令应该只是“exit 0”。

需要注意以下几点:

1、# chkconfig和# description不能少,必须写。

2、chkconfig的 为启动优先级,在man中查询不到,一般end…不用理解,直接100-start…即可。start为开始的顺序,一般系统从小执行到大,数值任意,这个对于依赖启动有很大的帮助,比如控制先启动某个服务,再启动某个服务。以下是查询设置后的命令:

# 查询启动级别
chkconfig --list <servicename>
# 查询启动顺序
grep chkconfig /etc/rc.d/init.d/<servicenaem>

Redis的概述、搭建及简单使用(基于CentOS)

1. 概述

   

Redis 简介

Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库。

Redis 与其他 key – value 缓存产品有以下三个特点:

  • Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。
  • Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。
  • Redis支持数据的备份,即master-slave模式的数据备份。

Redis 优势

  • 性能极高 – Redis能读的速度是110000次/s,写的速度是81000次/s 。
    丰富的数据类型 – Redis支持二进制案例的 Strings, Lists, Hashes, Sets 及 Ordered Sets 数据类型操作。
  • 原子 – Redis的所有操作都是原子性的,意思就是要么成功执行要么失败完全不执行。单个操作是原子性的。多个操作也支持事务,即原子性,通过MULTI和EXEC指令包起来。
  • 丰富的特性 – Redis还支持 publish/subscribe, 通知, key 过期等等特性。

Redis与其他key-value存储有什么不同?

  • Redis有着更为复杂的数据结构并且提供对他们的原子性操作,这是一个不同于其他数据库的进化路径。Redis的数据类型都是基于基本数据结构的同时对程序员透明,无需进行额外的抽象。

  • Redis运行在内存中但是可以持久化到磁盘,所以在对不同数据集进行高速读写时需要权衡内存,因为数据量不能大于硬件内存。在内存数据库方面的另一个优点是,相比在磁盘上相同的复杂的数据结构,在内存中操作起来非常简单,这样Redis可以做很多内部复杂性很强的事情。同时,在磁盘格式方面他们是紧凑的以追加的方式产生的,因为他们并不需要进行随机访问。

2. 搭建

(1)获取想要版本的下载地址(可直接去官网查询想要的版本,右击复制地址) 

http://download.redis.io/releases/redis-4.0.12.tar.gz

(2)进入对应目录,执行下载命令

[root@ezreal thirdparty]# wget http://download.redis.io/releases/redis-4.0.12.tar.gz

未分类

(3)当前文件夹下解压 

[root@ezreal redis]# tar -zxvf redis-4.0.12.tar.gz 

(4)进入解压后的文件夹并make

[root@ezreal redis]# cd redis-4.0.12

[root@ezreal redis-4.0.12]# make

(5)启动

[root@ezreal redis-4.0.12]# cd src/

[root@ezreal src]# ./redis-server 

未分类

3. 简单使用 

(1) 配置后台启动

a) 编辑redis.conf文件 打开守护进程(文件位置在根目录下)

未分类

(2) 启动redis并应用redis.conf配置文件

[root@ezreal src]# ./redis-server ../redis.conf

未分类

(3) 打开客户端并进行简单测试

[root@ezreal src]# ./redis-cli 
127.0.0.1:6379> hset testkey testfiled testvalue
(integer) 1
127.0.0.1:6379> hget testkey testfiled
"testvalue"
127.0.0.1:6379> 

本篇到此结束,嘿嘿嘿嘿嘿嘿嘿!