手工搭建LNMP环境(Ubuntu 20.04) 输入步骤4中设置的root用户密码 The 'validatepassword' component is installed on the server. The subsequent steps will run with the existing configuration of the component. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press yY for Yes, any other key for No) : Y 是否更改root用户密码,输入Y New password: 设置新的root用户密码 Reenter new password: 再次输入密码 Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press yY for Yes, any other key for No) : Y 确认使用已设置的密码,输入Y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press yY for Yes, any other key for No) : Y 是否删除匿名用户,输入Y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press yY for Yes, any other key for No) : Y 禁止root远程登录,输入Y Success. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press yY for Yes, any other key for No) : Y 是否删除test库和对它的访问权限,输入Y Dropping test database... Success. Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press yY for Yes, any other key for No) : Y 是否重新加载授权表,输入Y Success. All done! 3、安装PHP。 a.执行以下命令,安装PHP。 sudo apt update sudo apt install phpfpm b.执行以下命令,验证PHP的安装版本。 php v 回显如下类似信息: PHP 7.4.34ubuntu2.19 (cli) (built: Jun 27 2023 15:49:59) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.34ubuntu2.19, Copyright (c), by Zend Technologies c.执行以下命令,查看PHP运行状态。 systemctl status php7.4fpm 回显如下信息: ● php7.4fpm.service The PHP 7.4 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.4fpm.service; enabled; vendor preset: enabled) Active: active (running) since Mon 20230731 17:33:35 CST; 3min 50s ago Docs: man:phpfpm7.4(8) 说明 回显信息中若出现“lines 116/16 (end)”,可按q键退出。 d.修改Nginx配置文件以支持PHP。 1.执行以下命令,打开Nginx默认的配置文件。 sudo vim /etc/nginx/sitesenabled/default 2.按i键进入编辑模式。 3.修改打开的Nginx配置文件。 在server{}内,找到index开头的配置行,在该行中添加index.php。 在server{}内找到location ~ .php$ {},去除以下配置行的注释符号。 4.按Esc键退出编辑模式,并输入:wq保存后退出。 e.执行以下命令,重新载入nginx的配置文件。 sudo systemctl restart nginx 4、浏览器访问测试。 a.在Nginx网站根目录中,新建phpinfo.php文件。 sudo vim /var/www/html/phpinfo.php b.按i键进入编辑模式。 c.修改打开的“phpinfo.php”文件,将如下内容写入文件。 d.按Esc键退出编辑模式,并输入:wq保存后退出。 e.使用浏览器访问“