ubuntu小技巧

ubuntu22.04安装自带的nginx、自带mysql-server、自带的php8.1-fpm,直接上wordpress

购买ubuntu22.04后,apt update ,升级到最新软件,下面步骤快速安装好php,nginx,mysql环境,直接用,10分钟搞定。

安装软件:
apt -y install php8.1-mysqli php8.1-cli php8.1-fpm php8.1-curl php8.1-gd php8.1-intl php8.1-mbstring php8.1-soap php8.1-xml php8.1-xmlrpc php8.1-zip

systemctl status php8.1-fpm

# systemctl status php8.1-fpm
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-11-19 20:40:11 CST; 2h 59min ago
       Docs: man:php-fpm8.1(8)
    Process: 1065 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=>
   Main PID: 852 (php-fpm8.1)
     Status: "Processes active: 0, idle: 3, Requests: 1516, slow: 0, Traffic: 0.5req/sec"
      Tasks: 4 (limit: 3944)
     Memory: 435.3M
        CPU: 1min 40.639s
     CGroup: /system.slice/php8.1-fpm.service
             ├─  852 "php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
             ├─ 4850 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "">
             ├─13362 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "">
             └─46186 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "">

Nov 19 20:40:10 moneyslow systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
Nov 19 20:40:11 moneyslow systemd[1]: Started The PHP 8.1 FastCGI Process Manager.


apt install mysql-server

# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1497
Server version: 8.0.35-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


apt install nginx

~# nginx -v
nginx version: nginx/1.18.0 (Ubuntu)


service mysql status
systemctl status mysql

# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>
     Active: active (running) since Sun 2023-11-19 20:40:13 CST; 2h 58min ago
    Process: 843 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=ex>
   Main PID: 1054 (mysqld)
     Status: "Server is operational"
      Tasks: 41 (limit: 3944)
     Memory: 532.8M
        CPU: 41.494s
     CGroup: /system.slice/mysql.service
             └─1054 /usr/sbin/mysqld

Nov 19 20:40:10 moneyslow systemd[1]: Starting MySQL Community Server...
Nov 19 20:40:13 moneyslow systemd[1]: Started MySQL Community Server.


systemctl enable nginx
systemctl enable mysql
systemctl enable php8.1-fpm

在mysql8.0.35版本下,建个用户,比如moneyslow用户

建数据库:
CREATE DATABASE moneyslow DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER moneyslow@127.0.0.1 IDENTIFIED BY ‘password’;
GRANT ALL ON moneyslow.* TO moneyslow@127.0.0.1 WITH GRANT OPTION;

接下来导入数据,配置nginx。