lamp的搭建

所谓lamp,其实就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一组动态网站或者服务器的开源软件,除Linux外其它各部件本身都是各自独立的程序,但是因为经常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

lamp平台软件安装次序:

httpd --> mysql --> php

注意:php要求httpd使用prefork MPM

将准备好的包通过xshell上传

安装httpd

安装epel-release包和开发工具包

[root@xk yum.repos.d]# yum -y install epel-release vim
CentOS Linux 8 - 3.9 kB/s | 4.3 kB     00:01    
CentOS Linux 8 - 3.4 kB/s | 3.9 kB     00:01    
CentOS Linux 8 - 599  B/s | 1.5 kB     00:02    
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Dependencies resolved.
=================================================
 Package       Arch    Version     Repo     Size
=================================================
Installing:
 epel-release  noarch  8-11.el8    extras   24 k

Transaction Summary
=================================================
Install  1 Package

Total download size: 24 k
Installed size: 35 k
Downloading Packages:
epel-release-8-1  20 kB/s |  24 kB     00:01    
-------------------------------------------------
Total             20 kB/s |  24 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                         1/1 
  Installing       : epel-release-8-11.el8   1/1 
  Running scriptlet: epel-release-8-11.el8   1/1 
  Verifying        : epel-release-8-11.el8   1/1 

Installed:
  epel-release-8-11.el8.noarch                   

Complete!
[root@xk yum.repos.d]# ls
CentOS-Linux-AppStream.repo
CentOS-Linux-BaseOS.repo
CentOS-Linux-ContinuousRelease.repo
CentOS-Linux-Debuginfo.repo
CentOS-Linux-Devel.repo
CentOS-Linux-Extras.repo
CentOS-Linux-FastTrack.repo
CentOS-Linux-HighAvailability.repo
CentOS-Linux-Media.repo
CentOS-Linux-Plus.repo
CentOS-Linux-PowerTools.repo
CentOS-Linux-Sources.repo
epel-modular.repo
epel-playground.repo
epel.repo
epel-testing-modular.repo
epel-testing.repo
[root@xk yum.repos.d]# cd
[root@xk ~]# yum groupinstall 'Develoment' Tools'
> ^C
[root@xk ~]# yum groupinstall 'Develoment' Tools'
> ^C
[root@xk ~]# yum groups mark install 'Develoment' Tools'
> yum groups mark install 'Development Tools'
> ^C
[root@xk ~]# yum groups mark install 'Development Tools'
Last metadata expiration check: 0:06:50 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Dependencies resolved.
=================================================
 Package   Arch     Version      Repo       Size
=================================================
Installing Groups:
 Development Tools
                                                

Transaction Summary
=================================================

Is this ok [y/N]: y
Complete!
[root@xk ~]# yum groupinstall 'Development Tools'

Last metadata expiration check: 0:07:54 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Dependencies resolved.
=================================================
 Package  Arch   Version         Repo       Size
=================================================
Installing group/module packages:
 asciidoc noarch 8.6.10-0.5.20180627gitf7c2274.el8
                                 appstream 216 k
 bison    x86_64 3.0.4-10.el8    appstream 688 k
 byacc    x86_64 1.9.20170709-4.el8
                                 appstream  91 k
 ctags    x86_64 5.8-22.el8      appstream 170 k
 diffstat x86_64 1.61-7.el8      appstream  44 k
 elfutils-libelf-devel
          x86_64 0.185-1.el8     baseos     59 k
 flex     x86_64 2.6.1-9.el8     appstream 320 k
 gdb      x86_64 8.2-16.el8      appstream 298 k
 git      x86_64 2.27.0-1.el8    appstream 164 k
 
          x86_64 4.18.0-348.7.1.el8_5
                                 baseos     20 M
Enabling module streams:
 javapackages-runtime
                 201801                         
Installing Groups:
 Development Tools
                                                

Transaction Summary
=================================================
Install  174 Packages

Total download size: 143 M
Installed size: 489 M
Is this ok [y/N]: y
Downloading Packages:
(1/174): adobe-m  70 kB/s | 119 kB     00:01    
(2/174): annobin 239 kB/s | 111 kB     00:00    
(3/174): adobe-m 303 kB/s | 707 kB     00:02    
.........................................(省略安装过程)
 ch
  xorg-x11-server-utils-7.7-27.el8.x86_64        
  xz-devel-5.2.4-3.el8.x86_64                    
  zip-3.0-23.el8.x86_64                          
  zstd-1.4.4-1.el8.x86_64                        

Complete!

创建apache服务的用户和组

[root@xk ~]# groupadd -r apache
groupadd: group 'apache' already exists
[root@xk ~]# id apache
uid=994(apache) gid=991(apache) groups=991(apache)
[root@xk ~]# useradd -r -M -s /sbin/nologin -g apache apache
useradd: user 'apache' already exists

安装依赖包

