vagrant 安装centos8 虚拟机搭建lamp环境
首先保证已经安装了 virtualbox vagrant两个软件
然后找个目录下载centos8 的 box
wget https://vagrantcloud.com/generic/boxes/centos8/versions/3.0.12/providers/virtualbox.box
添加box
vagrant box add centos ./virtualbox.box
生成一个配置文件
vagrant init
编辑配置文件
vi Vagrantfile
修改
config.vm.box = "centos"
然后启动
vagrant up
ssh上去
vagrant ssh
用户名密码都是 vagrant
安装apache
[vagrant@centos8 ~]$ yum install httpd Failed to set locale, defaulting to C.UTF-8 Error: This command has to be run with superuser privileges (under the root user on most systems). [vagrant@centos8 ~]$ sudo yum install httpd Failed to set locale, defaulting to C.UTF-8 CentOS Linux 8 - BaseOS 316 kB/s | 4.6 MB 00:14 Last metadata expiration check: 0:00:06 ago on Fri Jan 14 07:46:52 2022. Dependencies resolved. ================================================================================ Package Arch Version Repo Size ================================================================================ Installing: httpd x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 1.4 M Installing dependencies: apr x86_64 1.6.3-12.el8 appstream 129 k apr-util x86_64 1.6.1-6.el8 appstream 105 k centos-logos-httpd noarch 85.8-2.el8 baseos 75 k httpd-filesystem noarch 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 39 k httpd-tools x86_64 2.4.37-43.module_el8.5.0+1022+b541f3b1 appstream 107 k mailcap noarch 2.1.48-3.el8 baseos 39 k mod_http2 x86_64 1.15.7-3.module_el8.4.0+778+c970deab appstream 154 k Installing weak dependencies: apr-util-bdb x86_64 1.6.1-6.el8 appstream 25 k apr-util-openssl x86_64 1.6.1-6.el8 appstream 27 k Enabling module streams: httpd 2.4 Transaction Summary ================================================================================ Install 10 Packages Total download size: 2.1 M Installed size: 5.6 M Is this ok [y/N]: y Downloading Packages: (1/10): apr-util-bdb-1.6.1-6.el8.x86_64.rpm 84 kB/s | 25 kB 00:00 (2/10): apr-1.6.3-12.el8.x86_64.rpm 384 kB/s | 129 kB 00:00 (3/10): apr-util-1.6.1-6.el8.x86_64.rpm 305 kB/s | 105 kB 00:00 (4/10): apr-util-openssl-1.6.1-6.el8.x86_64.rpm 273 kB/s | 27 kB 00:00 (5/10): httpd-filesystem-2.4.37-43.module_el8.5 369 kB/s | 39 kB 00:00 (6/10): httpd-tools-2.4.37-43.module_el8.5.0+10 386 kB/s | 107 kB 00:00 (7/10): mod_http2-1.15.7-3.module_el8.4.0+778+c 657 kB/s | 154 kB 00:00 (8/10): httpd-2.4.37-43.module_el8.5.0+1022+b54 3.4 MB/s | 1.4 MB 00:00 (9/10): mailcap-2.1.48-3.el8.noarch.rpm 25 kB/s | 39 kB 00:01 (10/10): centos-logos-httpd-85.8-2.el8.noarch.r 44 kB/s | 75 kB 00:01 -------------------------------------------------------------------------------- Total 618 kB/s | 2.1 MB 00:03 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : apr-1.6.3-12.el8.x86_64 1/10 Running scriptlet: apr-1.6.3-12.el8.x86_64 1/10 Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/10 Installing : apr-util-openssl-1.6.1-6.el8.x86_64 3/10 Installing : apr-util-1.6.1-6.el8.x86_64 4/10 Running scriptlet: apr-util-1.6.1-6.el8.x86_64 4/10 Installing : httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1 5/10 Installing : mailcap-2.1.48-3.el8.noarch 6/10 Installing : centos-logos-httpd-85.8-2.el8.noarch 7/10 Running scriptlet: httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b54 8/10 Installing : httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b54 8/10 Installing : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86 9/10 Installing : httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_6 10/10 Running scriptlet: httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_6 10/10 Verifying : apr-1.6.3-12.el8.x86_64 1/10 Verifying : apr-util-1.6.1-6.el8.x86_64 2/10 Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 3/10 Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 4/10 Verifying : httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_6 5/10 Verifying : httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b54 6/10 Verifying : httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1 7/10 Verifying : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86 8/10 Verifying : centos-logos-httpd-85.8-2.el8.noarch 9/10 Verifying : mailcap-2.1.48-3.el8.noarch 10/10 Installed: apr-1.6.3-12.el8.x86_64 apr-util-1.6.1-6.el8.x86_64 apr-util-bdb-1.6.1-6.el8.x86_64 apr-util-openssl-1.6.1-6.el8.x86_64 centos-logos-httpd-85.8-2.el8.noarch httpd-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 httpd-filesystem-2.4.37-43.module_el8.5.0+1022+b541f3b1.noarch httpd-tools-2.4.37-43.module_el8.5.0+1022+b541f3b1.x86_64 mailcap-2.1.48-3.el8.noarch mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64 Complete!
看一下版本
[vagrant@centos8 ~]$ httpd -v Server version: Apache/2.4.37 (centos) Server built: Nov 12 2021 04:57:27
开机启动
[vagrant@centos8 ~]$ sudo chkconfig httpd on Note: Forwarding request to 'systemctl enable httpd.service'. Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
重启apache
sudo systemctl restart httpd
看一下状态
[vagrant@centos8 html]$ sudo systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.service.d └─php-fpm.conf Active: active (running) since Fri 2022-01-14 07:50:39 UTC; 30min ago Docs: man:httpd.service(8) Main PID: 25047 (httpd) Status: "Total requests: 2; Idle/Busy workers 100/0;Requests/sec: 0.00109; Bytes served/sec: 109 B/sec" Tasks: 213 (limit: 11499) Memory: 31.3M CGroup: /system.slice/httpd.service ├─25047 /usr/sbin/httpd -DFOREGROUND ├─25049 /usr/sbin/httpd -DFOREGROUND ├─25050 /usr/sbin/httpd -DFOREGROUND ├─25051 /usr/sbin/httpd -DFOREGROUND └─25052 /usr/sbin/httpd -DFOREGROUND Jan 14 07:50:39 centos8.localdomain systemd[1]: Starting The Apache HTTP Server... Jan 14 07:50:39 centos8.localdomain httpd[25047]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using centos8.> Jan 14 07:50:39 centos8.localdomain systemd[1]: Started The Apache HTTP Server. Jan 14 07:50:39 centos8.localdomain httpd[25047]: Server configured, listening on: port 80
查询mysql
[vagrant@centos8 ~]$ yum search mysql Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:13:37 ago on Fri Jan 14 07:37:11 2022. ======================== Name & Summary Matched: mysql ========================= mysql.x86_64 : MySQL client programs and shared libraries
安装mysql
[vagrant@centos8 ~]$ sudo yum install mysql mysql-server Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:07:34 ago on Fri Jan 14 07:46:52 2022. Dependencies resolved. ================================================================================ Package Arch Version Repo Size ================================================================================ Installing: mysql x86_64 8.0.26-1.module_el8.4.0+915+de215114 appstream 12 M mysql-server x86_64 8.0.26-1.module_el8.4.0+915+de215114 appstream 25 M Installing dependencies: checkpolicy x86_64 2.9-1.el8 baseos 348 k mariadb-connector-c-config noarch 3.1.11-2.el8_3 appstream 15 k mecab x86_64 0.996-1.module_el8.4.0+589+11e12751.9 appstream 393 k mysql-common x86_64 8.0.26-1.module_el8.4.0+915+de215114 appstream 134 k mysql-errmsg x86_64 8.0.26-1.module_el8.4.0+915+de215114 appstream 598 k policycoreutils-python-utils noarch 2.9-16.el8 baseos 252 k protobuf-lite x86_64 3.5.0-13.el8 appstream 149 k python3-audit x86_64 3.0-0.17.20191104git1c2f876.el8 baseos 86 k python3-libsemanage x86_64 2.9-6.el8 baseos 127 k python3-policycoreutils noarch 2.9-16.el8 baseos 2.2 M python3-setools x86_64 4.3.0-2.el8 baseos 626 k Transaction Summary ================================================================================ Install 13 Packages Total download size: 42 M Installed size: 206 M Is this ok [y/N]: y Downloading Packages: (1/13): mariadb-connector-c-config-3.1.11-2.el8 66 kB/s | 15 kB 00:00 (2/13): mysql-common-8.0.26-1.module_el8.4.0+91 1.1 MB/s | 134 kB 00:00 (3/13): mecab-0.996-1.module_el8.4.0+589+11e127 984 kB/s | 393 kB 00:00 (4/13): mysql-errmsg-8.0.26-1.module_el8.4.0+91 429 kB/s | 598 kB 00:01 (5/13): protobuf-lite-3.5.0-13.el8.x86_64.rpm 847 kB/s | 149 kB 00:00 (6/13): mysql-8.0.26-1.module_el8.4.0+915+de215 2.5 MB/s | 12 MB 00:04 (7/13): checkpolicy-2.9-1.el8.x86_64.rpm 110 kB/s | 348 kB 00:03 (8/13): python3-audit-3.0-0.17.20191104git1c2f8 172 kB/s | 86 kB 00:00 (9/13): python3-libsemanage-2.9-6.el8.x86_64.rp 159 kB/s | 127 kB 00:00 (10/13): policycoreutils-python-utils-2.9-16.el 107 kB/s | 252 kB 00:02 (11/13): mysql-server-8.0.26-1.module_el8.4.0+9 2.6 MB/s | 25 MB 00:09 (12/13): python3-setools-4.3.0-2.el8.x86_64.rpm 157 kB/s | 626 kB 00:03 (13/13): python3-policycoreutils-2.9-16.el8.noa 114 kB/s | 2.2 MB 00:20 -------------------------------------------------------------------------------- Total 1.5 MB/s | 42 MB 00:27 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 1/13 Installing : mysql-common-8.0.26-1.module_el8.4.0+915+de215114. 2/13 Installing : mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64 3/13 Installing : mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114. 4/13 Installing : python3-setools-4.3.0-2.el8.x86_64 5/13 Installing : python3-libsemanage-2.9-6.el8.x86_64 6/13 Installing : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_ 7/13 Installing : checkpolicy-2.9-1.el8.x86_64 8/13 Installing : python3-policycoreutils-2.9-16.el8.noarch 9/13 Installing : policycoreutils-python-utils-2.9-16.el8.noarch 10/13 Installing : protobuf-lite-3.5.0-13.el8.x86_64 11/13 Installing : mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64 12/13 Running scriptlet: mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64 12/13 Running scriptlet: mysql-server-8.0.26-1.module_el8.4.0+915+de215114. 13/13 Installing : mysql-server-8.0.26-1.module_el8.4.0+915+de215114. 13/13 Running scriptlet: mysql-server-8.0.26-1.module_el8.4.0+915+de215114. 13/13 ValueError: File context for /var/log/mysql(/.*)? already defined Verifying : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 1/13 Verifying : mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64 2/13 Verifying : mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64 3/13 Verifying : mysql-common-8.0.26-1.module_el8.4.0+915+de215114. 4/13 Verifying : mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114. 5/13 Verifying : mysql-server-8.0.26-1.module_el8.4.0+915+de215114. 6/13 Verifying : protobuf-lite-3.5.0-13.el8.x86_64 7/13 Verifying : checkpolicy-2.9-1.el8.x86_64 8/13 Verifying : policycoreutils-python-utils-2.9-16.el8.noarch 9/13 Verifying : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_ 10/13 Verifying : python3-libsemanage-2.9-6.el8.x86_64 11/13 Verifying : python3-policycoreutils-2.9-16.el8.noarch 12/13 Verifying : python3-setools-4.3.0-2.el8.x86_64 13/13 Installed: checkpolicy-2.9-1.el8.x86_64 mariadb-connector-c-config-3.1.11-2.el8_3.noarch mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64 mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64 mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64 mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114.x86_64 mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64 policycoreutils-python-utils-2.9-16.el8.noarch protobuf-lite-3.5.0-13.el8.x86_64 python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64 python3-libsemanage-2.9-6.el8.x86_64 python3-policycoreutils-2.9-16.el8.noarch python3-setools-4.3.0-2.el8.x86_64 Complete!
重启mysql
[vagrant@centos8 ~]$ sudo systemctl restart mysqld
设置 mysql 为开机启动
[vagrant@centos8 ~]$ sudo chkconfig mysqld on Note: Forwarding request to 'systemctl enable mysqld.service'. Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
查询php
[vagrant@centos8 ~]$ yum search php Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:28:22 ago on Fri Jan 14 07:37:11 2022. ========================= Name & Summary Matched: php ========================= php.x86_64 : PHP scripting language for creating dynamic web sites
安装php
[vagrant@centos8 ~]$ sudo yum install php Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:19:02 ago on Fri Jan 14 07:46:52 2022. Dependencies resolved. =============================================================================== Package Arch Version Repo Size =============================================================================== Installing: php x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 1.5 M Installing dependencies: nginx-filesystem noarch 1:1.14.1-9.module_el8.0.0+184+e34fea82 appstream 24 k php-cli x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 3.1 M php-common x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 661 k Installing weak dependencies: php-fpm x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 1.6 M Enabling module streams: nginx 1.14 php 7.2 Transaction Summary =============================================================================== Install 5 Packages Total download size: 6.9 M Installed size: 25 M Is this ok [y/N]: y Downloading Packages: (1/5): nginx-filesystem-1.14.1-9.module_el8.0. 86 kB/s | 24 kB 00:00 (2/5): php-7.2.24-1.module_el8.2.0+313+b04d0a6 1.1 MB/s | 1.5 MB 00:01 (3/5): php-common-7.2.24-1.module_el8.2.0+313+ 439 kB/s | 661 kB 00:01 (4/5): php-cli-7.2.24-1.module_el8.2.0+313+b04 1.2 MB/s | 3.1 MB 00:02 (5/5): php-fpm-7.2.24-1.module_el8.2.0+313+b04 1.1 MB/s | 1.6 MB 00:01 ------------------------------------------------------------------------------- Total 1.8 MB/s | 6.9 MB 00:03 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86 1/5 Installing : php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 2/5 Running scriptlet: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34f 3/5 Installing : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34f 3/5 Installing : php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 4/5 Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 4/5 Installing : php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 5/5 Running scriptlet: php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 5/5 Running scriptlet: php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 5/5 Verifying : nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34f 1/5 Verifying : php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 2/5 Verifying : php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 3/5 Verifying : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86 4/5 Verifying : php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 5/5 Installed: nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch php-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-cli-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-fpm-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 Complete!
看版本
[vagrant@centos8 ~]$ php -v PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
装扩展
[vagrant@centos8 ~]$ sudo yum search php-mysql Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:23:30 ago on Fri Jan 14 07:46:52 2022. ========================== Name Matched: php-mysql =========================== php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
没有mysql扩展 开一个
[vagrant@centos8 ~]$ sudo yum install php-mysqlnd Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:24:01 ago on Fri Jan 14 07:46:52 2022. Dependencies resolved. ============================================================================== Package Arch Version Repository Size ============================================================================== Installing: php-mysqlnd x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 190 k Installing dependencies: php-pdo x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 122 k Transaction Summary ============================================================================== Install 2 Packages Total download size: 313 k Installed size: 647 k Is this ok [y/N]: y Downloading Packages: (1/2): php-mysqlnd-7.2.24-1.module_el8.2.0+31 959 kB/s | 190 kB 00:00 (2/2): php-pdo-7.2.24-1.module_el8.2.0+313+b0 594 kB/s | 122 kB 00:00 ------------------------------------------------------------------------------ Total 298 kB/s | 313 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_6 1/2 Installing : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x 2/2 Running scriptlet: php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x 2/2 Verifying : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x 1/2 Verifying : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_6 2/2 Installed: php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 Complete!
没有json扩展 开一个
[vagrant@centos8 ~]$ sudo yum search php-json Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:24:54 ago on Fri Jan 14 07:46:52 2022. ======================= Name Exactly Matched: php-json ======================= php-json.x86_64 : JavaScript Object Notation extension for PHP [vagrant@centos8 ~]$ sudo yum install php-json Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:25:04 ago on Fri Jan 14 07:46:52 2022. Dependencies resolved. ============================================================================== Package Arch Version Repository Size ============================================================================== Installing: php-json x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 73 k Transaction Summary ============================================================================== Install 1 Package Total download size: 73 k Installed size: 44 k Is this ok [y/N]: y Downloading Packages: php-json-7.2.24-1.module_el8.2.0+313+b04d0a66 363 kB/s | 73 kB 00:00 ------------------------------------------------------------------------------ Total 91 kB/s | 73 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_ 1/1 Running scriptlet: php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_ 1/1 Verifying : php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_ 1/1 Installed: php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 Complete!
没有gd扩展 开一个
[vagrant@centos8 ~]$ sudo yum search php-gd Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:26:14 ago on Fri Jan 14 07:46:52 2022. ======================== Name Exactly Matched: php-gd ======================== php-gd.x86_64 : A module for PHP applications for using the gd graphics : library [vagrant@centos8 ~]$ sudo yum install php-gd Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:26:20 ago on Fri Jan 14 07:46:52 2022. Dependencies resolved. ============================================================================== Package Arch Version Repo Size ============================================================================== Installing: php-gd x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66 appstream 84 k Installing dependencies: dejavu-fonts-common noarch 2.35-7.el8 baseos 74 k dejavu-sans-fonts noarch 2.35-7.el8 baseos 1.6 M fontconfig x86_64 2.13.1-4.el8 baseos 274 k fontpackages-filesystem noarch 1.44-22.el8 baseos 16 k gd x86_64 2.2.5-7.el8 appstream 144 k jbigkit-libs x86_64 2.1-14.el8 appstream 55 k libX11 x86_64 1.6.8-5.el8 appstream 611 k libX11-common noarch 1.6.8-5.el8 appstream 158 k libXau x86_64 1.0.9-3.el8 appstream 37 k libXpm x86_64 3.5.12-8.el8 appstream 58 k libjpeg-turbo x86_64 1.5.3-12.el8 appstream 157 k libtiff x86_64 4.0.9-20.el8 appstream 188 k libwebp x86_64 1.0.0-5.el8 appstream 272 k libxcb x86_64 1.13.1-1.el8 appstream 229 k Transaction Summary ============================================================================== Install 15 Packages Total download size: 3.9 M Installed size: 12 M Is this ok [y/N]: y Downloading Packages: (1/15): jbigkit-libs-2.1-14.el8.x86_64.rpm 238 kB/s | 55 kB 00:00 (2/15): libX11-common-1.6.8-5.el8.noarch.rpm 1.1 MB/s | 158 kB 00:00 (3/15): libX11-1.6.8-5.el8.x86_64.rpm 1.4 MB/s | 611 kB 00:00 (4/15): libXau-1.0.9-3.el8.x86_64.rpm 438 kB/s | 37 kB 00:00 (5/15): libXpm-3.5.12-8.el8.x86_64.rpm 681 kB/s | 58 kB 00:00 (6/15): libjpeg-turbo-1.5.3-12.el8.x86_64.rpm 1.5 MB/s | 157 kB 00:00 (7/15): libtiff-4.0.9-20.el8.x86_64.rpm 1.8 MB/s | 188 kB 00:00 (8/15): libwebp-1.0.0-5.el8.x86_64.rpm 2.0 MB/s | 272 kB 00:00 (9/15): libxcb-1.13.1-1.el8.x86_64.rpm 1.4 MB/s | 229 kB 00:00 (10/15): php-gd-7.2.24-1.module_el8.2.0+313+b 946 kB/s | 84 kB 00:00 (11/15): dejavu-fonts-common-2.35-7.el8.noarc 147 kB/s | 74 kB 00:00 (12/15): fontconfig-2.13.1-4.el8.x86_64.rpm 301 kB/s | 274 kB 00:00 (13/15): gd-2.2.5-7.el8.x86_64.rpm 64 kB/s | 144 kB 00:02 (14/15): fontpackages-filesystem-1.44-22.el8. 162 kB/s | 16 kB 00:00 (15/15): dejavu-sans-fonts-2.35-7.el8.noarch. 347 kB/s | 1.6 MB 00:04 ------------------------------------------------------------------------------ Total 512 kB/s | 3.9 MB 00:07 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : libjpeg-turbo-1.5.3-12.el8.x86_64 1/15 Installing : fontpackages-filesystem-1.44-22.el8.noarch 2/15 Installing : dejavu-fonts-common-2.35-7.el8.noarch 3/15 Installing : dejavu-sans-fonts-2.35-7.el8.noarch 4/15 Installing : fontconfig-2.13.1-4.el8.x86_64 5/15 Running scriptlet: fontconfig-2.13.1-4.el8.x86_64 5/15 Installing : libwebp-1.0.0-5.el8.x86_64 6/15 Installing : libXau-1.0.9-3.el8.x86_64 7/15 Installing : libxcb-1.13.1-1.el8.x86_64 8/15 Installing : libX11-common-1.6.8-5.el8.noarch 9/15 Installing : libX11-1.6.8-5.el8.x86_64 10/15 Installing : libXpm-3.5.12-8.el8.x86_64 11/15 Installing : jbigkit-libs-2.1-14.el8.x86_64 12/15 Running scriptlet: jbigkit-libs-2.1-14.el8.x86_64 12/15 Installing : libtiff-4.0.9-20.el8.x86_64 13/15 Installing : gd-2.2.5-7.el8.x86_64 14/15 Running scriptlet: gd-2.2.5-7.el8.x86_64 14/15 Installing : php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_ 15/15 Running scriptlet: php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_ 15/15 Running scriptlet: fontconfig-2.13.1-4.el8.x86_64 15/15 Verifying : gd-2.2.5-7.el8.x86_64 1/15 Verifying : jbigkit-libs-2.1-14.el8.x86_64 2/15 Verifying : libX11-1.6.8-5.el8.x86_64 3/15 Verifying : libX11-common-1.6.8-5.el8.noarch 4/15 Verifying : libXau-1.0.9-3.el8.x86_64 5/15 Verifying : libXpm-3.5.12-8.el8.x86_64 6/15 Verifying : libjpeg-turbo-1.5.3-12.el8.x86_64 7/15 Verifying : libtiff-4.0.9-20.el8.x86_64 8/15 Verifying : libwebp-1.0.0-5.el8.x86_64 9/15 Verifying : libxcb-1.13.1-1.el8.x86_64 10/15 Verifying : php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_ 11/15 Verifying : dejavu-fonts-common-2.35-7.el8.noarch 12/15 Verifying : dejavu-sans-fonts-2.35-7.el8.noarch 13/15 Verifying : fontconfig-2.13.1-4.el8.x86_64 14/15 Verifying : fontpackages-filesystem-1.44-22.el8.noarch 15/15 Installed: dejavu-fonts-common-2.35-7.el8.noarch dejavu-sans-fonts-2.35-7.el8.noarch fontconfig-2.13.1-4.el8.x86_64 fontpackages-filesystem-1.44-22.el8.noarch gd-2.2.5-7.el8.x86_64 jbigkit-libs-2.1-14.el8.x86_64 libX11-1.6.8-5.el8.x86_64 libX11-common-1.6.8-5.el8.noarch libXau-1.0.9-3.el8.x86_64 libXpm-3.5.12-8.el8.x86_64 libjpeg-turbo-1.5.3-12.el8.x86_64 libtiff-4.0.9-20.el8.x86_64 libwebp-1.0.0-5.el8.x86_64 libxcb-1.13.1-1.el8.x86_64 php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64 Complete!
好了 到这里 环境装好了 但是没有配置关联 web服务器还不能解析php
启用 fpm 模式
[vagrant@centos8 html]$ sudo systemctl start php-fpm
[vagrant@centos8 html]$ sudo systemctl enable php-fpm Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
看一下启动状态
[vagrant@centos8 html]$ sudo systemctl status php-fpm ● php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; ena> Active: active (running) since Fri 2022-01-14 08:23:49 UTC; > Main PID: 27928 (php-fpm) Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0,> Tasks: 6 (limit: 11499) Memory: 20.2M CGroup: /system.slice/php-fpm.service ├─27928 php-fpm: master process (/etc/php-fpm.conf) ├─27929 php-fpm: pool www ├─27930 php-fpm: pool www ├─27931 php-fpm: pool www ├─27932 php-fpm: pool www └─27933 php-fpm: pool www
指示SELinux允许Apache通过PHP-FPM运行来执行PHP代码
[vagrant@centos8 html]$ sudo setsebool -P httpd_execmem 1
重新启动Apache Web服务器以使PHP与Apache Web服务器一起使用
[vagrant@centos8 html]$ sudo systemctl restart httpd
/var/www/html 下面创建一个index.php
写入
<?php echo microtime(true); ?>
curl 验证网站访问结果
[vagrant@centos8 html]$ curl http://127.0.0.1/index.php 1642148716.9452