As the title of the blog says “Setting Up pa11y dashboard”. This blog post is about how we can set up a pa11y dashboard on a server. Before I start with the introduction of the dashboard, I would suggest you look at this blog about pa11y to have a better understanding of pa11y.
正如博客标题中所说的“设置Pa11y仪表板”。 这篇博客文章介绍了如何在服务器上设置付费仪表板。 在开始介绍仪表盘之前,建议您阅读有关pa11y的博客,以更好地了解pa11y。
(pa11y dashboard)
Pa11y Dashboard is a web interface which helps you monitor the accessibility of your websites. With pa11y dashboard, you can generate accessibility results of any website. Even if your website is behind a proxy or firewall, you can test the accessibility of that page as well.
Pa11y Dashboard是一个Web界面,可帮助您监视网站的可访问性。 使用pa11y仪表板,您可以生成任何网站的可访问性结果。 即使您的网站位于代理服务器或防火墙之后,您也可以测试该页面的可访问性。
(Setting up pa11y dashboard)
Before I start with the tutorial, the only pre-requisite of the pa11y dashboard server is that you need a server running on your local machine since I won’t be covering that part in the blog.
在开始学习本教程之前,pa11y仪表板服务器的唯一先决条件是您需要在本地计算机上运行的服务器,因为我不会在博客中介绍该部分。
Let’s start with the steps :
让我们从以下步骤开始:
(1. SSH into your server)
Once you have a server running in your machine. Let’s remotely ssh into the server with ssh root@<given IP address>.
在计算机中运行服务器后。 让我们使用ssh root@<given IP address>.远程SSH到服务器ssh root@<given IP address>.
(2. Install NodeJS)
Since pa11y dashboard is a node application and it requires a stable or LTS version of Node, currently version 8 or greater. So, you need to install node js. You can refer to node documentation to install node in your server.
由于pa11y仪表板是节点应用程序,因此它需要Node的稳定版本或LTS版本,当前版本为8或更高。 因此,您需要安装节点js。 您可以参考节点文档以在服务器中安装节点。
After you install node type node -v to know the current version of node js
安装节点后,请键入node -v以了解节点js的当前版本。
(3. Install MongoDB)
Pa11y Dashboard also requires a MongoDB database to be available so it can store the results of the tests. The database doesn’t have to be in the same server or computer where Pa11y Dashboard is running from.
Pa11y Dashboard还需要一个MongoDB数据库可用,以便它可以存储测试结果。 数据库不必与运行Pa11y Dashboard的服务器或计算机相同。
(4. Install PhantomJS)
We need another dependency which is PhantomJS to run the pa11y dashboard. You can follow this tutorial to install PhantomJS.
我们需要另一个依赖项PhantomJS来运行pa11y仪表板。 您可以按照本教程安装PhantomJS。
After you install it confirm the version of phantomJS or check if PhantomJS is installed using this command phantomjs -v
安装后,请确认phantomJS的版本或使用此命令phantomjs -v检查是否安装了PhantomJS。
(5. Fork and clone)
Your visible sites are in opt/ with this setup, so you’ll want to get into that directory with (from the root). Type the following commands to clone the repo.
通过此设置,您的可见站点位于opt/ ,因此您将希望使用(从根目录)进入该目录。 键入以下命令以克隆存储库。
cd /cd opt
Now, when you reach at opt, clone the repo in this directory, using the command
现在,当您到达opt时,使用以下命令在此目录中克隆存储库
git clone https://github.com/pa11y/pa11y-dashboard.git
git clone https://github.com/pa11y/pa11y-dashboard.git
You can also clone it using your fork
您也可以使用fork克隆它
Run the command cd pa11y-dashboard to enter in your pa11y dashboard and yes, now we have successfully completed the installation of pa11y dashboard.
运行命令cd pa11y-dashboard进入pa11y仪表板,是的,现在我们已经成功完成了pa11y仪表板的安装。
(6. Setting up the pa11y dashboard)
To set up the repo, you can follow these guidelines on the pa11y dashboard and use any of the two options as suggested.
要设置存储库,您可以在pa11y仪表板上遵循以下准则,并根据建议使用两个选项中的任何一个。
(Option 1: Using Environment Variables)
Each configuration can be set with an environment variable rather than a config file. For example to run the application on port 8080 you can use the following:
可以使用环境变量而不是配置文件来设置每个配置。 例如,要在端口8080上运行该应用程序,可以使用以下命令:
PORT=8080 node index.js
The available configurations are documented here.
可用配置在此处记录 。
(Option 2: Using Config Files)
You’ll need to copy and modify different config files depending on your environment (set with NODE_ENV):
您需要根据您的环境(设置为NODE_ENV )复制和修改不同的配置文件:
cp config/development.sample.json config/development.json
cp config/production.sample.json config/production.json
cp config/test.sample.json config/test.json
Each of these files defines configurations for a different environment. If you’re just running the application locally, then you should be OK with just development and test configurations. The available configurations are documented here.
每个文件都定义了不同环境的配置。 如果您只是在本地运行应用程序,那么只需进行开发和测试配置就可以了。 可用配置在此处记录 。
Now that you’ve got your application configured, make sure you have a MongoDB server running with the mongod command in another terminal window. You can run in each mode by changing the NODE_ENV environment variable:
现在,您已经配置了应用程序,请确保您在另一个终端窗口中使用mongod命令运行了MongoDB服务器。 您可以通过更改NODE_ENV环境变量在每种模式下运行:
NODE_ENV=development node index.js
Now in your terminal, you can see an output like this
现在在您的终端中,您可以看到这样的输出
On port 3000, the web service is running and in 4000, you can see the dashboard.
在port 3000 ,Web服务正在运行,在port 3000 4000 ,您可以看到仪表板。
(7. pm2)
Now the only problem is if we close the terminal, the server stop running. So, to solve this problem, we are going to install pm2 which is a process manager for node.
现在唯一的问题是,如果我们关闭终端,服务器将停止运行。 因此,要解决此问题,我们将安装pm2 ,它是节点的进程管理器。
You can install it with npm install pm2 -g.
您可以使用npm install pm2 -g 。
Now start the server with this command
现在使用此命令启动服务器
NODE_ENV=production pm2 start index.js
NODE_ENV=production pm2 start index.js
(8. Changing the port)
Let’s change our port from 4000 to 80. To do that, type the following command in your terminal,
让我们将端口从4000更改为80 。 为此,请在终端中键入以下命令,
sudo nano config/production.json
sudo nano config/production.json
You can also use vim or any other editor that you like and edit the file like this.
您也可以使用vim或您喜欢的任何其他编辑器,并像这样编辑文件。
Now, let us restart the server using pm2 restart all
现在,让我们使用pm2 restart all启动服务器。
Now you can see the server running at <your ip address> and not at <your ip address>:4000
现在您可以看到服务器在<your ip address>而不是<your ip address>:4000
pa11y documentation says that in Unix-like systems you may need to install the libnss3 and libgconf-2-4 libraries in order to be able to run Chrome. To fix this, run the following command
pa11y文档说,在类似Unix的系统中,可能需要安装libnss3和libgconf-2-4库才能运行Chrome。 要解决此问题,请运行以下命令
sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
Woohoo 😄, we are done with the steps now.
oo,我们现在已完成所有步骤。
Congratulations 😍 your pa11y dashboard set up is done and I am sure that your pa11y dashboard set up is working. Thanks for reading it till the end. Do let me know in the comment section if you have any suggestions or questions. You can reach out to me here
恭喜😍您的控制台设置已完成,我确定您的控制台设置已正常运行。 感谢您阅读它直到最后。 如果您有任何建议或问题,请在评论部分让我知道。 您可以在这里与我联系
翻译自: https://medium.com/@menidhikjha/setting-up-pa11y-dashboard-988f61e2154