首先保证已经安装了 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

如果你想让apache以别的组进行运行 那你可以修改
/etc/httpd/conf/httpd.conf

里面的user跟group 改为你想要的

比如说www-data组
然后你重启

sudo systemctl restart httpd

访问localhost发现访问服务用不了了
报错一个什么attempt to connect to unix domain socket /run/php-fpm/www.sock之类的错误
这个错误在哪看的,在/var/log/httpd/error.log里面发现的
这个时候发现要么是/var/www/html的所属组不对 要么是php fpm运行的组不对
那此时可以改一下php-fpm的运行组 配置文件是 /etc/php-fpm.d/www.conf 把这里面的组和用户改为www-data 同时注意到有个listen.acl_user这里要把www-data给追加到apache后面
因为默认都是用apache在跑
核心文件
/etc/httpd/conf/httpd.conf
/etc/php-fpm.d/www.conf

vagrant 安装centos8 虚拟机搭建lamp环境的更多相关文章

  1. linux下搭建lamp环境以及安装swoole扩展

    linux下搭建lamp环境以及安装swoole扩展   一.CentOS 6.5使用yum快速搭建LAMP环境 准备工作:先更新一下yum源  我安装的环境是:apache2.2.15+mysql5 ...

  2. CentOS 6.5 下源码搭建LAMP环境

    参考网站: http://wenku.baidu.com/link?url=Cvkqss2E9mnxXOZigMWPaCfqwsBxnm0sZ4aKE2oLAgQ888XxeC0DWOChxVqiHz ...

  3. CentOS下搭建LAMP环境详解

    前言:在这里将介绍如何在CentOS下搭建LAMP环境(全部使用源码编译安装),用于web服务器开发. •LAMP: Linux + Apache + PHP + Mysql. •系统: CentOS ...

  4. 在ubuntu上搭建开发环境4---ubuntu简单的搭建LAMP环境和配置

    最近重新安装了Ubuntu,但是之前的LAMP环境自然也就没有了,实在是不想再去编译搭建LAMP环境(这种方法实在是太费时间,而且太容易遇到各种不知道为什么的错误),所以,就去查查有没有什么简单的搭建 ...

  5. Centos6.4版本下搭建LAMP环境

    Centos6.4版本下搭建LAMP环境 配置yum mkdir/mnt/cdrom mount/dev/cdrom  /mnt/cdrom 装载光盘 vi /etc/yum.repos.d/Cent ...

  6. Centos7+Apache2.4+php5.6+mysql5.5搭建Lamp环境——为了wordPress

    最近想搭建个人博客玩玩,挑来挑去发现口碑不错的博客程序是wordpress,简称wp.虽然是学java路线的程序员,但因入行时间太短,至今没有发现较为称手开源的博客程序,如果各位大神有好的推荐,也希望 ...

  7. Linux手动搭建LAMP环境

    当你看到标题里的“手动搭建”,你是不是会想,难不成还有“自动搭建”?当然......不是,这里的“手动搭建”是指按部就班的搭建Apache.MySQL.PHP环境,是相对于集成软件包而言的.所以你是不 ...

  8. 利用yum搭建lamp环境并进一步创建博客

    用yum搭建lamp环境 第一.安装apache yum -y install httpd 第二.安装mariadb Yum -y mariadb mariadb-server 第三.安装php Yu ...

  9. Ubuntu18.04下搭建LAMP环境

    一.Apache2 web 服务器的安装 : 可以先更新一下服务器 1.sudo apt-get update             # 获取最新资源包 2.sudo apt-get upgrade ...

  10. •搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机

    本节所讲内容: 实战:搭建LAMP环境及快速部署双网站并实现基于域名的虚拟主机 LAMP架构:??? Linux+Apache+Mysql+PHP Linux+Apache+Mysql/MariaDB ...

随机推荐

  1. 【LLM训练系列】NanoGPT源码详解和中文GPT训练实践

    本文是[训练LLM系列]的第一篇,主要重点介绍NanoGPT代码以及中文.英文预训练实践.最新版参见我的知乎:https://zhuanlan.zhihu.com/p/716442447 除跑通原始N ...

  2. androi studio bitmap 压缩后 图片方向异常

    Android 使用 Camera2拍照后,获得 byte[] data,随后使用 BitmapFactory.decodeByteArray  压缩 导致图片方向异常 /* * 避免出现方向异常 * ...

  3. C语言中的数据类型及其转换

    目录 计算机中的数据类型 整型数据之间的转换 相同字长之间的转换 小字长转大字长 大字长转小字长 int.float.double之间的转换 float->double double->f ...

  4. SpringMVC初体验

    目录 SpringMVC简介 MVC介绍 什么是SpringMVC SpringMVC的特点 入门案例 创建maven工程 配置web.xml 默认配置方式 扩展配置方式 url-pattern标签中 ...

  5. 推荐一款开源、高效、灵活的Redis桌面管理工具:Tiny RDM!支持调试与分析功能!

    1.引言 在大数据和云计算快速发展的今天,Redis作为一款高性能的内存键值存储系统,在数据缓存.实时计算.消息队列等领域发挥着重要作用.然而,随着Redis集群规模的扩大和复杂度的增加,如何高效地管 ...

  6. Kubernetes 环境中切换代理ipvs模式

    Kubernetes 环境中切换代理ipvs模式 service代理默认使用iptables规则通过内核模块netfilter实现流量转发,内核转发效率高,但是iptables不具备更为灵活的负载均衡 ...

  7. Go runtime 调度器精讲(四):运行 main goroutine

    原创文章,欢迎转载,转载请注明出处,谢谢. 0. 前言 皇天不负有心人,终于我们到了运行 main goroutine 环节了.让我们走起来,看看一个 goroutine 到底是怎么运行的. 1. 运 ...

  8. ASP.NET Core – Partial View

    前言 之前写过一篇 ASP.NET Core – View Component 里面有提到, View Component 是 Partial View 的加强版. 多了一个 .cs 可以写逻辑. 那 ...

  9. 一个.NET开源、快速、低延迟的异步套接字服务器和客户端库

    前言 最近有不少小伙伴在问:.NET有什么值得推荐的网络通信框架?今天大姚给大家分享一个.NET开源.免费(MIT License).快速.低延迟的异步套接字服务器和客户端库:NetCoreServe ...

  10. iOS关于屏蔽暗黑模式小结

    不想适配暗黑模式可以关闭暗黑模式:在xcode12之前的版本Info.plist文件中添加Key:User Interface Style,值类型设置为String,值为Light,就可以不管在什么模 ...