• 128M小内存VPS优化与typecho环境搭建


    在使用Haphost提供的128M内存的VPS建站时,debian7+wordpress+nginx+mysql跑起来相当吃力。然后使用Debian7+typecho+lighttpd+sqlite的搭配好,发现效果特别好,在此记录下搭建和优化过程。

    1.debian 7 32位系统的优化

      删除建站用不到的软件并清理缓存

    apt-get -y purge apache2-* bind9-* xinetd samba-* nscd-* portmap sendmail-* sasl2-bin lynx memtester unixodbc python-* odbcinst-* sudo tcpdump ttf-*
    apt-get autoremove && apt-get clean 

      更新源列表和软件

    apt-get -y update&&apt-get -y upgrade

      重启并继续下一步

    2.安装Lighttpd、PHP、SQLite组件并配置

      安装软件

    apt-get -y install lighttpd sqlite php5-cgi php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

      配置PHP

    vim /etc/php5/cgi/php.ini

      查找cgi.fix_pathinfo,去掉注释

      新建www组www用户管理lighttpd运行

    useradd -d /home/wwwroot -m -s /bin/bash www

      创建网站默认目录

    mkdir -p /home/wwwroot/default/public

      修改网站目录和日志目录所有权

    chown -R www:www /home/wwwroot/
    chown -R www:www /var/log/lighttpd

      配置Lighttpd

    vim /etc/lighttpd/lighttpd.conf

      改成如下内容

    server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
    "mod_rewrite",
    "mod_fastcgi",
    )
    server.document-root        = "/home/wwwroot/default/public"
    server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
    server.errorlog             = "/var/log/lighttpd/error.log"
    server.pid-file             = "/var/run/lighttpd.pid"
    server.username             = "www"
    server.groupname            = "www"
    index-file.names            = ( "index.php", "index.html",
    "index.htm", "default.htm",
    " index.lighttpd.html" )
    url.access-deny             = ( "~", ".inc" )
    static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
    include_shell "/usr/share/lighttpd/use-ipv6.pl"
    dir-listing.encoding        = "utf-8"
    server.dir-listing          = "enable"
    compress.cache-dir          = "/var/cache/lighttpd/compress/"
    compress.filetype           = ( "application/x-javascript", "text/css", "text/html", "text/plain" )
    include_shell "/usr/share/lighttpd/create-mime.assign.pl"
    include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
    fastcgi.server = ( ".php" => ((
    "bin-path" => "/usr/bin/php5-cgi",
    "socket" => "/tmp/php.socket",
    "max-procs" => 1,
    "bin-environment" => (
    "PHP_FCGI_CHILDREN" => "4",
    "PHP_FCGI_MAX_REQUESTS" => "1000"
    ),
    )))

      重启Lighttpd

    /etc/init.d/lighttpd restart

    3.添加域名并初始化typecho

      下载typecho并解压至默认目录/home/wwwroot/default/public

      修改网站目录的所有权(有新文件加入,所以要重新赋权)

    chown -R www:www /home/wwwroot/

      在Lighttpd配置中配置域名

    $HTTP["host"] =~ "(^|.)yourdomain.com.com$" {
    server.document-root = "/home/wwwroot/default/public"
    accesslog.filename = "/var/log/lighttpd/itbulu.com/access.log"
    server.error-handler-404 = "/404.html"
    }

      重启Lighttpd

    /etc/init.d/lighttpd restart

      去域名服务商配置自己的域名解析

      访问自己的网站并设置

    搞定!

  • 相关阅读:
    sed命令
    python常用库
    python标准库
    从 Python 打包到 CLI 工具
    pip
    python包自我理解
    docker常用命令
    chattr命令
    xmss
    live2d-widget.js
  • 原文地址:https://www.cnblogs.com/tswcypy/p/4437540.html
Copyright © 2020-2023  润新知