1.系统选择
众所周知,Debian是Linux系统中做Web服务器比较稳定的发行版。由于Debian 6(squeeze)已经停止支持,而搬瓦工上的Debian 8又是全64位系统,所以我们选用Debian 7系统。Debian Long Term Support
Debian 6 “Squeeze” until 29th of February 2016
Debian 7 “Wheezy” from 26th of April 2016 to 31st of May 2018
2.安装系统
先在搬瓦工管理后台KiwiVM面板左侧的Main Controls里面使用Stop按钮停止服务器。然后选择Install new OS,选择debian-7.0-x86-minimal,在I agree that all existing data on my VPS will be lost.前面打勾,点击Reload重装系统。
重装系统后会生成新的SSH端口号和root账户密码。要记录下来方便SSH远程管理。
3.升级系统
系统安装完成后要先升级系统,先更新软件包信息:
Bash
apt-get update
运行此命令时可能会出现以下出错信息:There is no public key available for the following key ids ****运行以下命令解决这个问题:
Bash
apt-get install debian-archive-keyring
apt-key update
4.安装Lighttpd/SQLite/PHP
4.1.安装Lighttpd
Bash
apt-get install lighttpd
4.2.安装SQLite
Bash
apt-get install sqlite
4.3.安装php5
Bash
apt-get install 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
4.4.修改php配置文件
Bash
vi /etc/php5/cgi/php.ini
查找cgi.fix_pathinfo,将其值改为1:
PHP
cgi.fix_pathinfo=1
4.5.配置lighttpd
Bash
vi /etc/lighttpd/lighttpd.conf
更改文件内容为:
Bash
server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_rewrite",
"mod_fastcgi",
)
server.document-root = "/var/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "www-data"
server.groupname = "www-data"
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使配置生效:
Bash
/etc/init.d/lighttpd restart
5.功能测试
使用phpinfo检测:
Bash
vi /var/www/phpinfo.php
输入以下内容:
PHP
<?php
phpinfo();
?>
然后可以通过IP地址访问此页面:http://11.22.33.44/phpinfo.php
6.安装Z-Blog
6.1.在主目录下载Z-Blog文件
Bash
cd ~
wget https://github.com/zblogcn/Release/raw/master/zip/Z-BlogPHP_1_4_Deeplue_150101.zip
下载完成后用unzip命令解压发现命令不存在……先安装unzip:
Bash
apt-get install unzip
然后解压备用:
Bash
unzip Z-BlogPHP_1_4_Deeplue_150101.zip
解压后Blog程序在/root/Release文件夹。6.2.创建站点目录
Bash
mkdir -p /home/wwwroot/blog
在home/wwwroot创建站点,并根据站点内容创建子目录,如果以后进行多站点管理可以清除的知道站点目录。6.3.修改站点环境连接
Bash
vi /etc/lighttpd/lighttpd.conf
在最后一行添加:
Bash
$HTTP["host"] =~ "(^|\.)localhost\.localdomain$" {
server.document-root = "/home/wwwroot/blog"
accesslog.filename = "/var/log/lighttpd/blog/access.log"
server.error-handler-404 = "/404.html"
}
根据自己的域名修改localhost和localdomain。重启lighttpd使配置生效:
Bash
/etc/init.d/lighttpd restart
6.4.站点安装
将刚才下载解压好的程序文件放到/home/wwwroot/blog/目录下:
Bash
cp -R ~/Release/ /home/wwwroot/blog/
为了防止运行出错,需要修改文件夹权限:
Bash
chown -R www-data:www-data /home/wwwroot
用IP地址(或者已经绑定好的域名)直接打开:http://11.22.33.44/根据安装向导安装即可。
没有评论:
发表评论