lighttpd+php+mysql 安装教程

   |    2016年2月24日  |   PHP, 数据库, 编程语言  |    0 条评论  |    6742

1、安装 lighttpd

sudo -i
apt-get install lighttpd
/etc/init.d/lighttpd restart

可能会出现以下错误:

perl: warning: Falling back to the standard locale (“C”).
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = “en_US:”,
LC_ALL = (unset),
LC_CTYPE = “zh_CN.UTF-8”,
LANG = “en_US.UTF-8”
are supported and installed on your system.

这个时候需要安装中文包,执行 apt-get install language-pack-zh-hans ,安装后再重启 lighttpd,即执行 /etc/init.d/lighttpd restart;

2、安装 php

执行 apt-get install php5 php5-cgi php5-curl

3、安装 mysql

apt-get install mysql-server-5.6
apt-get install mysql-client-5.6

4、安装 phpMyAdmin

apt-get install phpmyadmin

可能会出现错误:

Err http://security.ubuntu.com/ubuntu/ trusty-security/main libtiff5 amd64 4.0.3-7ubuntu0.1
404  Not Found [IP: 91.189.92.201 80]

Get:25 http://mirrors.aliyun.com/ubuntu/ trusty/universe libjs-codemirror all 2.23-1 [210 kB]
Get:26 http://mirrors.aliyun.com/ubuntu/ trusty/universe phpmyadmin all 4:4.0.10-1 [4,224 kB]
Fetched 7,840 kB in 3s (2,361 kB/s)
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/t/tiff/libtiff5_4.0.3-7ubuntu0.1_amd64.deb  404  Not Found [IP: 91.189.92.201 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?

这时只需执行下

apt-get update
apt-get install phpmyadmin

 

5、运行 php 文件

在根目录 /var/www 下新建一个 php 文件,conf.php,输入 

<?php

phpinfo();

?>

在浏览器中运行 127.0.0.1/info.php,可能出现 403 错误,原因是 lighttpd 没有加载到 cgi 服务,需要修改配置文件:

  • vim /etc/lighttpd/lighttpd.conf,在底部加上 include “conf-available/10-fastcgi.conf” ,保存关闭;
  • vim /etc/lighttpd/conf-available/10-fastcgi.conf,在底部加上

fastcgi.server = ( “.php” => ((

                     “bin-path” => “/usr/bin/php-cgi”,

                     “socket” => “/tmp/php.socket”,

                     “max-procs” => 2,

                     “bin-environment” => (

                       “PHP_FCGI_CHILDREN” => “16”,

                       “PHP_FCGI_MAX_REQUESTS” => “10000”

                     ),

                     “bin-copy-environment” => (

                       “PATH”, “SHELL”, “USER”

                     ),

                     “broken-scriptfilename” => “enable”

                 )))

  • 重启 lighttpd ;

特别说明:

  1. /etc/lighttpd/lighttpd.conf 默认未开启 rewrite 模块;
  2. 使用 phpMyAdmin,需要执行 sudo ln -s /usr/share/phpmyadmin /var/www
回复 取消