ITHO博客

从网络安全入门到放弃

Ubuntu 20.04 安装配置LNMP环境

2020-12-18 ITHO 二维码

0x01安装Nginx
安装Nginx
sudo apt-get install nginx

启动Nginx服务
sudo /etc/init.d/nginx start

停止Nginx服务
sudo /etc/init.d/nginx stop

加载最新配置
sudo /etc/init.d/nginx reload

默认配置文件位置简单配置
/etc/nginx/sites-enabled/default
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
sudo apt-get install php7.4-fpm

查看是否启动
sudo systemctl status php7.4-fpm

0x03安装mysql
安装mysql8.0
sudo apt-get install mysql

安装完后查看默认密码
sudo cat /etc/mysql/debian.cnf

用上面的默认用户名密码登录mysql 
mysql -u xxxx -p

登录mysql后修改root密码
alter user 'root'@'localhost' identified with caching_sha2_password by '123456';



标签: ubuntu lnmp