OpenLiteSpeed is an optimized open source web server that can be used to manage and serve sites. OpenLiteSpeed has some useful features that make it a solid choice for many installations: it features Apache-compatible rewrite rules, a built-in web-based administration interface, and customized PHP processing optimized for the server.
OpenLiteSpeed是经过优化的开源Web服务器,可用于管理和服务站点。 OpenLiteSpeed具有一些有用的功能,使其成为许多安装的可靠选择:它具有与Apache兼容的重写规则,内置的基于Web的管理界面以及针对服务器进行了优化的自定义PHP处理。
In this guide, we’ll demonstrate how to install and configure OpenLiteSpeed on an Ubuntu 18.04 server.
在本指南中,我们将演示如何在Ubuntu 18.04服务器上安装和配置OpenLiteSpeed。
To complete this tutorial you will need an Ubuntu 18.04 server with a sudo
-enabled, non-root user and the ufw
firewall enabled.
要完成本教程,您将需要一台Ubuntu 18.04服务器,该服务器具有启用了sudo
非root用户并启用了ufw
防火墙。
Please refer to our Initial Server Setup with Ubuntu 18.04 tutorial for instructions on fulfilling these requirements.
请参阅我们的Ubuntu 18.04初始服务器设置教程,以获取有关满足这些要求的说明。
OpenLiteSpeed provides a software repository we can use to download and install the server with Ubuntu’s standard apt
command.
OpenLiteSpeed提供了一个软件存储库,可用于通过Ubuntu的标准apt
命令下载和安装服务器。
To enable this repository for your Ubuntu system, first download and add the developer’s software signing key:
要为您的Ubuntu系统启用此存储库,请首先下载并添加开发人员的软件签名密钥:
This key is used to cryptographically verify that nobody has tampered with the software we’re about to download.
该密钥用于加密验证没有人篡改我们将要下载的软件。
Next, we add the repository information to our system:
接下来,我们将存储库信息添加到我们的系统中:
After the repository has been added, the add-apt-repository
command will refresh our package cache and the new software will be available to install.
添加存储库后, add-apt-repository
命令将刷新我们的程序包缓存,并且可以安装新软件。
Install the OpenLiteSpeed server and its PHP processor using apt install
:
使用apt install
OpenLiteSpeed服务器及其PHP处理器:
Finally, create a soft link to the PHP processor we just installed. This directs the OpenLiteSpeed server to use the correct version:
最后,创建一个指向刚刚安装PHP处理器的软链接。 这指示OpenLiteSpeed服务器使用正确的版本:
Now that the OpenLiteSpeed server is installed, we’ll secure it by updating the default admin account.
现在已经安装了OpenLiteSpeed服务器,我们将通过更新默认的管理员帐户来保护它。
Before we test the server, we should set a new administrative password for OpenLiteSpeed. By default, the password is set to 123456
, so we should change this immediately. We can do this by running a script provided by OpenLiteSpeed:
在测试服务器之前,我们应该为OpenLiteSpeed设置一个新的管理密码。 默认情况下,密码设置为123456
,因此我们应该立即更改它。 我们可以通过运行OpenLiteSpeed提供的脚本来做到这一点:
You will be asked to provide a username for the administrative user. If you press ENTER
without choosing a new username, the default of admin will be used. Then, you will be prompted to create and confirm a new password for the account. Do so, then hit ENTER
one last time. The script will confirm a successful update:
系统将要求您提供管理用户的用户名。 如果按ENTER
而不选择新的用户名,则将使用默认的admin 。 然后,将提示您创建并确认该帐户的新密码。 这样做,然后最后一次按ENTER
。 该脚本将确认更新成功:
Output
Administrator's username/password is updated successfully!
Now that we’ve secured the admin account, let’s test out the server and make sure it’s running properly.
现在,我们已经保护了管理员帐户的安全,让我们测试一下服务器并确保其正常运行。
OpenLiteSpeed should have started automatically after it was installed. We can verify this using the lswsctrl
command:
安装后,OpenLiteSpeed应该会自动启动。 我们可以使用lswsctrl
命令验证这一点:
Output
litespeed is running with PID 990.
If you don’t see a similar message, you can start the server using lswsctrl
:
如果没有看到类似的消息,则可以使用lswsctrl
启动服务器:
Output
[OK] litespeed: pid=5137.
The server should now be running. Before we can visit it in our browser, we need to open up some ports on our firewall. We’ll do this with the ufw
command:
服务器现在应该正在运行。 在浏览器中访问它之前,我们需要打开防火墙上的一些端口。 我们将使用ufw
命令执行此操作:
The first port, 8088
, is the default port for OpenLiteSpeed’s example site. It should now be accessible to the public. In your web browser, navigate to your server’s domain name or IP address, followed by :8088
to specify the port:
第一个端口8088
是OpenLiteSpeed的示例站点的默认端口。 现在,它应该可供公众使用。 在Web浏览器中,导航到服务器的域名或IP地址,然后导航到:8088
以指定端口:
http://server_domain_or_IP:8088
Your browser should load the default OpenLiteSpeed web page, which looks like this:
您的浏览器应加载默认的OpenLiteSpeed网页,如下所示:
The links towards the bottom of the page are designed to demonstrate various features of the server. If you click through them you will notice that these features are already installed and properly configured. For instance, an example CGI script is available, a customized PHP instance is up and running, and custom error pages and authentication gates are configured. Click around to explore a little.
页面底部的链接旨在演示服务器的各种功能。 如果单击它们,您将注意到这些功能已经安装并正确配置。 例如,有一个示例CGI脚本可用,一个自定义PHP实例已启动并正在运行,并且已配置了自定义错误页面和身份验证门。 单击周围进行探索。
When you are satisfied with the default site, you can move on to the administrative interface. In your web browser, using HTTPS, navigate to your server’s domain name or IP address followed by :7080
to specify the port:
当您对默认站点感到满意时,可以转到管理界面。 在Web浏览器中,使用HTTPS,导航到服务器的域名或IP地址,后跟:7080
以指定端口:
https://server_domain_or_IP:7080
You will likely see a page warning you that the SSL certificate from the server cannot be validated. Since this is a self-signed certificate, this is expected. Click through the available options to proceed to the site. In Chrome, you must click “Advanced” and then “Proceed to…”.
您可能会看到一个页面,警告您无法验证来自服务器的SSL证书。 由于这是一个自签名证书,因此可以预期。 单击可用选项以转到站点。 在Chrome中,您必须单击“高级”,然后单击“继续...”。
You will be prompted to enter the administrative username and password that you selected with the admpass.sh
script in the previous step:
系统将提示您输入在上一步中使用admpass.sh
脚本选择的管理用户名和密码:
Once you correctly authenticate, you will be presented with the OpenLiteSpeed administration interface:
正确验证身份后,将显示OpenLiteSpeed管理界面:
This is where the majority of your configuration for the web server will take place.
这是Web服务器大多数配置的地方。
Next, we’ll explore this interface by walking through a common configuration task: updating the port used by the default page.
接下来,我们将通过完成一个常见的配置任务来探索此界面:更新默认页面使用的端口。
To demonstrate how to configure options through the web interface, we will change the port that the default site uses from 8088
to the conventional HTTP port 80
.
为了演示如何通过Web界面配置选项,我们将默认站点使用的端口从8088
更改为常规HTTP端口80
。
To accomplish this, first click Listeners in the list of options on the left side of the interface. A list of all available listeners will load.
为此,请首先在界面左侧的选项列表中单击“ 侦听器” 。 将加载所有可用侦听器的列表。
In the list of listeners, click the “View/Edit” button for the Default listener:
在侦听器列表中,单击默认侦听器的“查看/编辑”按钮:
This will load a page with more details about the Default listener. Click the edit button in the top-right corner of the “Address Settings” table to modify its values:
这将加载一个页面,其中包含有关默认侦听器的更多详细信息。 单击“地址设置”表右上角的编辑按钮,以修改其值:
On the next screen, change port 8088
to port 80
, then click the floppy disk icon, Save:
在下一个屏幕上,将端口8088
更改为端口80
,然后单击软盘图标Save :
After the modification, you will need to restart the server. Click the “reload” arrow icon to restart OpenLiteSpeed:
修改后,您将需要重新启动服务器。 单击“重新加载”箭头图标以重新启动OpenLiteSpeed:
Additionally, you’ll need to now open up port 80
on your firewall:
此外,您现在需要在防火墙上打开端口80
:
The default web page should now be accessible in your browser on port 80
instead of port 8088
. Visiting your server’s domain name or IP address without providing any port number will now display the site.
现在可以在浏览器中的端口80
而不是端口8088
上访问默认网页。 现在,在不提供任何端口号的情况下访问服务器的域名或IP地址将显示该站点。
OpenLiteSpeed is a fully-featured web server that is primarily managed through the administrative web interface. A full run through of how to configure your site through this interface is outside of the scope of this guide.
OpenLiteSpeed是功能齐全的Web服务器,主要通过管理Web界面进行管理。 如何通过此界面配置站点的完整介绍不在本指南的范围之内。
However, to get you started, we’ll touch on a few important points below:
但是,为了让您入门,我们将在下面重点介绍以下几点:
Everything associated with OpenLiteSpeed will be found under the /usr/local/lsws
directory.
与OpenLiteSpeed相关的所有内容都可以在/usr/local/lsws
目录下找到。
The document root (where your files will be served from) for the default virtual host is located at /usr/local/lsws/DEFAULT/html
. The configuration and logs for this virtual host can be found under the /usr/local/lsws/DEFAULT
directory.
默认虚拟主机的文档根目录(将在其中提供文件)位于/usr/local/lsws/DEFAULT/html
。 可在/usr/local/lsws/DEFAULT
目录下找到此虚拟主机的配置和日志。
You can create new virtual hosts for different sites using the admin interface. However, all of the directories that you will reference when setting up your configuration must be created ahead of time on your server. OpenLiteSpeed is not able to create the directories
您可以使用管理界面为不同的站点创建新的虚拟主机。 但是, 必须在服务器上提前创建设置配置时将引用的所有目录。 OpenLiteSpeed无法创建目录
The admin interface has a built-in tooltip help system for almost all fields. There is also a Help menu option in the left-hand menu that links to the server documentation. Consult these sources of information during configuration if you need more help.
管理界面为几乎所有字段提供了内置的工具提示帮助系统。 左侧菜单中还有一个“ 帮助”菜单选项,可链接到服务器文档。 如果需要更多帮助,请在配置期间查阅这些信息源。
To secure your OpenLiteSpeed installation with HTTPS, see the officall documentation’s section on SSL Setup
要使用HTTPS保护您的OpenLiteSpeed安装,请参阅SSL设置中正式文件的部分
At this point, you should have OpenLiteSpeed and PHP installed and running on an Ubuntu 18.04 server. OpenLiteSpeed offers great performance, a web-based configuration interface, and pre-configured options for script handling.
此时,您应该已经在Ubuntu 18.04服务器上安装并运行了OpenLiteSpeed和PHP。 OpenLiteSpeed具有出色的性能,基于Web的配置界面以及用于脚本处理的预配置选项。