http://www.lenggirl.com/code/centos7.html


layout: post
title: "一个CentOS7的开发环境部署,包括防火墙|VPN|HTTP代理服务器设置等"
date: 2016-11-03
author: hunterhug
desc: "一个CentOS7的开发环境部署,包括防火墙|VPN|HTTP代理服务器设置等。"
categories: [渣渣记录]
tags: ["运维跑路"]
permalink: "/code/centos7.html"
---

一.基础安装

先从 CentOS 下载镜像



选择中文,安装模式图形界面,标注(图形界面消耗的内存大概600M,硬盘3.7G),我的硬盘是300G,请划盘如下:

95G /home
200G /
4000 swap
250 /boot

以上/boot不可改,其他随便,可以不选swap,建议/划大一点,示例如下:



设置账号,密码,然后安装完重启登陆:


查看硬盘大小,内存大小:

free -h
df -h

二.机器网络设置

进入图形界面,请一定在图形界面里设置,然后你就可以弃用,改用命令行了。

1.时间同步

先设置时间同步:

timedatectl
timedatectl set-ntp true

2.设置网络

查看网卡状态:

ip addr 查看网卡状态

填入IP和网关:

禁掉IP6:

查看配置,命令行手工的在这里改:

cat /etc/sysconfig/network-scripts/ifcfg-eno16777728

这个时候还上不了网!请手动修改DNS(永生生效)

vim /etc/resolv.conf

修改网关!

vim /etc/sysconfig/network

主机名请改掉

3.禁掉虚拟网卡

有虚拟网卡的要先禁用虚拟网卡,可能有,为什么禁,不知道!

virsh net-list
virsh net-destroy default
virsh net-undefine default
systemctl restart libvirtd.service

三.防火墙设置

#先检查是否安装了iptables
service iptables status

#安装iptables
yum install -y iptables

#升级iptables
yum update iptables 

#安装iptables-services
yum install iptables-services

#停止firewalld服务
systemctl stop firewalld

#禁用firewalld服务
systemctl mask firewalld

#查看iptables现有规则
iptables -L -n

#先允许所有,不然有可能会杯具
iptables -P INPUT ACCEPT
#清空所有默认规则
iptables -F
#清空所有自定义规则
iptables -X
#所有计数器归0
iptables -Z
#允许来自于lo接口的数据包(本地访问)
iptables -A INPUT -i lo -j ACCEPT
#开放22端口
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#开放21端口(FTP)
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
#开放80端口(HTTP)
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
#开放5902端口(VCN)
iptables -A INPUT -p tcp --dport 5902 -j ACCEPT
#开放5901端口(VNC root)
iptables -A INPUT -p tcp --dport 5901 -j ACCEPT
#开放443端口(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
#开放3306端口(MYSQL)
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
#允许ping
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
#允许接受本机请求之后的返回数据 RELATED,是为FTP设置的
iptables -A INPUT -m state --state  RELATED,ESTABLISHED -j ACCEPT
#其他入站一律丢弃
iptables -P INPUT DROP
#所有出站一律绿灯
iptables -P OUTPUT ACCEPT
#所有转发一律丢弃
iptables -P FORWARD DROP

#保存上述规则
service iptables save

#注册iptables服务
#相当于以前的chkconfig iptables on
systemctl enable iptables.service

#开启服务
systemctl start iptables.service

#查看状态
systemctl status iptables.service

#重启
systemctl restart iptables.service

http://blog.chinaunix.net/uid-26495963-id-3279216.html

http://www.linuxso.com/linuxpeixun/10332.html

vim /etc/sysconfig/iptables

四.安装VNC虚拟主机远程连接

VNC分为服务端和客户端,linux服务器主机需要安装vncserver,centos7下一般使用tigervnc。

yum install -y tigervnc-server

安装完毕后需要配置,配置vnc-server,进入目录

cd /lib/systemd/system
ls

我们会看到有个service叫做vncserver@.service,这就是我们需要的vnc服务。但是需要对它进行配置才可以使用。假设我们当前为root用户配置远程桌面,配置流程如下:
首先,复制该service,命名为vncserver@:1.service

cp vncserver@.service vncserver@:1.service

然后修改vncserver@:1.service

vim vncserver@:1.service

