当前位置: 首页 > article >正文

ubantu lnmp

www.carrotchou.blog

sudo apt install nginx
ufw enable
ufw allow ssh
ufw allow 80
ufw status

2、安装MySQL 5.7.6(Ubuntu 18.04 默认源中不包含这个版本,需要添加官方源):
sudo apt install software-properties-common -y
sudo add-apt-repository 'deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7'
sudo add-apt-repository 'deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7'
sudo apt update
sudo apt install mysql-server -y

2.2最新mysql8.0.3
sudo apt install mysql-server
2.3修改用户名密码
sudo vim /etc/mysql/debian.cnf
使用文件初始用户名和密码
mysql -u debian-sys-maint -pblySkrApIKeAlC4o
修改用户名密码
update mysql.user set authentication_string=password('123456') where
user='root' and host='localhost';

update mysql.user set plugin="mysql_native_password";

flush privileges;
查看mysql字符集
show variables like 'char%';
修改为utf-8编码集
set character_set_server=utf8;
修改表的字符编码
alter table user default character set utf8;
修改属性的字符编码
alter table user modify column name varchar(50) character set utf8; 

授权远程连接
# 访问mysql库
use mysql
# 修改root用户能在任何host访问(授权远程连接)
update user set host = '%' where user = 'root';
修改my.cnf或my.ini
[mysqld]
bind-address = 0.0.0.0
# 刷新
FLUSH PRIVILEGES;

停止
sudo systemctl stop mysql
启动
sudo systemctl start mysql


3、安装php7.4
最新 sudo apt install php-fpm php-mysql php-common php-xml php-cli php-gd php-curl php-bcmath
确认php-fpm是否安装
dpkg -l | grep php-fpm

指定 sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.4 php7.4-fpm php7.4-mysql php7.4-common php7.4-xml php7.4-cli php7.4-gd php7.4-curl

4.nginx配置查看sock
4.1 sudo find /etc/php -type f -name '*.conf' -exec grep -H 'listen' {} \;

4.2 cat /etc/php/8.1/fpm/pool.d/www/conf
以下内容:
; Note: This value is mandatory.
listen = /var/run/php/php7.4-fpm.sock
配置nginx vhost或nginx/sites-available/default
server {
    listen 80;
    server_name example.com;
    root /var/www/html;
 
    index index.php index.html index.htm;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
 
    location / {
        try_files $uri $uri/ =404;
    }
 
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
4.3重启nginx
sudo systemctl restart nginx

sudo systemctl start php8.1-fpm
sudo systemctl enable php8.1-fpm

server {
        listen        80;
        server_name  www.goserver.com;
        # root   "E:/projects/www.goserver.com";
        location / {
            # 设置允许跨域头部
            add_header 'Access-Control-Allow-Origin' 'http://www.vuedist.com';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            # cookies跨域传输
            add_header 'Access-Control-Allow-Credentials' true;
            add_header 'Access-Control-Allow-Headers' 'Origin, x-token, Authorization, Accept, DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            
            # 如果请求方法为 OPTIONS,则直接返回 204 状态码
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' 'http://www.vuedist.com';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Credentials' 'true';
                add_header 'Access-Control-Allow-Headers' 'Origin,x-token, Authorization, Accept, DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
                
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }

            proxy_pass http://localhost:8869;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9001;
            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;
        }
}

ufw防火墙命令
sudo ufw enable
sudo ufw disable
sudo ufw status verbose
sudo ufw allow 80/tcp
sudo ufw deny 80/tcp
sudo ufw allow from 192.168.1.1
sudo ufw deny from 192.168.1.1
sudo ufw delete allow 80/tcp

sudo ufw default allow/deny

sudo ufw reload


 


http://www.kler.cn/a/379263.html

相关文章:

  • LeetCode //C - 447. Number of Boomerangs
  • 一些常用的react hooks以及各自的作用
  • MySQL 数据库备份与恢复
  • 利用EasyExcel实现简易Excel导出
  • 音频模型介绍
  • 全!新!LLM推理加速调研
  • 【Android】Activity组件通信
  • 002-Kotlin界面开发之Kotlin旋风之旅
  • Jmeter5.X性能测试
  • 【机器学习】 16. 降维:PCA-主成分分析 Principle Component Analysis
  • Docker部署Portainer CE结合内网穿透实现容器的可视化管理与远程访问
  • Docker配置国内源加速
  • chrome 安装vuejs
  • CocoaPods安装步骤详解 - 2024
  • 封装ES高亮Yxh-Es
  • auxm 注册多个router参数时报错
  • Python数据分析NumPy和pandas(二十、数据清洗和预处理之二:数据转换)
  • 开源模型应用落地-glm模型小试-glm-4-9b-chat-快速体验(一)
  • SpringBoot核心知识点
  • 初识动态规划(由浅入深)
  • Spring Boot 应用开发指南
  • .Net C# 基于EFCore的DBFirst和CodeFirst
  • Docker基本概念汇总(更全面了解Docker)
  • 15. 文件操作
  • Netty 常见组件介绍
  • 鸿蒙生态认识