[root@xk ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
Last metadata expiration check: 0:14:41 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package pcre-devel-8.42-6.el8.x86_64 is already installed.
Package expat-devel-2.2.5-4.el8.x86_64 is already installed.
Package libtool-2.4.6-25.el8.x86_64 is already installed.
Package gcc-8.5.0-4.el8_5.x86_64 is already installed.
Package gcc-c++-8.5.0-4.el8_5.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

解压apr-1.7.2.tar和apr-util-1.6.3.tar

[root@xk src]# tar xf apr-1.7.2.tar 
[root@xk src]# tar xf apr-util-1.6.3.tar 
[root@xk src]# ls
apr-1.7.0
apr-1.7.0.tar.gz
apr-1.7.2
apr-1.7.2.tar
apr-util-1.6.1
apr-util-1.6.1.tar.gz
apr-util-1.6.3
apr-util-1.6.3.tar
debug
httpd-2.4.54
httpd-2.4.54.tar.gz
httpd-2.4.55-rc1.tar
kernels
mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz
php-8.2.3.tar

进入apr-1.7.2编辑configure,注释此行

[root@xk apr-1.7.2]# vim configure
# $RM "$cfgfile"

释放到/usr/local/apr

[root@xk apr-1.7.2]# ./configure --prefix=/usr/local/apr
......................................................
restoring INCLUDES to ""
  setting EXTRA_INCLUDES to ""
configure: creating ./config.status
config.status: creating Makefile
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands

编译安装make&&make install

[root@xk apr-1.7.2]# make&&make install
make[1]: Entering directory '/usr/src/apr-1.7.2'
/bin/sh /usr/src/apr-1.7.2/libtool --silent --mode=compile --tag=CC gcc -g -O2 -pthread   -DHAVE_CONFIG_H  -DLINUX -D_REENTRANT -D_GNU_SOURCE   -I./include -I/usr/src/apr-1.7.2/include/arch/unix -I./include/arch/unix -I/usr/src/apr-1.7.2/include
..............................................................................

进入到apr-1.6.3

[root@xk apr-1.7.2]# cd ..
[root@xk src]# cd apr-util-1.6.3
[root@xk apr-util-1.6.3]# 

同样释放

[root@xk apr-util-1.6.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

编译安装

[root@xk apr-util-1.6.3]# make && make install

解压httpd2.4.55并进入

[root@xk src]# tar xf httpd-2.4.55-rc1.tar 
[root@xk src]# ls
apr-1.7.0
apr-1.7.0.tar.gz
apr-1.7.2
apr-1.7.2.tar
apr-util-1.6.1
apr-util-1.6.1.tar.gz
apr-util-1.6.3
apr-util-1.6.3.tar
debug
httpd-2.4.54
httpd-2.4.54.tar.gz
httpd-2.4.55
httpd-2.4.55-rc1.tar
kernels
mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz
php-8.2.3.tar
[root@xk src]# cd httpd-2.4.55
[root@xk httpd-2.4.55]# 

释放到/usr/local/apache下

./configure --prefix=/usr/local/apache \
--sysconfdir=/etc/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork

编译安装

[root@xk httpd-2.4.55]# make && make install

安装后配置相关该有的命令

[root@xk ~]# ls /usr/local/apache
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[root@xk ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@xk ~]# source /etc/profile.d/httpd.sh
[root@xk ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@xk ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config

取消ServerName前面的注释

[root@xk ~]# sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf

启动apache

[root@xk ~]# apachectl start
httpd (pid 933) already running
[root@xk ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port           Peer Address:Port        Process        
LISTEN   0        128              0.0.0.0:111                 0.0.0.0:*                          
LISTEN   0        128              0.0.0.0:22                  0.0.0.0:*                          
LISTEN   0        128                 [::]:111                    [::]:*                          
LISTEN   0        128                    *:80                        *:*                          
LISTEN   0        128                 [::]:22                     [::]:*         

永久关闭防火墙

[root@xk ~]# systemctl disable --now firewalld
[root@xk ~]# setenforce 0
setenforce: SELinux is disabled
[root@xk ~]# vim /etc/selinux/config 
修改为SELINUX=disabled

安装mysql

安装依赖包

[root@xk ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
Last metadata expiration check: 1:54:18 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package openssl-1:1.1.1k-5.el8_5.x86_64 is already installed.
Dependencies resolved.
=================================================
 Package
       Arch   Version            Repo       Size
=================================================
Installing:
 cmake x86_64 3.20.2-4.el8       appstream  12 M
 mariadb-devel
       x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d
                                 appstream 1.1 M
 ncurses-devel
       x86_64 6.1-9.20180224.el8 baseos    528 k
Installing dependencies:
 cmake-data
       noarch 3.20.2-4.el8       appstream 1.7 M
 cmake-filesystem
       x86_64 3.20.2-4.el8       appstream  44 k
 cmake-rpm-macros
       noarch 3.20.2-4.el8       appstream  44 k
 libuv x86_64 1:1.41.1-1.el8_4   appstream 156 k
 mariadb-connector-c
       x86_64 3.1.11-2.el8_3     appstream 200 k
 mariadb-connector-c-config
       noarch 3.1.11-2.el8_3     appstream  15 k
 mariadb-connector-c-devel
       x86_64 3.1.11-2.el8_3     appstream  68 k
 ncurses-c++-libs
       x86_64 6.1-9.20180224.el8 baseos     58 k
Enabling module streams:
 mariadb
              10.3                              

Transaction Summary
=================================================
Install  11 Packages

Total download size: 16 M
Installed size: 45 M
Downloading Packages:
(1/11): cmake-fi  28 kB/s |  44 kB     00:01    
(2/11): cmake-rp  73 kB/s |  44 kB     00:00    
(3/11): cmake-da 649 kB/s | 1.7 MB     00:02    
(4/11): libuv-1. 217 kB/s | 156 kB     00:00    
(5/11): mariadb- 374 kB/s | 200 kB     00:00    
(6/11): mariadb-  33 kB/s |  15 kB     00:00    
(7/11): cmake-3. 3.2 MB/s |  12 MB     00:03    
(8/11): mariadb- 1.6 MB/s | 1.1 MB     00:00    
(9/11): ncurses- 129 kB/s |  58 kB     00:00    
(10/11): mariadb  69 kB/s |  68 kB     00:00    
(11/11): ncurses 1.2 MB/s | 528 kB     00:00    
-------------------------------------------------
Total            3.5 MB/s |  16 MB     00:04     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                         1/1 
  Installing       : cmake-rpm-macros-3.    1/11 
  Installing       : cmake-filesystem-3.    2/11 
  Installing       : ncurses-c++-libs-6.    3/11 
  Installing       : mariadb-connector-c    4/11 
  Installing       : mariadb-connector-c    5/11 
  Installing       : mariadb-devel-3:10.    6/11 
  Installing       : mariadb-connector-c    7/11 
  Installing       : libuv-1:1.41.1-1.el    8/11 
  Installing       : cmake-data-3.20.2-4    9/11 
  Installing       : cmake-3.20.2-4.el8.   10/11 
  Installing       : ncurses-devel-6.1-9   11/11 
  Running scriptlet: ncurses-devel-6.1-9   11/11 
  Verifying        : cmake-3.20.2-4.el8.    1/11 
  Verifying        : cmake-data-3.20.2-4    2/11 
  Verifying        : cmake-filesystem-3.    3/11 
  Verifying        : cmake-rpm-macros-3.    4/11 
  Verifying        : libuv-1:1.41.1-1.el    5/11 
  Verifying        : mariadb-connector-c    6/11 
  Verifying        : mariadb-connector-c    7/11 
  Verifying        : mariadb-connector-c    8/11 
  Verifying        : mariadb-devel-3:10.    9/11 
  Verifying        : ncurses-c++-libs-6.   10/11 
  Verifying        : ncurses-devel-6.1-9   11/11 

Installed:
  cmake-3.20.2-4.el8.x86_64                      
  cmake-data-3.20.2-4.el8.noarch                 
  cmake-filesystem-3.20.2-4.el8.x86_64           
  cmake-rpm-macros-3.20.2-4.el8.noarch           
  libuv-1:1.41.1-1.el8_4.x86_64                  
  mariadb-connector-c-3.1.11-2.el8_3.x86_64      
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch
  mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64
  mariadb-devel-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64
  ncurses-c++-libs-6.1-9.20180224.el8.x86_64     
  ncurses-devel-6.1-9.20180224.el8.x86_64        

Complete!

创建用户和组

[root@xk src]# groupadd -r -g 306 mysql
[root@xk src]# useradd -r -M -s /sbin/nologin -g 306 -u 306 mysql

解压软件至/usr/local/

[root@xk src]# tar xf mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@xk src]# cd /usr/local/
[root@xk local]# ln -sv mysql-5.7.40-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.40-linux-glibc2.12-x86_64/'
[root@xk local]# ll
total 0
drwxr-xr-x. 14 root root 164 Dec 26 23:41 apache
drwxr-xr-x.  6 root root  58 Dec 26 23:36 apr
drwxr-xr-x.  5 root root  43 Dec 26 23:37 apr-util
drwxr-xr-x.  2 root root   6 Jun 22  2021 bin
drwxr-xr-x.  2 root root   6 Jun 22  2021 etc
drwxr-xr-x.  2 root root   6 Jun 22  2021 games
drwxr-xr-x.  2 root root   6 Jun 22  2021 include
drwxr-xr-x.  2 root root   6 Jun 22  2021 lib
drwxr-xr-x.  3 root root  17 Dec 23 00:17 lib64
drwxr-xr-x.  2 root root   6 Jun 22  2021 libexec
lrwxrwxrwx   1 root root  36 Feb 20 16:54 mysql -> mysql-5.7.40-linux-glibc2.12-x86_64/
drwxr-xr-x   9 root root 129 Feb 20 16:52 mysql-5.7.40-linux-glibc2.12-x86_64
drwxr-xr-x.  2 root root   6 Jun 22  2021 sbin
drwxr-xr-x.  5 root root  49 Dec 23 00:17 share
drwxr-xr-x.  2 root root   6 Jun 22  2021 src

修改目录/usr/local/mysql的属主属组,添加环境变量

[root@xk local]# chown -R mysql.mysql /usr/local/mysql
[root@xk local]# ll /usr/local/mysql -d
lrwxrwxrwx 1 mysql mysql 36 Feb 20 16:54 /usr/local/mysql -> mysql-5.7.40-linux-glibc2.12-x86_64/
[root@xk local]# ls /usr/local/mysql
bin   include  LICENSE  README  support-files
docs  lib      man      share
[root@xk local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/pro
profile    profile.d/ protocols  
[root@xk local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@xk local]# . /etc/profile.d/mysql.sh 
[root@xk local]# echo $PATH
/usr/local/mysql/bin:/usr/local/apache/bin:/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@xk local]# 

建立数据存放目录

[root@xk mysql]# mkdir /opt/data
[root@xk mysql]# chown -R mysql.mysql /opt/data/
[root@xk mysql]# ll /opt/
total 0
drwxr-xr-x 2 mysql mysql 6 Feb 20 17:02 data

配置mysql

[root@xk mysql]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
'/usr/local/include/mysql' -> '/usr/local/mysql/include/'
[root@xk mysql]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@xk mysql]# ldconfig

初始化数据库

[root@xk mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2023-02-20T09:07:47.577574Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-02-20T09:07:47.800091Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-02-20T09:07:47.837992Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-02-20T09:07:47.893698Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0b77d13b-b0fe-11ed-b92c-000c295105b0.
2023-02-20T09:07:47.894939Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-02-20T09:07:48.339683Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-02-20T09:07:48.339713Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-02-20T09:07:48.340246Z 0 [Warning] CA certificate ca.pem is self signed.
2023-02-20T09:07:48.404695Z 1 [Note] A temporary password is generated for root@localhost: (kw:.5k4wUgi
此处生成了一个随机密码,等会登录会用上

生成配置文件

[root@xk ~]# cat > /etc/my.cnf <<EOF
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
EOF

配置服务启动脚本

[root@xk mysql]# cd /usr/local/mysql/support-files/
[root@xk support-files]# cp mysql.server /etc/init.d/mysqld
[root@xk support-files]# vim /etc/init.d/mysqld
更改存放的位置
basedir=/usr/local/mysql
datadir=/opt/data
[root@xk support-files]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
cp: overwrite '/etc/init.d/mysqld'? yes
[root@xk support-files]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@xk support-files]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
[root@xk support-files]# 

启动mysql

[root@xk ~]# service mysqld start
Starting MySQL.Logging to '/opt/data/xk.err'.
 SUCCESS! 
[root@xk ~]# ps -ef|grep mysql
root       82759       1  0 17:19 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pid
mysql      82947   82759  1 17:19 pts/2    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=xk.err --pid-file=/opt/data/mysql.pid --socket=/tmpmysql.sock --port=3306
root       82977    1553  0 17:19 pts/2    00:00:00 grep --color=auto mysql
[root@xk ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port           Peer Address:Port        Process        
LISTEN   0        128              0.0.0.0:111                 0.0.0.0:*                          
LISTEN   0        128              0.0.0.0:22                  0.0.0.0:*                          
LISTEN   0        128                 [::]:111                    [::]:*                          
LISTEN   0        128                    *:80                        *:*                          
LISTEN   0        128                 [::]:22                     [::]:*                          
LISTEN   0        80                     *:3306                      *:*                          
[root@xk ~]# 

登录前安装两个包

[root@xk ~]# mysql -uroot -p
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@xk ~]# yum provides libncurses.so.5
Last metadata expiration check: 2:44:00 ago on Mon 20 Feb 2023 02:42:18 PM CST.
ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility libraries
Repo        : @System
Matched from:
Provide    : libncurses.so.5

ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility libraries
Repo        : baseos
Matched from:
Provide    : libncurses.so.5
[root@xk ~]# yum -y install libncurses*
Last metadata expiration check: 2:44:27 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Package ncurses-c++-libs-6.1-9.20180224.el8.x86_64 is already installed.
Package ncurses-compat-libs-6.1-9.20180224.el8.i686 is already installed.
Package ncurses-libs-6.1-9.20180224.el8.x86_64 is already installed.
Dependencies resolved.
===============================================================================================================
 Package                         Architecture       Version                           Repository          Size
===============================================================================================================
Installing:
 ncurses-compat-libs             x86_64             6.1-9.20180224.el8                baseos             328 k

Transaction Summary
===============================================================================================================
Install  1 Package

Total download size: 328 k
Installed size: 1.0 M
Downloading Packages:
ncurses-compat-libs-6.1-9.20180224.el8.x86_64.rpm                              143 kB/s | 328 kB     00:02    
---------------------------------------------------------------------------------------------------------------
Total                                                                          143 kB/s | 328 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                       1/1 
  Installing       : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                         1/1 
  Running scriptlet: ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                         1/1 
  Verifying        : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                         1/1 

Installed:
  ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                                                

Complete!
[root@xk ~]# mysql -uroot -p
Enter password: 

使用临时密码登录并设置新密码

[root@xk ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.40

Copyright (c) 2000, 2022, 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> set password = password('runtime123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

安装php

安装依赖包

[root@xk ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php-mysqlnd
Last metadata expiration check: 2:55:25 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Package libxml2-2.9.7-9.el8_4.2.x86_64 is already installed.
Package openssl-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package bzip2-1.0.6-26.el8.x86_64 is already installed.
Package libcurl-7.61.1-22.el8.x86_64 is already installed.
Package libjpeg-turbo-1.5.3-12.el8.x86_64 is already installed.
Package libpng-2:1.6.34-5.el8.x86_64 is already installed.
Package pcre-devel-8.42-6.el8.x86_64 is already installed.
Package freetype-2.9.1-4.el8_3.1.x86_64 is already installed.
Package gmp-1:6.1.2-10.el8.x86_64 is already installed.
Package readline-7.0-10.el8.x86_64 is already installed.
Package libxslt-1.1.32-6.el8.x86_64 is already installed.
Dependencies resolved.
=================================================
 Package     Arch   Version         Repo    Size
=================================================
Installing:
 bzip2-devel x86_64 1.0.6-26.el8    baseos 224 k
 freetype-devel
             x86_64 2.9.1-4.el8_3.1 baseos 464 k
 gmp-devel   x86_64 1:6.1.2-10.el8  baseos 187 k
 libcurl-devel
             x86_64 7.61.1-22.el8   baseos 834 k
 libicu-devel
             x86_64 60.3-2.el8_1    baseos 922 k
 libjpeg-turbo-devel
             x86_64 1.5.3-12.el8    appstream
                                           109 k
 libmcrypt   x86_64 2.5.8-26.el8    epel   109 k
 libmcrypt-devel
             x86_64 2.5.8-26.el8    epel    18 k
 libpng-devel
             x86_64 2:1.6.34-5.el8  baseos 327 k
 libxml2-devel
             x86_64 2.9.7-9.el8_4.2 appstream
                                           1.0 M
 libxslt-devel
             x86_64 1.1.32-6.el8    appstream
                                           323 k
 mhash       x86_64 0.9.9.9-20.el8  epel   113 k
 mhash-devel x86_64 0.9.9.9-20.el8  epel    30 k
 openldap-devel
             x86_64 2.4.46-18.el8   baseos 811 k
 php-mysqlnd x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66
                                    appstream
                                           190 k
 readline-devel
             x86_64 7.0-10.el8      baseos 204 k
Installing dependencies:
 cyrus-sasl  x86_64 2.1.27-5.el8    baseos  96 k
 cyrus-sasl-devel
             x86_64 2.1.27-5.el8    baseos 128 k
 gmp-c++     x86_64 1:6.1.2-10.el8  baseos  33 k
 libgcrypt-devel
             x86_64 1.8.5-6.el8     baseos 149 k
 libgpg-error-devel
             x86_64 1.31-1.el8      baseos  64 k
 php-common  x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66
                                    appstream
                                           661 k
 php-pdo     x86_64 7.2.24-1.module_el8.2.0+313+b04d0a66
                                    appstream
                                           122 k
Enabling module streams:
 httpd              2.4                         
 nginx              1.14                        
 php                7.2                         

Transaction Summary
=================================================
Install  23 Packages

Total download size: 7.0 M
Installed size: 35 M
Downloading Packages:
(1/23): libjpeg- 9.0 kB/s | 109 kB     00:12    
(2/23): libxslt-  17 kB/s | 323 kB     00:19    
(3/23): php-mysq 120 kB/s | 190 kB     00:01    
(4/23): libxml2-  50 kB/s | 1.0 MB     00:21    
(5/23): php-pdo- 138 kB/s | 122 kB     00:00    
(6/23): php-comm  68 kB/s | 661 kB     00:09    
(7/23): bzip2-de 260 kB/s | 224 kB     00:00    
(8/23): cyrus-sa 135 kB/s |  96 kB     00:00    
(9/23): cyrus-sa 178 kB/s | 128 kB     00:00    
(10/23): gmp-c++  62 kB/s |  33 kB     00:00    
(11/23): freetyp 418 kB/s | 464 kB     00:01    
(12/23): gmp-dev 233 kB/s | 187 kB     00:00    
(13/23): libgpg- 130 kB/s |  64 kB     00:00    
(14/23): libgcry 220 kB/s | 149 kB     00:00    
(15/23): libpng- 403 kB/s | 327 kB     00:00    
(16/23): libcurl 433 kB/s | 834 kB     00:01    
(17/23): readlin 274 kB/s | 204 kB     00:00    
(18/23): libicu- 486 kB/s | 922 kB     00:01    
(19/23): openlda 713 kB/s | 811 kB     00:01    
(20/23): libmcry 7.0 kB/s |  18 kB     00:02    
(21/23): mhash-d 8.0 kB/s |  30 kB     00:03    
(22/23): libmcry 5.2 kB/s | 109 kB     00:21    
[MIRROR] mhash-0.9.9.9-20.el8.x86_64.rpm: Curl error (28): Timeout was reached for http://linux.domainesia.com/fedora/fedora-epel/8/Everything/x86_64/Packages/m/mhash-0.9.9.9-20.el8.x86_64.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
[MIRROR] mhash-0.9.9.9-20.el8.x86_64.rpm: Curl error (28): Timeout was reached for https://linux.domainesia.com/fedora/fedora-epel/8/Everything/x86_64/Packages/m/mhash-0.9.9.9-20.el8.x86_64.rpm [Operation timed out after 30000 milliseconds with 0 out of 0 bytes received]
(23/23): mhash-0.9.9.9-20.el8.x86_64.rpm                                       1.4 kB/s | 113 kB     01:20    
---------------------------------------------------------------------------------------------------------------
Total                                                                           67 kB/s | 7.0 MB     01:46     
Extra Packages for Enterprise Linux 8 - x86_64                                 1.6 MB/s | 1.6 kB     00:00    
Importing GPG key 0x2F86D6A1:
 Userid     : "Fedora EPEL (8) <epel@fedoraproject.org>"
 Fingerprint: 94E2 79EB 8D8F 25B2 1810 ADF1 21EA 45AB 2F86 D6A1
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                       1/1 
  Installing       : libgpg-error-devel-1.31-1.el8.x86_64                                                 1/23 
  Running scriptlet: libgpg-error-devel-1.31-1.el8.x86_64                                                 1/23 
  Installing       : libgcrypt-devel-1.8.5-6.el8.x86_64                                                   2/23 
  Running scriptlet: libgcrypt-devel-1.8.5-6.el8.x86_64                                                   2/23 
  Installing       : mhash-0.9.9.9-20.el8.x86_64                                                          3/23 
  Installing       : libmcrypt-2.5.8-26.el8.x86_64                                                        4/23 
  Installing       : libpng-devel-2:1.6.34-5.el8.x86_64                                                   5/23 
  Installing       : gmp-c++-1:6.1.2-10.el8.x86_64                                                        6/23 
  Running scriptlet: gmp-c++-1:6.1.2-10.el8.x86_64                                                        6/23 
  Running scriptlet: cyrus-sasl-2.1.27-5.el8.x86_64                                                       7/23 
  Installing       : cyrus-sasl-2.1.27-5.el8.x86_64                                                       7/23 
  Running scriptlet: cyrus-sasl-2.1.27-5.el8.x86_64                                                       7/23 
  Installing       : cyrus-sasl-devel-2.1.27-5.el8.x86_64                                                 8/23 
  Installing       : bzip2-devel-1.0.6-26.el8.x86_64                                                      9/23 
  Installing       : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                              10/23 
  Installing       : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                 11/23 
  Installing       : libxml2-devel-2.9.7-9.el8_4.2.x86_64                                                12/23 
  Installing       : libxslt-devel-1.1.32-6.el8.x86_64                                                   13/23 
  Installing       : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                             14/23 
  Installing       : freetype-devel-2.9.1-4.el8_3.1.x86_64                                               15/23 
  Installing       : openldap-devel-2.4.46-18.el8.x86_64                                                 16/23 
  Installing       : gmp-devel-1:6.1.2-10.el8.x86_64                                                     17/23 
  Running scriptlet: gmp-devel-1:6.1.2-10.el8.x86_64                                                     17/23 
  Installing       : libmcrypt-devel-2.5.8-26.el8.x86_64                                                 18/23 
  Installing       : mhash-devel-0.9.9.9-20.el8.x86_64                                                   19/23 
  Installing       : readline-devel-7.0-10.el8.x86_64                                                    20/23 
  Running scriptlet: readline-devel-7.0-10.el8.x86_64                                                    20/23 
  Installing       : libicu-devel-60.3-2.el8_1.x86_64                                                    21/23 
  Installing       : libcurl-devel-7.61.1-22.el8.x86_64                                                  22/23 
  Installing       : libjpeg-turbo-devel-1.5.3-12.el8.x86_64                                             23/23 
  Running scriptlet: libjpeg-turbo-devel-1.5.3-12.el8.x86_64                                             23/23 
  Verifying        : libjpeg-turbo-devel-1.5.3-12.el8.x86_64                                              1/23 
  Verifying        : libxml2-devel-2.9.7-9.el8_4.2.x86_64                                                 2/23 
  Verifying        : libxslt-devel-1.1.32-6.el8.x86_64                                                    3/23 
  Verifying        : php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                               4/23 
  Verifying        : php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                              5/23 
  Verifying        : php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                  6/23 
  Verifying        : bzip2-devel-1.0.6-26.el8.x86_64                                                      7/23 
  Verifying        : cyrus-sasl-2.1.27-5.el8.x86_64                                                       8/23 
  Verifying        : cyrus-sasl-devel-2.1.27-5.el8.x86_64                                                 9/23 
  Verifying        : freetype-devel-2.9.1-4.el8_3.1.x86_64                                               10/23 
  Verifying        : gmp-c++-1:6.1.2-10.el8.x86_64                                                       11/23 
  Verifying        : gmp-devel-1:6.1.2-10.el8.x86_64                                                     12/23 
  Verifying        : libcurl-devel-7.61.1-22.el8.x86_64                                                  13/23 
  Verifying        : libgcrypt-devel-1.8.5-6.el8.x86_64                                                  14/23 
  Verifying        : libgpg-error-devel-1.31-1.el8.x86_64                                                15/23 
  Verifying        : libicu-devel-60.3-2.el8_1.x86_64                                                    16/23 
  Verifying        : libpng-devel-2:1.6.34-5.el8.x86_64                                                  17/23 
  Verifying        : openldap-devel-2.4.46-18.el8.x86_64                                                 18/23 
  Verifying        : readline-devel-7.0-10.el8.x86_64                                                    19/23 
  Verifying        : libmcrypt-2.5.8-26.el8.x86_64                                                       20/23 
  Verifying        : libmcrypt-devel-2.5.8-26.el8.x86_64                                                 21/23 
  Verifying        : mhash-0.9.9.9-20.el8.x86_64                                                         22/23 
  Verifying        : mhash-devel-0.9.9.9-20.el8.x86_64                                                   23/23 

Installed:
  bzip2-devel-1.0.6-26.el8.x86_64                                                                              
  cyrus-sasl-2.1.27-5.el8.x86_64                                                                               
  cyrus-sasl-devel-2.1.27-5.el8.x86_64                                                                         
  freetype-devel-2.9.1-4.el8_3.1.x86_64                                                                        
  gmp-c++-1:6.1.2-10.el8.x86_64                                                                                
  gmp-devel-1:6.1.2-10.el8.x86_64                                                                              
  libcurl-devel-7.61.1-22.el8.x86_64                                                                           
  libgcrypt-devel-1.8.5-6.el8.x86_64                                                                           
  libgpg-error-devel-1.31-1.el8.x86_64                                                                         
  libicu-devel-60.3-2.el8_1.x86_64                                                                             
  libjpeg-turbo-devel-1.5.3-12.el8.x86_64                                                                      
  libmcrypt-2.5.8-26.el8.x86_64                                                                                
  libmcrypt-devel-2.5.8-26.el8.x86_64                                                                          
  libpng-devel-2:1.6.34-5.el8.x86_64                                                                           
  libxml2-devel-2.9.7-9.el8_4.2.x86_64                                                                         
  libxslt-devel-1.1.32-6.el8.x86_64                                                                            
  mhash-0.9.9.9-20.el8.x86_64                                                                                  
  mhash-devel-0.9.9.9-20.el8.x86_64                                                                            
  openldap-devel-2.4.46-18.el8.x86_64                                                                          
  php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                                       
  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                                                          
  readline-devel-7.0-10.el8.x86_64                                                                             

Complete!

编译安装php

[root@xk ~]# cd /usr/src/
[root@xk src]# tar xf php-8.2.3.tar 
[root@xk src]# cd php-8.2.3
[root@xk php-8.2.3]# ./configure --prefix=/usr/local/php7 \
> --with-config-file-path=/etc \
> --enable-fpm \
> --enable-inline-optimization \
> --disable-debug \
> --disable-rpath \
> --enable-shared \
> --enable-soap \
> --with-openssl \
> --enable-bcmath \
> --with-iconv \
> --with-bz2 \
sqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix> --enable-calendar \
> --with-curl \
> --enable-exif \
> --enable-ftp \
> --with-gd \
> --with-jpeg-dir \
> --with-png-dir \
> --with-zlib-dir \
> --with-freetype-dir \
> --with-gettext \
> --enable-json \
> --enable-mbstring \
> --enable-pdo \
> --with-mysqli=mysqlnd \
> --with-pdo-mysql=mysqlnd \
> --with-readline \
> --enable-shmop \
> --enable-simplexml \
> --enable-sockets \
> --enable-zip \
> --enable-mysqlnd-compression-support \
> --with-pear \
> --enable-pcntl \
> --enable-posix
configure: WARNING: unrecognized options: --enable-inline-optimization, --with-gd, --with-jpeg-dir, --with-png-dir, --with-freetype-dir, --enable-json, --enable-zip
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
......................................................................................

没找到Package 'sqlite3'包,安装其需要的包

[root@xk php-8.2.3]# yum -y install sqlite
Last metadata expiration check: 3:09:10 ago on Mon 20 Feb 2023 02:42:18 PM CST.
Dependencies resolved.
=================================================
 Package Arch    Version           Repo     Size
=================================================
Installing:
 sqlite  x86_64  3.26.0-15.el8     baseos  668 k

Transaction Summary
=================================================
Install  1 Package

Total download size: 668 k
Installed size: 1.3 M
Downloading Packages:
sqlite-3.26.0-15 273 kB/s | 668 kB     00:02    
-------------------------------------------------
Total            273 kB/s | 668 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                         1/1 
  Installing       : sqlite-3.26.0-15.el8.   1/1 
  Running scriptlet: sqlite-3.26.0-15.el8.   1/1 
  Verifying        : sqlite-3.26.0-15.el8.   1/1 

Installed:
  sqlite-3.26.0-15.el8.x86_64                    

Complete!

发现不兼容,安装php早些的版本

[root@xk php-7.1.10]# ./configure --prefix=/usr/local/php7 --with-config-file-path=/etc --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-openssl --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --with-gettext --enable-json --enable-mbstring --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --enable-shmop --enable-simplexml --enable-sockets --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-pcntl --enable-posix
编译安装
[root@xk php-7.1.10]#dnf -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
[root@xk php-7.1.10]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)
编译过程略
[root@xk php-7.1.10]# make install
安装过程略

安装后配置

[root@xk ~]# echo 'export PATH=/usr/local/php7/bin:/usr/local/php7:sbin:$PATH' > /etc/profile.d/php.sh
[root@xk ~]# source /etc/profile.d/php.sh
[root@xk ~]# ln -s /usr/local/php7/include /usr/include/php
[root@xk ~]# echo '/usr/local/php7/lib' /etc/ld.so.conf.d/php.conf
[root@xk ~]# ldconfig
[root@xk php-7.2.8]# which php
/usr/local/php7/bin/php
[root@xk php-7.2.8]# php -v
PHP 7.2.8 (cli) (built: Aug 16 2018 13:27:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

配置php-fp

[root@xk php-7.1.10]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? yes
[root@xk php-7.1.10]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@xk php-7.1.10]# chmod +x /etc/rc.d/init.d/php-fpm
[root@xk php-7.1.10]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf[root@xk php-7.1.10]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
[root@xk php-7.1.10]# 

编辑php-fpm的配置文件

[root@xk php-7.1.10]# vim /usr/local/php7/etc/php-fpm.conf
pm.max_children = 50 ;最多同时提供50个进程提供50个并发服务
pm.start_servers = 5 ;启动时启动5个进程
pm.min_spare_servers = 2 ;最小空闲进程数
pm.max_spare_servers = 8 ;最大空闲进程数
[root@xk php-7.1.10]# tail /usr/local/php7/etc/php-fpm.conf
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local/php7 otherwise
include=/usr/local/php7/etc/php-fpm.d/*.conf
pm.max_children = 50 
pm.start_servers = 5 
pm.min_spare_servers = 2 
pm.max_spare_servers = 8 
[root@xk php-7.1.10]#

启动php-fpm

[root@xk ~]# service php-fpm start
Starting php-fpm  done
[root@xk ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port           Peer Address:Port        Process        
LISTEN   0        128              0.0.0.0:111                 0.0.0.0:*                          
LISTEN   0        128              0.0.0.0:22                  0.0.0.0:*                          
LISTEN   0        128            127.0.0.1:9000                0.0.0.0:*                          
LISTEN   0        128                 [::]:111                    [::]:*                          
LISTEN   0        128                    *:80                        *:*                          
LISTEN   0        128                 [::]:22                     [::]:*                          
LISTEN   0        80                     *:3306                      *:*                       

[root@xk ~]# ps -ef|grep php
root      287588       1  0 18:49 ?        00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody    287589  287588  0 18:49 ?        00:00:00 php-fpm: pool www
nobody    287590  287588  0 18:49 ?        00:00:00 php-fpm: pool www
nobody    287591  287588  0 18:49 ?        00:00:00 php-fpm: pool www
nobody    287592  287588  0 18:49 ?        00:00:00 php-fpm: pool www
nobody    287593  287588  0 18:49 ?        00:00:00 php-fpm: pool www
root      287596  126872  0 18:50 pts/0    00:00:00 grep --color=auto php

使用域名访问

启用代理模块,

编辑httpd.conf文件,取消以下两行内容的注释:

  • LoadModule proxy_module modules/mod_proxy.so

  • LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

[root@xk ~]# cd /etc/httpd24/
[root@xk httpd24]# vim httpd.conf

启用httpd的相关模块

[root@xk httpd24]# sed -i '/proxy_module/s/#//g' /etc/httpd24/httpd.conf
[root@xk httpd24]# sed -i '/proxy_fcgi_module/s/#//g' /etc/httpd24/httpd.conf

配置虚拟主机

[root@localhost~]# vim /etc/httpd24/httpd.conf//在配置文件的最后加入以下内容

<VirtualHost *:80>
DocumentRoot"/usr/local/apache/htdocs/wangqing.com"
ServerName www.wangqing.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/wangqing.com/$1
<Directory"/usr/local/apache/htdocs/wangqing.com">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>

创建虚拟主机目录并生成php测试页面

[root@xk htdocs]# mkdir wangqing.com
[root@xk htdocs]# cd wangqing.com/
[root@xk wangqing.com]# ls
[root@xk wangqing.com]# vim index.php
[root@xk wangqing.com]# cat index.php
<?php
phpinfo();
?>
[root@xk wangqing.com]# cd ../../ 
[root@xk apache]# chown -R apache.apache /usr/local/apache/htdocs/
[root@xk apache]# ll /usr/local/apache/htdocs/ -ddrwxr-xr-x. 3 apache apache 59 Feb 20 19:08 /usr/local/apache/htdocs/

vim /etc/httpd24/httpd.conf,

[root@xk apache]# vim /etc/httpd24/httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php#添加此行
AddType application/x-httpd-php-source .phps#添加此行
[root@xk~]# sed -i '/ DirectoryIndex/s/index.html/index.php index.html/g' /etc/httpd24/httpd.conf

重启apache服务

[root@localhost ~]# apachectl stop
[root@localhost ~]# apachectl start
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*

验证

成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值