这里需要且只需要做一种替换:将替换为需要配置的用户。注意因为root的home目录就是/root/,而不是/home/root/,所以替换后文本如下:

[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

好了,运行:

systemctl daemon-reload
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
systemctl status vncserver@:1.service

出错!!哈哈哈,没错,上面都是浪费的流程!

只需要:

systemctl daemon-reload
runuser -l root -c /usr/bin/vncserver 1
runuser -l smart -c /usr/bin/vncserver 2 

#开放5902端口(VCN)
iptables -A INPUT -p tcp --dport 5902 -j ACCEPT
#开放5901端口(VNC root)
iptables -A INPUT -p tcp --dport 5901 -j ACCEPT

#保存上述规则
service iptables save

#重启
systemctl restart iptables.service

五.安装开发环境

1.Python大法

yum install epel-release
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-deve

wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
tar xvf Python-3.4.3.tar.xz
mkdir /usr/local/python3
cd Python-3.4.3
./configure --prefix=/usr/local/python3
make
make install

安装好后请

vim /etc/profile.d/myenv.sh

export PATH=/usr/local/python3/bin:$PATH
export PYTHONPATH=/data/www/python/smartdo

source /etc/profile.d/myenv.sh

python3
pip3

2.MYSQL好大法

下载官方源
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server
1,进入yum源配置目录
cd /etc/yum.repos.d
2,备份系统自带的yum源
mv CentOS-Base.repo CentOS-Base.repo.bk
下载163网易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效
yum makecache
4,除了网易之外,国内还有其他不错的yum源,比如中科大和搜狐的,大家可以根据自己需求下载
中科大的yum源:
wget http://centos.ustc.edu.cn/CentOS-Base.repo
sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
授权
chown -R mysql:mysql /var/lib/mysqlc
service mysqld restart

#授权远程和改密码(123456是密码)
mysql -uroot
use mysql
update user set host = '%' where user ='root' and host="localhost";
select host, user from user;
update user set password=password('123456') where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'  IDENTIFIED BY '123456'  WITH GRANT OPTION;
flush privileges;
service mysqld restart

然后远程登陆后干掉其他东西,留下:

设置权限!!

六.VPN代理服务器

1.安装PPTP,以用来提供VPN服务.

yum install pptpd.x86_64 按tab

2.进行配置

vim /etc/pptpd.conf
localip 192.168.0.1
remoteip 192.168.0.12-238,192.168.0.245

localip是主机VPN内网地址,remoteip是连接VPN分配的内网地址

3.分配账号给自己使用.

vim /etc/ppp/chap-secrets

在里面添加账户按如下格式

hunterhug  pptpd  123456  *
hunterhug1  pptpd  123456  *

hunterhug为你的用户名,123456为你的密码,最后的*号表示允许在任意IP连接到服务

service pptpd restart

重启服务后发现还访问不了外网。然后我们需要让他能访问外网。首先,

vim /etc/ppp/pptpd-options

文件名可能为
vim /etc/ppp/options.pptpd

找到ms-dns,取消掉注释,改成你喜欢的DNS比如8.8.8.8,8.8.4.4

要开启内核IP转发

sudo vi /etc/sysctl.conf
取消掉 net.ipv4.ip_forward=1 这一行的注释. 可能找不到这一句

然后执行

sudo sysctl -p

使修改后的文件配置立即生效。

开启NAT转发.

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eno16777728 -j MASQUERADE
service iptables save
service iptables restart

192.168.0.0/24是你在上面设置的IP段,让这个段转发,注意eno16777728是你连接外网的那块网卡,这样就以NAT的方式请求外网的东西了。
不知道你的机器哪块网卡连的外网的话ifconfig一下!!

再来一次

service pptpd restart
NAT(Network Address Translation,网络地址转换)是1994年提出的。当在专用网内部的一些主机本来已经分配到了本地IP地址(即仅在本专用网内使用的专用地址),但现在又想和因特网上的主机通信(并不需要加密)时,可使用NAT方法。
这种方法需要在专用网连接到因特网的路由器上安装NAT软件。装有NAT软件的路由器叫做NAT路由器,它至少有一个有效的外部全球IP地址。这样,所有使用本地地址的主机在和外界通信时,都要在NAT路由器上将其本地地址转换成全球IP地址,才能和因特网连接。
另外,这种通过使用少量的公有IP 地址代表较多的私有IP 地址的方式,将有助于减缓可用的IP地址空间的枯竭。在RFC 1632中有对NAT的说明

如果不行的话防火墙上,全部接受,完美!!

iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P INPUT ACCEPT
service iptables save
service iptables restart

查看/etc/sysconfig/iptables,结果是这样的,这样肯定不行,求告知!!

[root@spider2 ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.21 on Fri Nov  4 10:01:51 2016
*filter
:INPUT ACCEPT [4:192]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [49:7158]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5902 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT
COMMIT
# Completed on Fri Nov  4 10:01:51 2016
# Generated by iptables-save v1.4.21 on Fri Nov  4 10:01:51 2016
*nat
:PREROUTING ACCEPT [50:2445]
:INPUT ACCEPT [16:835]
:OUTPUT ACCEPT [24:1821]
:POSTROUTING ACCEPT [24:1821]
-A POSTROUTING -s 192.168.0.0/24 -o eno16777728 -j MASQUERADE
COMMIT
# Completed on Fri Nov  4 10:01:51 2016

参考:http://www.cnblogs.com/apexchu/p/4274416.html

七.多网关和多IP配置

目前有两个IP网段,分别对应两个网关,且只有一块网卡,网卡名为eno16777984

比如

146.148.149.202-254 146.148.149.193
146.148.150.194-254 146.148.150.193

先将网段和网关绑定

一次性路由

1、使用route命令添加的路由,机器重启或者网卡重启后路由就失效了,方法:

添加到主机的路由(就是一个IP一个IP添加)

 route add –host 146.148.149.202 dev eno16777984
 route add –host 146.148.149.202 gw 146.148.149.193

添加到网络的路由(批量)

route add –net 146.148.149.0 netmask 255.255.255.0 dev eno16777984
route add –net 146.148.149.0 netmask 255.255.255.0 gw 146.148.149.193

简洁写法

route add –net 146.148.150.0/24 dev eno16777984
route add –net 146.148.150.0/24 gw 146.148.150.193

添加默认网关

route add default gw 146.148.149.193

删除主机路由:

route del –host 146.148.149.202 dev eno16777984

删除网络路由:

 route del -net 146.148.149.0 netmask 255.255.255.0
 route del -net 146.148.150.0/24

删除默认路由

route del default gw 146.148.149.193

2.永久路由

在/etc/rc.local里添加

route add default gw 146.148.149.193
route add –net 146.148.149.0 netmask 255.255.255.0 dev eno16777984
route add –net 146.148.149.0 netmask 255.255.255.0 gw 146.148.149.193
route add –net 146.148.150.0/24 dev eno16777984
route add –net 146.148.150.0/24 gw 146.148.150.193

或者在/etc/sysconfig/network里添加到末尾

GATEWAY=gw_ip  未尝试过

或者在/etc/sysconfig/static-routes:写入路由信息,如果没有这个文件自己创建 (尝试过十分好用)!(推荐!!!!!!)

any net 146.148.149.0/24 gw 146.148.149.193
any net 146.148.150.0/24 gw 146.148.150.193
any net 0.0.0.0/0 gw 146.148.149.193       # 默认路由写法,这里的子网掩码为0

创建完请这样,ifcfg-Wired_connection_1这个要自己把握

ifdown ifcfg-Wired_connection_1
ifup ifcfg-Wired_connection_1
service network restart   # 失败不要紧
[root@centos7 network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         146.148.149.193 0.0.0.0         UG    0      0        0 eno16777984
0.0.0.0         146.148.149.193 0.0.0.0         UG    100    0        0 eno16777984
146.148.149.0   0.0.0.0         255.255.255.0   U     100    0        0 eno16777984
146.148.150.0   146.148.150.193 255.255.255.0   UG    0      0        0 eno16777984
146.148.150.0   0.0.0.0         255.255.255.0   U     100    0        0 eno16777984

如果在rc.local中添加路由会造成NFS无法自动挂载问题,所以使用static-routes的方法是最好的。无论重启系统和service network restart 都会生效。

解决NFS问题的描述:
 按照linux启动的顺序,rc.local里面的内容是在linux所有服务都启动完毕,最后才被执行的,也就是说,这里面的内容是在NFS之后才被执行的,那也就是说在NFS启动的时候,服务器上的静态路由是没有被添加的,所以NFS挂载不能成功。

3.其他方法

在/etc/sysconfig/network-script/route-interface下添加路由(每个接口一个文件,如果没有就创建一个,只能添加针对该接口的路由)

格式如下:

network/prefix via gateway dev intf

例如给eno16777984添加一个默认网关:

vim /etc/sysconfig/network-scripts/route-eno16777984

#添加如下内容(可以省略dev eno16777984)
0.0.0.0/0 via 146.148.149.193 dev eno16777984

ps:注意这里的掩码是0而不是32,因为这里是网段而不是路由。保存退出后,service network restart。

查看路由

route -n

修改好后保存退出,然后重启网络:

service network restart

或者

ifdown ifcfg-Wired_connection_2 && ifup ifcfg-Wired_connection_2 && service network restart

4.多IP

如在/etc/sysconfig/network-scripts/ifcfg-eno16777984手填,网关不设置

HWADDR=00:50:56:83:7B:B0
TYPE=Ethernet
BOOTPROTO=none
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="Wired connection 2"
UUID=94ce4100-6639-4950-8d94-6cd594a2759c
ONBOOT=yes
IPADDR1=146.148.149.203
PREFIX1=24
IPADDR2=146.148.149.204
PREFIX2=24
IPADDR3=146.148.149.205
PREFIX3=24
IPADDR4=146.148.150.194
PREFIX4=24
IPADDR=146.148.149.202
PREFIX=24

#GATEWAY=

然后

ifdown ifcfg-Wired_connection_1
ifup ifcfg-Wired_connection_1

八.HTTP代理服务器

1.使用squid

#安装
yum -y install squid

# 版本
squid -v

Squid Cache: Version 3.3.8

#开机使用
chkconfig --level 35 squid on

#安装密码
yum install httpd-tools
htpasswd  -c /etc/squid/passwd username

# 一定要设置!!
chmod 777 /etc/squid/passwd 

#编辑,看后面完整
vim /etc/squid/squid.conf 

# 加上
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
#开端口
iptables -A INPUT -p tcp --dport 808 -j ACCEPT

ls /var/log/squid/

squid -z  #初始化缓存

# 启动
systemctl start squid.service

查看状态
squid -Nd1

# 停止
systemctl stop squid.service
# 重启
systemctl restart squid.service

出错!!

#按提示操作
journalctl -xe

如果只是用squid做代理,不想缓存所有网站文件的话,可以修改squid配置,no-store选项指示Squid继续从cache_dir读取文件,但不往里面写新目标。它在squid.conf文件里看起来如下:

将squid.conf里的cache_dir ufs /home/cache 1024 16 256改为

cache_dir ufs /home/cache 1024 16 256 no-store
cache deny all

保存 然后,检查一下,有没有语法错误:

#squid -k parse
#squid -k reconfigure

访问显示


    User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate
    Upgrade-Insecure-Requests: 1
    Host: ip.42.pl
    Via: 1.1 spider2 (squid/3.3.8)
    X-Forwarded-For: 116.21.24.161
    Cache-Control: max-age=259200
    Connection: keep-alive

去掉真实IP

via off
forwarded_for off
follow_x_forwarded_for deny all
request_header_access X-Forwarded-For deny all
header_access X_Forwarded_For deny all

爆 Could not determine this machines public hostname. Please configure one or set 'visible_hostname'

配置加上
visible_hostname hunterhug

完整配置:

#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
#http_access allow localhost

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 100 16 256 no-store
cache deny all
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated

# Squid normally listens to port 3128
http_port 808

# And finally deny all other access to this proxy
http_access deny all
via off
forwarded_for off
follow_x_forwarded_for deny all
request_header_access X-Forwarded-For deny all
#header_access X_Forwarded_For deny all
visible_hostname hunterhug

http://blog.csdn.net/mingzznet/article/details/52921218

2.多IP squid设置!

http://zyan.cc/book/squid/

参考谷歌!!!

https://itechnology.wordpress.com/2008/05/26/setup-squid-proxy-server-to-use-multiple-outgoing-ip-addresses/

A friend of mine needed my help to configure squid server to use multiple IP addresses based on the squid’s IP being used as proxy server. I told him that he can configure the squid server using following squid acls and tcp_outgoing_address directives.

acl ip1 myip 192.168.1.2
acl ip2 myip 192.168.1.3
acl ip3 myip 192.168.1.4
tcp_outgoing_address 192.168.1.2 ip1
tcp_outgoing_address 192.168.1.3 ip2
tcp_outgoing_address 192.168.1.4 ip3

The acl lines tell squid to match myip which means if someone uses the IP 192.168.1.2 as their proxy server they will match the acl ip1 and so on..

Update: But his problem was not solved by this, because he had to configure squid for 500+ IPs and doing this by hand is not worth it when you have so many languages out there. So I wrote a small perl script for him to generate squid acl and tcp_outgoing_address directives for all IPs.

我编了一个程序来实现....hahha,注意myip已经改为localip

所以

九.附送

1.清除历史

清除登陆系统成功的记录
[root@localhost root]# echo > /var/log/wtmp //此文件默认打开时乱码,可查到ip等信息
[root@localhost root]# last //此时即查不到用户登录信息

清除登陆系统失败的记录
[root@localhost root]# echo > /var/log/btmp //此文件默认打开时乱码,可查到登陆失败信息
[root@localhost root]# lastb //查不到登陆失败信息

清除历史执行命令
[root@localhost root]# history -c //清空历史执行命令
[root@localhost root]# echo > ./.bash_history //或清空用户目录下的这个文件即可

导入空历史记录
[root@localhost root]# vi /root/history //新建记录文件
[root@localhost root]# history -c //清除记录
[root@localhost root]# history -r /root/history.txt //导入记录
[root@localhost root]# history //查询导入结果

example
[root@localhost root]# vi /root/history
[root@localhost root]# history -c
[root@localhost root]# history -r /root/history.txt
[root@localhost root]# history
[root@localhost root]# echo > /var/log/wtmp
[root@localhost root]# last
[root@localhost root]# echo > /var/log/btmp
[root@localhost root]# lastb
[root@localhost root]# history -c
[root@localhost root]# echo > ./.bash_history
[root@localhost root]# history
echo > /var/log/wtmp    #清除用户登录记录和命令记录
echo > /var/log/btmp
echo > .bash_history
history -c

2.扩大linux的文件描述符

一,通过ulimit命令修改

//显示当前文件描述符
ulimit -n

//修改当前用户环境下的文件描述符为65536
ulimit -HSn 65536

echo "ulimit -HSn 65536" >> /etcrc.local

使用ulimit命令的缺点:

1,只能修改当前登录用户环境下的文件描述符,如果此用户来另外打开一个连接,此链接环境的文件描述符依然是没改前的
2,如果系统重启,以前修改都不再生效

二,通过修改limits.conf文件

编辑/etc/security/limits.conf 文件,在最后加入如下两行

*  soft    nofile  65536
*  hard    nofile  65536

保存退出,都不需要重启服务器,直接重新登陆用ulimit -n就能看到效果

这样无论使用哪个用户,无论是否重启都不会失效了。

扩大linux的文件描述符后,再重新编译安装squid,安装完成后,重新启用此代理,发现连接数马上就上来了

3.替换文本字符串

http://www.cnblogs.com/emanlee/archive/2013/09/07/3307642.html

sed -i 's/myip/localip/g' /etc/squid/squid.conf     将source替换成OKSTR

一个CentOS7的开发环境部署,包括防火墙|VPN|多IP多网关|HTTP代理服务器设置等的更多相关文章

  1. Linux——Django 开发环境部署(二)python版本控制器pyenv

    python版本控制器pyenv 之前的 那篇是说明了django环境的site package完全独立出来了,但是使用的python解释器还是系统的,为了继续独立出来,甚至是达到ruby的rvm的自 ...

  2. 西秦的ACE-Python教程 一、Python本地开发环境部署

    西秦的ACE-Python教程 一.Python本地开发环境部署       西秦 级别: 论坛版主 发帖 1357 云币 2782 加关注 写私信   只看楼主 更多操作楼主  发表于: 10-10 ...

  3. 【J2EE】struts-2.3.16.3+apache-tomcat-8.0.9开发环境部署,“Hello World”的实现。

    1.在官网下载Struts2的开发包 下载链接如下: http://120.203.229.30/5ff/2bc79/5ff16ae8698e1c321758a8f03a1bc0939892bc79/ ...

  4. Electron开发环境部署

    Electron开发环境部署 安装node.js 可以从node.js官方网站上获取安装包,并进行安装,安装完可以通过 ndoe -v 指令进行版本查看. 本文的开发环境为node.js 4.4.5. ...

  5. Cocos发展Visual Studio下一个libcurl图书馆开发环境的搭建

    我们解释win32在Visual Studio下一个libcurl图书馆开发环境的搭建.Cocos2d-x发动机实际上与Win32在访问libcurl库.Cocos2d-x 3.x在libcurl库文 ...

  6. 搭建centos7的开发环境3-Spark安装配置

    说起大数据开发,必然就会提到Spark,在这片博文中,我们就介绍一下Spark的安装和配置. 这是Centos7开发环境系列的第三篇,本篇的安装会基于之前的配置进行,有需要的请回复搭建centos7的 ...

  7. Laravel 的 Homestead 开发环境部署

    ---恢复内容开始--- Laravel 努力在整个PHP开发过程中提供令人愉快的开发体验,当然也包括本地的开发环境. 首先明白以下几个概念 VirtualBox -- Oracle 公司的虚拟机软件 ...

  8. eclipse+hbase开发环境部署

    一.前言 1. 前提 因为hbase的运行模式是伪分布式,需要用到hdfs,所以在此之前,我已经完成了hadoop-eclipse的开发环境搭建,详细看另一篇文章:hadoop开发环境部署——通过ec ...

  9. # centos7下FFmpeg环境部署记录

    # centos7下FFmpeg环境部署记录 随着视频在网站上的应用越来越多,越来越多的网站服务器需要支持视频转码,视频压缩,FFmpeg是目前最好用的网站服务器后台转码程序,应用最多.FFmpeg是 ...

随机推荐

  1. mysql bin-log和innodb_log的关系

    首先,二进制日志会记录所有与MySQL数据库有关的日志记录,包括InnoDB.MyISAM.Heap(memory除外)等其他存储引擎的日志.而InnoDB存储引擎的重做日志记录有关该引擎本身的事务日 ...

  2. 将HTML5封装成android应用APK文件的几种方法(转)

    作为下一代的网页语言,HTML5拥有很多让人期待已久的新特性.HTML5的优势之一在于能够实现跨平台游戏编码移植,现在已经有很多公司在移动 设备上使用HTML5技术.随着HTML5跨平台支持的不断增强 ...

  3. Windows Azure 上传 VM

    One of the great features of Windows Azure is VHD mobility. Simply put it means you can upload and d ...

  4. Atitit. Atiposter 发帖机 新特性 poster new feature   v7 q39

    Atitit. Atiposter 发帖机 新特性 poster new feature   v7 q39 V1  初步实现sina csdn cnblogs V2  实现qzone sohu 的发帖 ...

  5. SharePoint 页面中添加.Net代码

    今天整理资料,看到一个非常有意思的截图,可以在SharePoint页面库里的页面中,添加.Net代码,只需修改一下相应应用程序的web.config文件,即可: 在web.config里面的<P ...

  6. 实验12:Problem E: 还会用继承吗?

    Home Web Board ProblemSet Standing Status Statistics   Problem E: 还会用继承吗? Problem E: 还会用继承吗? Time Li ...

  7. Android--Apache HttpClient

    前言 上一篇文章介绍了使用HttpURLConnection来完成对于HTTP协议的支持.现在介绍一个新的方式来访问Web站点,那就是HttpClient. HttpClient是Apache开源组织 ...

  8. iOS设计模式之策略模式

    策略模式(Strategy) 基本理解 面向对象的编程,并不是类越多越好,类的划分是为了封装,但分类的基础是抽象,具有相同属性和功能的对象的抽象集合才是类. 策略模式:它定义了算法家族,分别封装起来, ...

  9. CSS 指定选择器(十一)

    一.指定选择器 有时个会希望控制某个元素在一定范围内的对象样式,这时就可以把元素与Class或者Id选择器结合起来使用 <!DOCTYPE html PUBLIC "-//W3C//D ...

  10. iOS项目上传到AppStore步骤流程

    1.登录developer.apple.com 2.点击member center后 进下图 3.点击certificates Identifiers进下图 4.点击Certificates进下图,首 ...