ubuntu lnmp&pptp一键安装脚本

在ubuntu12.04下测试通过;

原始脚本见来源,修改了nginx配置,增加了pptp的设置;
#!/bin/sh
#coding=utf-8

#修改软件包的源
echo 'deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted' > /etc/apt/sources.list

#更新源
apt-get update
apt-get -y install dos2unix screen lrzsz

#安装nginx
apt-get -y install nginx

#php环境搭建
apt-get -y install php5-cli php5-cgi php5-fpm php5-mcrypt php5-mysql
apt-get -y install mysql-server
apt-get -y install php5-common php5-dev php-apc php5-curl php5-gd php5-idn php-pear php5-memcache php5-ming php5-recode php5-tidy php5-xmlrpc php5-xsl
apt-get -y install git bash-completion

#重启nginx php5-fpm
/etc/init.d/php5-fpm restart
/etc/init.d/nginx restrat

apt-get -y install phpmyadmin
mkdir -p /web/www 2>/dev/null
ln -s /usr/share/phpmyadmin /web/www 2>/dev/null
cd /web
mkdir logs 2>/dev/null
mkdir gits 2>/dev/null

#php测试文件
cd /web/www
touch index.php
echo '<?php phpinfo() ?>' > index.php

#配置vim
cd
touch .vimrc
echo 'set nu' > .vimrc
echo '**********nginx************'
cd /etc/nginx
cat >nginx.conf <<EOF
#nginx config create at `date`
user www-data;

worker_processes 4;

pid /var/run/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;

events
{
use epoll;
worker_connections 768;
}

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

#charset gb2312;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

#limit_zone crawler $binary_remote_addr 10m;

log_format access '$remote_addr - [$time_local] - "Host:$host" "Req:$request" "$upstream_addr"'
' "status:$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$http_content_length"';

access_log /web/logs/access.log access;
error_log /web/logs/error.log ;

include /etc/nginx/vhosts.d/*.conf;
}

EOF

mkdir vhosts.d 2>/dev/null
cd vhosts.d
cat >default.conf <<EOF
server
{
listen 80;
server_name 127.0.0.1;
index index.html index.htm index.php;
root /web/www/;

location ~ .*.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*.(js|css)?$
{
expires 1h;
}

}
EOF

cd -
/etc/init.d/nginx restart
#不生成pyc
echo 'export PYTHONDONTWRITEBYTECODE=1' >> /etc/bash.bashrc
#添加显示git分支的配置
echo "export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m] $(__git_ps1 [%s])$ ' " >> ~/.bashrc

echo "install pptpd:"

apt-get -y install pptpd

mkdir /etc/install_back/ 2>/dev/null
cp /etc/pptpd.conf /etc/install_back/pptpd_`date +%s`.conf

cat >/etc/pptpd.conf <<EOF
#simple config at `date`
option /etc/ppp/pptpd-options
logwtmp

localip 172.10.0.1
remoteip 172.10.0.2-230

EOF

cp /etc/pptpd.conf /etc/install_back/chap-secrets_`date +%s`
cat >/etc/ppp/chap-secrets <<EOF
# Secrets for authentication using CHAP
# client server secret IP addresses
test pptpd qwe123 *

EOF

cp /etc/options /etc/install_back/options_`date +%s`
cat >/etc/ppp/options <<EOF
# /etc/ppp/options
asyncmap 0
noauth
crtscts
lock
hide-password
modem
lcp-echo-interval 30
lcp-echo-failure 4
noipx

#dns server
ms-dns 8.8.8.8
ms-dns 8.8.4.4

EOF

#开启ip_forward
sed -i 's/#net.ipv4.ip_forward/net.ipv4.ip_forward/g' /etc/sysctl.conf
sysctl -p

apt-get -y install iptables
iptables -t nat -A POSTROUTING -s 172.10.0.0/24 -o eth0 -j MASQUERADE
iptables-save > /etc/iptables.pptp

cat >/etc/network/if-up.d/iptables <<EOF
#!/bin/sh
#pptp iptables restore
iptables-restore < /etc/iptables.pptp

EOF
chmod a+x /etc/network/if-up.d/iptables
/etc/init.d/pptpd restart
echo "pptpd installed success. vpn user:test ,password: qwe123 "
echo "process end."

下载链接:

vps_lnmp_pptp
| 0个评论