$ su
1. 安装
Ubuntu
$ apt install lighttpd
$ apt install php php-pear php-mysql php7.0-fpm mysql-server
Fedora
$ dnf install lighttpd lighttpd-fastcgi
$ dnf install php php-pear php-mysqlnd php-fpm mariadb-server
CentOS
$ yum install lighttpd lighttpd-fastcgi
$ yum install php php-pear php-mysql php-fpm mariadb-server
自行编译安装
http://jasonmun.blogspot.my/2017/01/linux-lighttpd_25.html
$ zypper install lighttpd
$ zypper install php7 php7-pear php7-mysql php7-fpm mysql-community-server
$ cp /etc/php7/fpm/php-fpm.conf.default /etc/php7/fpm/php-fpm.conf
$ cp /etc/php7/fpm/php-fpm.d/www.conf.default /etc/php7/fpm/php-fpm.d/www.conf
2. 设置
$ mysql_secure_installation
2.1) PHP - 编辑 php.ini
Ubuntu
$ gedit /etc/php/7.0/fpm/php.ini
Fedora / CentOS
$ gedit /etc/php.ini
OpenSUSE
$ gedit /etc/php7/cli/php.ini
cgi.fix_pathinfo=1
2.2) Lighttpd - 编辑 fastcgi.conf / 15-fastcgi-php.conf
Ubuntu
$ cd /etc/lighttpd/conf-available
$ cp 15-fastcgi-php.conf 15-fastcgi-php-spawnfcgi.conf
$ gedit /etc/lighttpd/conf-available/15-fastcgi-php.conf
server.modules += ( "mod_fastcgi" )
fastcgi.server += ( ".php" =>
((
"socket" => "/run/php/php7.0-fpm.sock",
"broken-scriptfilename" => "enable"
))
)
$ gedit /etc/lighttpd/conf.d/fastcgi.conf
server.modules += ( "mod_fastcgi" )
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php-fpm/php-fpm.sock",
"broken-scriptfilename" => "enable"
))
)
Fedora
$ gedit /etc/lighttpd/conf.d/fastcgi.conf
server.modules += ( "mod_fastcgi" )
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php-fpm/www.sock",
"broken-scriptfilename" => "enable"
))
)
$ gedit /etc/lighttpd/conf.d/fastcgi.conf
server.modules += ( "mod_fastcgi" )
fastcgi.server += ( ".php" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable"
))
)
2.3) PHP-FPM - 编辑 www.conf (Ubuntu 可跳过)
CentOS
$ gedit /etc/php-fpm.d/www.conf
Fedora
$ cp /etc/php-fpm.d/www.conf.rpmsave /etc/php-fpm.d/www.conf
$ gedit /etc/php-fpm.d/www.conf
OpenSUSE
$ gedit /etc/php7/fpm/php-fpm.d/www.conf
; CentOS
listen = /var/run/php-fpm/php-fpm.sock
; Fedora
listen = /var/run/php-fpm/www.sock
; OpenSUSE
listen = 127.0.0.1:9000
listen.owner = nobody
listen.group = nobody
listen.mode = 0666
user = lighttpd
group = lighttpd
3. 启动 lighttpd 模块
Ubuntu
$ systemctl enable php7.0-fpm
$ systemctl restart php7.0-fpm
$ lighttpd-enable-mod fastcgi
$ lighttpd-enable-mod fastcgi-php
列出启动的模块设置
$ ls -l /etc/lighttpd/conf-enabled
Fedora / CentOS
$ systemctl enable php-fpm
$ systemctl restart php-fpm
$ gedit /etc/lighttpd/modules.conf
include "conf.d/fastcgi.conf"
OpenSUSE
opening errorlog '/var/log/lighttpd/error.log' failed: Permission denied
$ touch /var/log/lighttpd/error.log
$ chmod 666 /var/log/lighttpd/error.log
opening errorlog '/var/log/lighttpd/access.log' failed: Permission denied
$ touch /var/log/lighttpd/access.log
$ chmod 666 /var/log/lighttpd/access.log
$ systemctl enable php-fpm
$ systemctl restart php-fpm
$ gedit /etc/lighttpd/modules.conf
include "conf.d/fastcgi.conf"
4. 启动 lighttpd
$ systemctl enable lighttpd
$ systemctl restart lighttpd
5. 测试
Ubuntu
$ gedit /var/www/html/test.php
Fedora / CentOS
$ gedit /var/www/lighttpd/test.php
OpenSUSE
$ gedit /srv/www/htdocs/test.php
<?php
phpinfo();
?>
http://127.0.0.1/test.php
6. 其它
WebDAV
http://jasonmun.blogspot.my/2017/01/linux-lighttpd-webdav.html
; CentOS
listen = /var/run/php-fpm/php-fpm.sock
; Fedora
listen = /var/run/php-fpm/www.sock
; OpenSUSE
listen = 127.0.0.1:9000
listen.owner = nobody
listen.group = nobody
listen.mode = 0666
user = lighttpd
group = lighttpd
3. 启动 lighttpd 模块
Ubuntu
$ systemctl enable php7.0-fpm
$ systemctl restart php7.0-fpm
$ lighttpd-enable-mod fastcgi
$ lighttpd-enable-mod fastcgi-php
列出启动的模块设置
$ ls -l /etc/lighttpd/conf-enabled
Fedora / CentOS
$ systemctl enable php-fpm
$ systemctl restart php-fpm
$ gedit /etc/lighttpd/modules.conf
include "conf.d/fastcgi.conf"
OpenSUSE
opening errorlog '/var/log/lighttpd/error.log' failed: Permission denied
$ touch /var/log/lighttpd/error.log
$ chmod 666 /var/log/lighttpd/error.log
opening errorlog '/var/log/lighttpd/access.log' failed: Permission denied
$ touch /var/log/lighttpd/access.log
$ chmod 666 /var/log/lighttpd/access.log
$ systemctl enable php-fpm
$ systemctl restart php-fpm
$ gedit /etc/lighttpd/modules.conf
include "conf.d/fastcgi.conf"
4. 启动 lighttpd
$ systemctl enable lighttpd
$ systemctl restart lighttpd
5. 测试
Ubuntu
$ gedit /var/www/html/test.php
Fedora / CentOS
$ gedit /var/www/lighttpd/test.php
OpenSUSE
$ gedit /srv/www/htdocs/test.php
<?php
phpinfo();
?>
http://127.0.0.1/test.php
6. 其它
WebDAV
http://jasonmun.blogspot.my/2017/01/linux-lighttpd-webdav.html
没有评论:
发表评论