Archive

Posts Tagged ‘centos’

alias命令别名设置

May 4th, 2016 No comments

[[email protected] ~]# alias
alias cp=’cp -i’
alias l.=’ls -d .* –color=auto’
alias ll=’ls -l –color=auto’
alias ls=’ls –color=auto’
alias mv=’mv -i’
alias rm=’rm -i’
alias which=’alias | /usr/bin/which –tty-only –read-alias –show-dot –show-tilde’

可以查看系统默认的一些命令别名设置,比如alias rm=’rm -i’,实际上我们敲rm这个命令,等同于执行rm -i这个命令,带了个i参数,可以避免误删文件。

Categories: linux基础 Tags: ,

通过ulimit命令限制用户使用某些系统资源

May 4th, 2016 No comments

[[email protected] ~]# ulimit -a
core file size (blocks, -c) 0   【0代表没限制】
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited【可创建单一文件大小,也是没限制】
pending signals (-i) 7825
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024【可以同时打开的文件数量】
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7825
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

敲个命令,设置下将可以创建的单一文件大小设置成10MB

[[email protected] ~]# ulimit -f 10240
[[email protected] ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) 10240
pending signals (-i) 7825
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7825
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

下面咱们再创建下大小为20M的文件,显示失败。

[[email protected] ~]# dd if=/dev/zero of=123 bs=1M count=20
File size limit exceeded (core dumped)

Categories: linux基础 Tags: ,

CentOS 6.x 64位搭建pptpd.v.p.n

January 15th, 2016 No comments

之前用的centos 6搭建pptpd.vpn一键包失效了。

熟悉linux基础的朋友,手动搭建下pptpd/vpn也不是很难。
服务器操作系统:CentOS 6.X 64位

服务器IP地址:45.33.55.150
一、检查服务器系统环境是否支持安装pptp/vpn
1、检查系统内核是否支持MPPE补丁

modprobe ppp-compress-18 &&echo success

显示success说明系统支持MPPE补丁,如果不支持,需要先安装kernel-devel

yum install kernel-devel

======================================

[[email protected] ~]# modprobe ppp-compress-18 &&echo success
FATAL: Module ppp_mppe not found.
[[email protected] ~]# yum install kernel-devel

Running Transaction
Installing : kernel-devel-2.6.32-573.12.1.el6.x86_64 1/1
Verifying : kernel-devel-2.6.32-573.12.1.el6.x86_64 1/1

Installed:
kernel-devel.x86_64 0:2.6.32-573.12.1.el6

Complete!

========================================
2、检查系统是否开启TUN/TAP支持

cat /dev/net/tun

如果这条指令显示结果为下面的文本,则表明通过:

cat: /dev/net/tun: File descriptor in bad state

=================================

[[email protected] ~]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state

=================================
3、检查系统是否开启ppp支持

cat /dev/ppp

如果这条指令显示结果为下面的文本,则表明通过:

cat: /dev/ppp: No such device or address

============================

[[email protected] ~]# cat /dev/ppp
cat: /dev/ppp: No such device or address

============================
上面三条必须同时满足,否则不能安装pptp/ vpn

二、安装ppp和pptpd

wget -c http://poptop.sourceforge.net/yum/stable/packages/ppp-2.4.5-33.0.rhel6.x86_64.rpm

wget -c http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.4.0-1.el6.x86_64.rpm

rpm -ivh ppp-2.4.5-33.0.rhel6.x86_64.rpm 【安装ppp】

rpm -ivh pptpd-1.4.0-1.el6.x86_64.rpm【安装pptpd】

三、配置pptpd
1、vi /etc/ppp/options.pptpd

修改默认的

#ms-dns 10.0.0.1
#ms-dns 10.0.0.2

变成:

ms-dns 8.8.8.8 #添加主DNS服务器地址
ms-dns 8.8.4.4 #添加备DNS服务器地址
2、vi /etc/ppp/chap-secrets #设置pptp拨号用户和密码(可以设置多个用户,每行一个)

# Secrets for authentication using CHAP
# client server secret IP addresses
laoyi2 pptpd laoyi2 *
格式:用户名 pptpd 密码 *

其中*表示为客户端自动分配IP地址

3、vi /etc/pptpd.conf #设置pptp服务器IP地址,设置vpn拨入客户端ip地址池

默认是
#localip 192.168.0.1
#remoteip 192.168.0.234-238,192.168.0.245
修改成
localip 192.168.11.1 #设置pptp虚拟拨号服务器IP地址(注意:不是服务器本身的IP地址)

remoteip 192.168.11.2-254 #为拨入vpn的用户动态分配192.168.11.2~192.168.11.254之间的IP地址
/sbin/service pptpd start #启动pptp

/etc/init.d/pptpd stop #关闭

service pptpd restart #重启

chkconfig pptpd on #设置开机启动

======================================

