php:ubuntu24.04(kde neon)上apt方式搭建环境

一,查看ubuntu版本

# lsb_release -a
No LSB modules are available.
Distributor ID: Neon
Description:    KDE neon User Edition
Release:        24.04
Codename:       noble

二,安装php

# apt-get install php
# apt-get install php-fpm
# apt-get install php-mysql

查看状态:

# service php8.3-fpm status
● php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager
     Loaded: loaded (/usr/lib/systemd/system/php8.3-fpm.service; enabled; preset: enabled)
     Active: active (running) since Mon 2025-10-13 16:39:41 CST; 27min ago
       Docs: man:php-fpm8.3(8)
   Main PID: 12144 (php-fpm8.3)
     Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 9367)
     Memory: 7.8M (peak: 8.8M)
        CPU: 302ms
     CGroup: /system.slice/php8.3-fpm.service
             ├─12144 "php-fpm: master process (/etc/php/8.3/fpm/php-fpm.conf)"
             ├─12145 "php-fpm: pool www"
             └─12146 "php-fpm: pool www"

10月 13 16:39:41 liuhongdi-pc systemd[1]: Starting php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager...
10月 13 16:39:41 liuhongdi-pc systemd[1]: Started php8.3-fpm.service - The PHP 8.3 FastCGI Process Manager.

三,安装nginx

# apt-get install nginx

使可访问php:

# vi /etc/nginx/sites-enabled/default

把下面一段去掉注释:

location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

注意此处php的sock文件按实际安装的版本修改

四,安装mysql

# apt-get install mysql-server
# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.43-0ubuntu0.24.04.2 (Ubuntu)

Copyright (c) 2000, 2025, 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> 
mysql> create user 'root'@'127.0.0.1' identified by 'rootpassword';
Query OK, 0 rows affected (0.02 sec)

mysql> grant all on *.* to root@127.0.0.1;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
# systemctl stop mysql
# systemctl start mysql

五,安装phpmyadmin

解压:
root@lhdpc:/usr/local/source# unzip phpMyAdmin-5.0.1-all-languages.zip
移动到documentroot
root@lhdpc:/usr/local/source# mv phpMyAdmin-5.0.1-all-languages /var/www/html/phpmyadmin
生成配置文件:
root@lhdpc:/var/www/html/phpmyadmin# cp config.sample.inc.php config.inc.php
修改一行:
root@lhdpc:/var/www/html/phpmyadmin# vi config.inc.php
内容如下:
//$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
访问,用root和上面所添加的密码登录
查看效果:

 

posted @ 2025-10-25 14:44  刘宏缔的架构森林  阅读(4)  评论(0)    收藏  举报