产品动态
公共镜像更新动态
操作系统官方停止维护计划
产品公告
sudo apt update
sudo apt -y install nginx
sudo nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
sudo vim /etc/nginx/sites-enabled/default
server {listen 80 default_server;listen [::]:80 default_server;root /var/www/html;# Add index.php to the list if you are using PHPindex index.php index.html index.htm index.nginx-debian.html;server_name _;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;fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;}}
sudo systemctl restart nginx
index.html 首页。sudo vi /var/www/html/index.html
<p> hello world!</p>

sudo apt -y install mysql-server
sudo mysql -V
mysql Ver 8.0.41-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
sudo mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
flush privileges;
\\q
sudo apt -y install php-fpm
sudo php -v
PHP 8.1.2-1ubuntu2.19 (cli) (built: Sep 30 2024 16:25:25) (NTS)Copyright (c) The PHP GroupZend Engine v4.1.2, Copyright (c) Zend Technologieswith Zend OPcache v8.1.2-1ubuntu2.19, Copyright (c), by Zend Technologies
sudo vim <网站根目录>/phpinfo.php
/etc/nginx/sites-enabled/default,您可以运行cat /etc/nginx/sites-enabled/default命令查看文件内容,其中如下图所示的 /var/www/html 部分即为网站根目录。
sudo vim /var/www/html/phpinfo.php
<?php echo phpinfo(); ?>
sudo systemctl start php8.1-fpm
http://<Ubuntu 实例公网 IP 地址 >/phpinfo.php 进行访问。
文档反馈