
1.登录和更新
1 2 3 4 5
| #以管理身份登录 su #k系统更新 apt-get update apt-get upgrade
|
2.安装nginx
1 2
| sudo apt install nginx systemctl enable nginx
|
3.安装MySQL
1 2
| sudo apt install mysql-server systemctl enable mysql
|
4.安装PHP
1 2
| sudo apt install php sudo apt install php-fpm
|
5.配置Nginx支持PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| server { listen 80 default_server; listen [::]:80 default_server; root /home/html; index index.php index.html index.htm index.nginx-debian.html; server_name localhost; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } location ~ /\.ht { deny all; } }
|
6.测试篇
注意新版本Mysql 中操作命令 “mysql”改为”mysqli”
1 2 3
| #新建网站首页 cd /home/html; vim index.php;
|
1 2 3 4 5 6 7 8 9 10 11
| <?php echo "测试数据库连接"; $con = mysqli_connect("localhost","root","NewPass1!"); if (!$con) { die('Could not connect: ' . mysql_error()); }else{ echo "conneted"; } #打印php信息 phpinfo(); ?>
|