欢迎来到云服务器

服务器租用

Debian 8.2系统安装配置Nginx PHP MySQL Java Tomcat环境

剧本一键安装好之后的目次布局:

/data

    /nginx

        /html

            /phpmyadmin

            html/php文件位置

    /tomcat

        /tomcat1

        /tomcat2

    /soft

        /nginx

            nginx措施/设置文件位置

        /php

            php措施/设置文件位置

        /src

            下载的源码文件

以下除了utils.py不需要运行外,香港网存空间 北京主机,其他剧本由上到下依次运行即可

首先要举办编译情况安装

utils

# coding:utf-8
import os
__author__ = 'gavin'
def apt_install():
    os.system("apt-get -y install gcc g++ automake autoconf libtool make build-essential pkg-config")
    if not os.path.exists("/data"):
        os.mkdir("/data")
        os.mkdir("/data/soft")
        os.mkdir("/data/soft/src")
        pass
    if not os.path.exists("/data/soft"):
        os.mkdir("/data/soft")
        os.mkdir("/data/soft/src")
        pass
    if not os.path.exists("/data/soft/src"):
        os.mkdir("/data/soft/src")
if __name__ == "__main__":
    pass

mysql安装

# coding:utf-8
import os
__author__ = 'gavin'
def apt_install():
    os.system("apt-get install mysql-server  mysql-client")
    pass
def config_cha(user, passwd):
    command = '''myslq -u%s -p%s -e " SET character_set_client = utf8 ;SET character_set_connection = utf8 ;SET character_set_database = utf8 ;SET character_set_results = utf8 ;SET character_set_server = utf8 ; "''' % (
        user, passwd)
    os.system(command)
if __name__ == "__main__":
    apt_install()
    config_cha("root", "xxxx")
    pass

nginx安装

# coding:utf-8
__author__ = 'gavin'
import os
import utils
def apt_prepare():
    utils.apt_install()
    os.chdir("/data/soft/src")
    if not os.path.exists("/data/soft/src/pcre-8.38.tar.gz"):
        os.system("wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz")
    os.system("tar -zxf pcre-8.38.tar.gz")
    os.chdir("/data/soft/src/pcre-8.38")
    os.system("./configure")
    os.system("make")
    os.system("make install")
    os.chdir("/data/soft/src")
    if not os.path.exists("/data/soft/src/zlib-1.2.8.tar.gz"):
        os.system("wget http://zlib.net/zlib-1.2.8.tar.gz")
    os.system("tar -zxf zlib-1.2.8.tar.gz")
    os.chdir("/data/soft/src/zlib-1.2.8")
    os.system("./configure")
    os.system("make")
    os.system("make install")
    os.chdir("/data/soft/src")
    if not os.path.exists("/data/soft/src/openssl-1.0.1s.tar.gz"):
        os.system("wget http://www.openssl.org/source/openssl-1.0.1s.tar.gz")
    os.system("tar -zxf openssl-1.0.1s.tar.gz")
    os.chdir("/data/soft/src/openssl-1.0.1s")
    # os.system("./config --prefix=/usr/local --openssldir=/usr/local/ssl")
    os.system("./config")
    os.system("make")
    os.system("make install")
    # os.system("./config shared --prefix=/usr/local --openssldir=/usr/local/ssl")
    # os.system("make clean")
    # os.system("make")
    # os.system("make install")
    pass
def apt_install():
    os.chdir("/data/soft/src")
    if not os.path.exists("/data/soft/src/nginx-1.9.9.tar.gz"):
        os.system("wget http://nginx.org/download/nginx-1.9.9.tar.gz")
    os.system("tar -zxf nginx-1.9.9.tar.gz")
    os.chdir("/data/soft/src/nginx-1.9.9")
    os.system("./configure --sbin-path=/data/soft/nginx/nginx "
              "--prefix=/data/nginx "
              "--conf-path=/data/soft/nginx/nginx.conf "
              "--pid-path=/data/soft/nginx/nginx.pid "
              "--error-log-path=/data/soft/nginx/logs/error.log "
              "--http-log-path=/data/soft/nginx/logs/access.log "
              "--with-http_ssl_module "
              "--with-pcre=/data/soft/src/pcre-8.38 "
              "--with-zlib=/data/soft/src/zlib-1.2.8 "
              "--with-openssl=/data/soft/src/openssl-1.0.1s")
    os.system("make")
    os.system("make install")
    os.system("echo "/data/soft/nginx/nginx" >> /etc/rc.local")
    os.system("/data/soft/nginx/nginx")
    pass
def config():
    newstrs = '''
#user  nobody;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    include vhost/*.conf;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm index.php;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ .php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
}'''
    if not os.path.exists("/data/soft/nginx/nginx.conf.back"):
        os.system("cp /data/soft/nginx/nginx.conf /data/soft/nginx/nginx.conf.back")
        pass
    if not os.path.exists("/data/soft/nginx/vhost"):
        os.mkdir("/data/soft/nginx/vhost")
        pass
    fw = file("/data/soft/nginx/nginx.conf", 'w')
    fw.write(newstrs)
    fw.close()
    os.system("/data/soft/nginx/nginx -s reload")
if __name__ == "__main__":
    apt_prepare()
    apt_install()
    config()
    pass

php安装

腾讯云代理

Copyright © 2003-2021 MFISP.COM. 国外vps服务器租用 梦飞云服务器租用 版权所有 粤ICP备11019662号