Lighttpd 是一款安全、快速、符合标准的Web服务器。本教程介绍了如何通过PHP7(PHP-FPM)和MySQL5.7在Ubuntu16.04服务器上安装Lighttpd服务。 PHP-FPM(FastCGI进程管理器)是一种替代PHP的FastCGI适用于各种规模的网站,尤其是繁忙的网站有用的一些额外的功能。 1、安装初步说明
在本教程中,使用的IP地址为192.168.1.100,主机名server1.example.com。这些设置可能与你的服务器不同,所以你不得不在适当情况下更换他们。
2、安装MySQL 5.7 安装命令:
安装过程中要求设置 root 账户密码,如图:
MySQL 安装更改设置命令:
如下进行设置: root@server1:~# mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: <– Enter the MySQL root password
VALIDATE PASSWORD PLUGIN can be used to test passwords
Press y|Y for Yes, any other key for No: <– Press y if you want this function or press Enter otherwise.
… skipping.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : <– y
Normally, root should only be allowed to connect from
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : <– y
By default, MySQL comes with a database named ‘test’ that
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : <– y
– Removing privileges on test database…
Reloading the privilege tables will ensure that all changes
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : <– y All done! 3、安装Lighttpd:
安装命令: 浏览器输入主机地址,看看安装是否成功:
另外说明一下:
Lighttpd 默认根目录: /var/www/html
4、安装PHP 7.0
5、配置 Lighttpd 与 PHP 7.0 打开 php.ini:
文件配置: [...] ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok ; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting ; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting ; of zero causes PHP to behave as before. Default is 1. You should fix your scripts ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. ; http://php.net/cgi.fix-pathinfo cgi.fix_pathinfo=1 [...] httpd配置文件,我们需要将 /etc/lighttpd/conf-available/15-fastcgi-php.conf 进行备份:
内容修改: # /usr/share/doc/lighttpd-doc/fastcgi.txt.gz # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi ## Start an FastCGI server for php (needs the php7.0-cgi package) fastcgi.server += ( ".php" => (( "socket" => "/var/run/php/php7.0-fpm.sock", "broken-scriptfilename" => "enable" )) ) 要启用FastCGI配置,运行以下命令:
这将创建符号链接
执行情况: root@server1:/etc/lighttpd/conf-available# ls -l /etc/lighttpd/conf-enabled total 0 lrwxrwxrwx 1 root root 33 Apr 27 11:26 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf lrwxrwxrwx 1 root root 37 Apr 27 11:26 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf lrwxrwxrwx 1 root root 42 Apr 21 11:10 90-javascript-alias.conf -> ../conf-available/90-javascript-alias.conf root@server1:/etc/lighttpd/conf-available# 重新加载Lighttpd:
注意:如果提示你的语言环境错误,那么你可以下面的命令删除错误:
6、建立一个探针文件看看安装情况:
内容: <?php phpinfo(); ?> 好了,浏览器访问这个探针文件:http://192.168.1.100/info.php 7、PHP 获得 MySQL 支持 产看模块:
安装模块:
重新加载php7.0-fpm:
8、安装phpmyadmin 命令:
安装过程中询问设置: Web server to reconfigure automatically: Configure database for phpmyadmin with dbconfig-common? MySQL application password for phpmyadmin:
如果出现错误:
9、使PHP-FPM使用TCP连接(可选)
编辑: 内容如下: [...] ;listen = /var/run/php/php7.0-fpm.sock listen = 127.0.0.1:9000 [...] 重新加载PHP-FPM:
再配置一个文件:
配置内容如下: # /usr/share/doc/lighttpd-doc/fastcgi.txt.gz # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi ## Start an FastCGI server for php (needs the php7.0-cgi package) fastcgi.server += ( ".php" => (( "host" => "127.0.0.1", "port" => "9000", "broken-scriptfilename" => "enable" )) )
重新加载 Lighttpd: (责任编辑:IT) |