手动搭建LNMP环境 禁止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! 安装PHP 1. 依次执行以下命令,安装PHP 7和一些所需的PHP扩展。 plaintext rpm Uvh Uvh yum/el7/webtaticrelease.rpm yum y install php70wtidy php70wcommon php70wdevel php70wpdo php70wmysql php70wgd php70wldap php70wmbstring php70wmcrypt php70wfpm 2. 执行以下命令,验证PHP的安装版本。 plaintext php v 回显如下类似信息: plaintext PHP 7.0.31 (cli) (built: Jul 20 2018 08:55:22) ( NTS ) Copyright (c) 19972017 The PHP Group Zend Engine v3.0.0, Copyright (c) 19982017 Zend Technologies 3. 执行以下命令,启动PHP服务并设置开机自启动。 plaintext systemctl start phpfpm systemctl enable phpfpm 4. 修改nginx配置文件以支持PHP。 执行以下命令打开配置文件“default.conf”。 plaintext vim /etc/nginx/conf.d/default.conf 按i键进入编辑模式。 修改打开的“default.conf”文件。 在所支持的主页面格式中添加php格式的主页,如下所示: plaintext location / { root /usr/share/nginx/html; index index.php index.html index.htm; } 取消如下内容的注释,并设置字体加粗部分为nginx的默认路径,如下所示: plaintext location ~ .php$ { root html; fastcgipass 127.0.0.1:9000; fastcgiindex index.php; fastcgiparam SCRIPTFILENAME /usr/share/nginx/html$fastcgiscriptname; include fastcgiparams; } 按Esc键退出编辑模式,并输入 :wq保存后退出。 执行以下命令,重新载入nginx的配置文件。 plaintext service nginx reload