[[email protected] ~]# /sbin/service pptpd start
Starting pptpd: [ OK ]
[[email protected] ~]# /etc/init.d/pptpd stop
Shutting down pptpd: [ OK ]
[[email protected] ~]# service pptpd restart
Shutting down pptpd: [FAILED]
Starting pptpd: [ OK ]
Warning: a pptpd restart does not terminate existing
connections, so new connections may be assigned the same IP
address and cause unexpected results. Use restart-kill to
destroy existing connections during a restart.
[[email protected] ~]# chkconfig pptpd on

========================================
四、开启服务器系统路由模式,支持包转发

vi /etc/sysctl.conf #编辑

net.ipv4.ip_forward = 1 #设置为1

#net.ipv4.tcp_syncookies = 1 #注释掉

:x保存后,执行
/sbin/sysctl -p #使设置立刻生效

五、设置防火墙转发规则

yum install iptables #安装防火墙

service iptables start #启动防火墙

iptables -t nat -A POSTROUTING -s 192.168.11.0/255.255.255.0 -j SNAT --to-source 45.33.55.150 #添加规则

iptables -A FORWARD -p tcp --syn -s 192.168.11.0/255.255.255.0 -j TCPMSS --set-mss 1356 #添加规则

/etc/init.d/iptables save #保存防火墙设置

======================================

[root@li1005-150 ~]# iptables -t nat -A POSTROUTING -s 192.168.11.0/255.255.255.0 -j SNAT --to-source 45.33.55.150
[root@li1005-150 ~]# iptables -A FORWARD -p tcp --syn -s 192.168.11.0/255.255.255.0 -j TCPMSS --set-mss 1356
[root@li1005-150 ~]# /etc/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]

=======================================
六、开启pptp服务端口tcp 1723,设置vpn拨入客户端ip地址池192.168.11.0/255.255.255.0通过防火墙
vi /etc/sysconfig/iptables #编辑,添加以下代码

-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 1723 -j ACCEPT

-A RH-Firewall-1-INPUT -s 192.168.11.0/255.255.255.0 -j ACCEPT
:wq! #保存,退出

备注:

#45.33.55.150为服务器IP地址

#192.168.11.0/255.255.255.0是第三步中设置的pptp虚拟拨号服务器IP地址段

/etc/init.d/iptables restart #重启防火墙

chkconfig iptables on #设置开机启动

=======================

[[email protected] ~]# /etc/init.d/iptables restart
iptables: Setting chains to policy ACCEPT: security raw nat[FAILED]filter
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: iptables-restore: line 37 failed
[FAILED] 提示失败
===========
换个方法:

[root@li1005-150 ~]# /sbin/iptables -I INPUT -p tcp --dport 1723 -j ACCEPT
[root@li1005-150 ~]# /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@li1005-150 ~]# /etc/init.d/iptables restart
iptables: Setting chains to policy ACCEPT: security raw nat[FAILED]filter
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ],提示ok了。

============================
七、设置开机自动建立ppp设备节点(系统重新启动后有可能会丢失此文件,导致pptp客户端拨号出现错误619)

vi /etc/rc.d/rc.local #编辑

mknod /dev/ppp c 108 0 #在文件最后添加此行代码

:wq! #保存,退出

至此,CentOS下PPTP VPN服务器搭建完成,可以在Windows客户端建立VPN连接,输入服务器外网IP地址,用上面配置的账号、密码进行连接。

 

Categories: linux基础 Tags: , , ,

CentOS安装memcache的yum方法附图文介绍

November 14th, 2013 No comments

memcache1

yum search memcached
有了,可以进行安装了

Read more…

Categories: linux运维 Tags: , ,

centos下安装配置socks5

May 17th, 2013 2 comments

1、配置编译环境:

yum -y install gcc automake make

2、安装socks5必要的包

yum -y install pam-devel openldap-devel cyrus-sasl-devel

3、下载,编译安装socks5

wget http://www.linuxso.com/uploads/soft/101018/ss5-3.6.1-1.tar.gz
tar zxvf ss5-3.6.1-1.tar.gz
cd ss5-3.6.1
./configure
make
make install

4、启动ss5服务。

/etc/init.d/ss5 start

5、开机启动ss5服务。

chkconfig –add ss5

chkconfig ss5 on

6、默认使用1080端口,并允许任何人使用。

我们可以修改ss5的配置文件 /etc/opt/ss5/ss5.conf中的如下内容,进行用户认证:

cd /etc/opt/ss5

vi ss5.conf,将图示箭头地方-修改为u

ss5

ss5-permit

然后在 /etc/opt/ss5/ss5.passwd 中添加用户名和密码 如:
testuser testpw
重启ss5服务,以使修改生效:
/etc/init.d/ss5 restart

7、修改默认的端口:

vi /etc/rc.d/init.d/ss5

daemon /usr/sbin/ss5 -m -t -b IP:8833

else
/usr/local/sbin/ss5 -m -t -b IP:8833

/etc/rc.d/init.d/ss5 start

8、默认支持S4匿名可以使用取消S4,

