安装nginx和php

sudo apt install nginx php-fpm
php --version #测试是否安装成功

在目录下下载speedtest speedtest地址 https://github.com/adolfintel/speedtest

cd /var/www/
git clone https://github.com/adolfintel/speedtest

配置nginx的设置,这里我没有动nginx.conf , 而是修改的/etc/nginx/sites-enabled/default 文件


server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html index.php;

	server_name ip地址;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	  #一下两种二选一,第一种要注意php的版本和路径
		# With php-fpm (or other unix sockets):
		fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
		# With php-cgi (or other tcp sockets):
		#fastcgi_pass 127.0.0.1:9000;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
}

将克隆下来的项目放到nginx的默认目录下,这里设置的是root /var/www/html , 所以应该是/var/www/html/speedtest/ 然后选择自己喜欢的html文件修改名字成index.html即可