«

Ubuntu 20.04 安装配置LNMP环境

myluzh 发布于 阅读:872 Linux


0x01安装Nginx

安装Nginx

Shell
sudo apt-get install nginx

启动Nginx服务

Shell
sudo /etc/init.d/nginx start

停止Nginx服务

Shell
sudo /etc/init.d/nginx stop

加载最新配置

Shell
sudo /etc/init.d/nginx reload

默认配置文件位置简单配置
/etc/nginx/sites-enabled/default

HTML
server {
       listen 80;
       server_name localhost;
       root /var/www/html;
       location / {
           index index.php index.html;
           #autoindex  off;
       }
       #开启php
       location ~ \.php(.*)$ {
           #"netstat -npl  | grep php"可以找到php run路径
           fastcgi_pass   unix:///run/php/php7.4-fpm.sock;
           fastcgi_index  index.php;
           fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           fastcgi_param  PATH_INFO  $fastcgi_path_info;
           fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
           include        fastcgi_params;
       }
}

0x02安装PHP

安装php7.4

Shell
sudo apt-get install php7.4-fpm

查看是否启动

Shell
sudo systemctl status php7.4-fpm

0x03安装mysql

安装mysql8.0

Shell
sudo apt-get install mysql

安装完后查看默认密码

Shell
sudo cat /etc/mysql/debian.cnf

用上面的默认用户名密码登录mysql

Shell
mysql -u xxxx -p

登录mysql后修改root密码

SQL
alter user 'root'@'localhost' identified with caching_sha2_password by '123456';

ubuntu lnmp


正文到此结束
版权声明:若无特殊注明,本文皆为 Myluzh Blog 原创,转载请保留文章出处。
文章内容:https://itho.cn/linux/100.html
文章标题:《Ubuntu 20.04 安装配置LNMP环境