mv /usr/lib/ss5/mod_socks4.so /usr/lib/ss5/mod_socks4.so.bk

9、查看日志:

more /var/log/ss5/ss5.log

Categories: linux基础 Tags: ,

centos6.2安装unixbench解决几个依赖关系

March 10th, 2013 No comments

wget -c http://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz

tar zxvf UnixBench5.1.3.tgz

cd UnixBench

make

./Run

今天用centos6.2安装unixbench结果发现有几个依赖包需要安装,不然无法继续。

#安装Time-HiRes
[[email protected]]# wget http://www.cpan.org/modules/by-module/Time/Time-HiRes-1.9725.tar.gz
[[email protected]]# tar zxvf Time-HiRes-1.9725.tar.gz
[[email protected]]# cd Time-HiRes-1.9725
[[email protected] Time-HiRes-1.9725]# perl Makefile.PL
[[email protected] Time-HiRes-1.9725]# make && make install
#下载依赖包
[[email protected]]$ wget http://files.directadmin.com/services/9.0/ExtUtils-MakeMaker-6.31.tar.gz
[[email protected]]$ tar zxvf ExtUtils-MakeMaker-6.31.tar.gz
#安装依赖包报错
[[email protected]]$ cd ExtUtils-MakeMaker-6.31
[[email protected] ExtUtils-MakeMaker-6.31]$ perl Makefile.PL
Checking if your kit is complete…
Looks good
Could not open ”: No such file or directory at lib/ExtUtils/MM_Unix.pm line 2697.
#yum安装依赖包
[[email protected] ExtUtils-MakeMaker-6.31]# yum install perl-ExtUtils-MakeMaker
[[email protected] ExtUtils-MakeMaker-6.31]# perl Makefile.PL
Writing Makefile for ExtUtils::MakeMaker

Categories: linux基础 Tags: ,

linode vps基于centos6搭建LAMP环境

October 17th, 2012 No comments

通常我们为了省事,直接用第三方的LNMP一键安装包,但是毕竟是第三方的,里面的设置我们不是很清楚,为此,特贡献一篇手动搭建LAMP环境。LAMP,是一个web环境的简称而已,L代表基于linux的操作系统,A代表Apache web服务器,M代表mysql数据库,P,代表PHP程序语言,当然P也可以指Python,Perl,Ruby等程序语言。

系统centos6.2,搭建LAMP环境。

1.设置主机名:

[[email protected] ~]# echo “HOSTNAME=taotaonv” >> /etc/sysconfig/network
[[email protected] ~]# hostname “taotaonv”

vi /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
106.187.54.183 test.taotaonv.me taotaonv

[[email protected] ~]# hostname
taotaonv
[[email protected] ~]# hostname -f
test.taotaonv.me

2.安装配置Apache

yum update
yum install httpd

cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup(最好将默认的配置备份一份备用)

3.配置虚拟主机:

先建立对应的文件夹:

mkdir -p /srv/www/taotaonv.me/public_html
mkdir /srv/www/taotaonv.me/logs

vi /etc/httpd/conf.d/vhost.conf(有多个站就配置多个站)

NameVirtualHost *:80

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName taotaonv.me
     ServerAlias www.taotaonv.me
     DocumentRoot /srv/www/taotaonv.me/public_html/
     ErrorLog /srv/www/taotaonv.me/logs/error.log
     CustomLog /srv/www/taotaonv.me/logs/access.log combined
</VirtualHost>

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName yqf.me
     ServerAlias www.yqf.me
     DocumentRoot /srv/www/yqf.me/public_html/
     ErrorLog /srv/www/yqf.me/logs/error.log
     CustomLog /srv/www/yqf.me/logs/access.log combined
</VirtualHost>

开启Apache:/etc/init.d/httpd start

开机自运行Apache:/sbin/chkconfig –levels 235 httpd on

修改vhost.conf文件后,重新加载apache:/etc/init.d/httpd reload

4.安装mysql及配置mysql

yum install mysql-server

开机自运行Mysql:/sbin/chkconfig –levels 235 mysqld on

启动mysql:/etc/init.d/mysqld start

配置mysql及建立数据库

mysql_secure_installation(执行此命令可以设置root密码,删除多余的数据库,增强安全性)

建立数据库:mysql -u root -p (回车后,输入刚设置的root密码)

create database lampsql;
grant all on lampsql.* to ‘taotaonv’ identified by ‘yqfv5’;

以上lampsql为数据库名,taotaonv为数据库用户名,yqfv5为对应的数据库密码。

quit离开数据库。

5.安装PHP及配置php

yum install php php-pear

配置php,编辑php.ini,vi /etc/php.ini,查询类似的参数做出相应的设置。
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php.log
max_execution_time = 300
memory_limit = 64M
register_globals = Off

需要php支持mysql,还需安装

yum install php-mysql

到此,LAMP环境已经搭建好了,深入了解可以参考如下网站:

Categories: linode入门 Tags: , , ,