在使用Haphost提供的128M內存的VPS建站時,debian7+wordpress+nginx+mysql跑起來至關吃力。而後使用Debian7+typecho+lighttpd+sqlite的搭配好,發現效果特別好,在此記錄下搭建和優化過程。javascript
1.debian 7 32位系統的優化php
刪除建站用不到的軟件並清理緩存css
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
更新源列表和軟件html
apt-get -y update&&apt-get -y upgrade
重啓並繼續下一步java
2.安裝Lighttpd、PHP、SQLite組件並配置python
安裝軟件mysql
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
配置PHPnginx
vim /etc/php5/cgi/php.ini
查找cgi.fix_pathinfo,去掉註釋sql
新建www組www用戶管理lighttpd運行shell
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
去域名服務商配置本身的域名解析
訪問本身的網站並設置
搞定!