-
准备工作
- 先去阿里云镜像站下载CentOS 8;
[root@cxr ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo //直接复制粘贴
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2495 100 2495 0 0 5400 0 --:--:-- --:--:-- --:--:-- 5388
[root@cxr ~]# ls /etc/yum.repos.d/ //已经下载成功
CentOS-Base.repo cxr.repo redhat.repo
//非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,使用下面的命令删除就不会在弹出来了
[root@cxr ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@cxr ~]# dnf clean all //清理一下缓存
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
12 文件已删除
//下载epel源
[root@cxr ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
//安装过程以省略
//将 repo 配置中的地址替换为阿里云镜像站地址
[root@cxr ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@cxr ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@cxr ~]# dnf clean all //清理缓存
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
23 文件已删除
[root@cxr ~]# dnf makecache //重建一下缓存
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
CentOS-8.5.2111 - Base - mirrors.aliyun.com 1.8 MB/s | 4.6 MB 00:02
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 42 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com 1.3 MB/s | 8.4 MB 00:06
BaseOS 442 MB/s | 2.3 MB 00:00
Extra Packages for Enterprise Linux Modular 8 - x86_ 738 kB/s | 1.0 MB 00:01
Extra Packages for Enterprise Linux 8 - x86_64 1.2 MB/s | 11 MB 00:08
元数据缓存已建立。
[root@cxr ~]# yum -y install wget vim //安装wget和vim
//安装开发工具包
[root@cxr ~]# yum groups mark install 'Development Tools'
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
上次元数据过期检查:0:06:01 前,执行于 2022年04月21日 星期四 03时05分46秒。
依赖关系解决。
=====================================================================================
软件包 架构 版本 仓库 大小
=====================================================================================
安装组:
Development Tools
事务概要
=====================================================================================
确定吗?[y/N]: y
完毕!
//创建apache服务的用户和组
[root@cxr ~]# useradd -r -M -s /sbin/nologin apache
//安装依赖包
[root@cxr ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
- 安装和配置par以及par-util
- 包在apache官网可以下载
[root@cxr ~]# tar -xf apr-1.7.0.tar.gz
[root@cxr ~]# tar -xf apr-util-1.6.1.tar.gz
[root@cxr ~]# tar -xf httpd-2.4.53.tar.gz
[root@cxr ~]# cd apr-1.7.0
[root@cxr apr-1.7.0]# vim configure
$RM "$cfgfile" //将此行加上注释,或者删除此行
- 配置和编译par
[root@cxr apr-1.7.0]# ./configure --prefix=/usr/local/apr //配置过长省略一部分
...........
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
[root@cxr apr-1.7.0]#
[root@cxr apr-1.7.0]# make && make install //编译过程太长省略一部分
make[1]: 进入目录“/root/apr-1.7.0”
/bin/sh /root/apr-1.7.0/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I./include -I/root/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/root/apr-1.7.0/include/arch/unix -I/root/apr-1.7.0/include -I/root/apr-1.7.0/include/private -I/root/apr-1.7.0/include/private -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo
/root/apr-1.7.0/build/mkdir.sh tools
.............
[root@cxr apr-1.7.0]#
[root@cxr ~]# cd apr-util-1.6.1/
[root@cxr apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr //配置过长已省略
[root@cxr apr-util-1.6.1]# make && make install //编译过程太长已省略
[root@cxr httpd-2.4.53]# ./configure --prefix=/usr/local/apache --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@cxr httpd-2.4.53]# make && make install //编译安装过长已省略
//安装后配置
[root@cxr httpd-2.4.53]# cd
[root@cxr ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@cxr ~]# source /etc/profile.d/httpd.sh
[root@cxr ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@cxr ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
[root@cxr ~]#
//取消ServerName前面的注释
[root@cxr system]# cp sshd.service httpd.service //复制一个sshd.service
[root@cxr system]# vim httpd.service //编辑成httpd配置文件
[Unit]
Description=httpd server daemon
After=network.target sshd-keygen.target
[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
//保存退出
[root@cxr system]# systemctl daemon-reload //设置开机自启
[root@cxr system]# cd
[root@cxr ~]# systemctl status httpd //查看一下状态
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: d>
lActive: inactive (dead)
[root@cxr ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@cxr ~]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: di>
Active: active (running) since Thu 2022-04-21 09:01:39 EDT; 8s ago
Process: 211691 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, stat>
Main PID: 211694 (httpd)
Tasks: 6 (limit: 23648)
Memory: 5.1M
CGroup: /system.slice/httpd.service
├─211694 /usr/local/apache/bin/httpd -k start
├─211695 /usr/local/apache/bin/httpd -k start
├─211696 /usr/local/apache/bin/httpd -k start
├─211697 /usr/local/apache/bin/httpd -k start
├─211698 /usr/local/apache/bin/httpd -k start
└─211699 /usr/local/apache/bin/httpd -k start
4月 21 09:01:39 cxr.example.com systemd[1]: Starting httpd server daemon...
4月 21 09:01:39 cxr.example.com systemd[1]: Started httpd server daemon.
[root@cxr ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
[root@cxr ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@cxr ~]# vim /etc/selinux/
[root@cxr ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled //这个改成disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@cxr ~]# setenforce 0
- 去网站访问虚拟机IP
[root@cxr extra]# cd /usr/local/apache/conf/
[root@cxr conf]# vim httpd.conf
ServerName www.example.com:80 //将这行解注释掉
[root@cxr conf]# systemctl restart httpd.service //重启一下
- 安装MySQL
// 下载mysql源
[root@cxr ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
//安装mysql源
[root@cxr ~]# rpm -ivh mysql57-community-release-el7-10.noarch.rpm
- 然后需要进到https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/ 在里面下载以下文件
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.371.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.371.el7.x86_64.rpm
- 用wget命令将它们下载到我们的虚拟机上
[root@cxr ~]# wget https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.37-1.el7.x86_64.rpm
https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.37-1.el7.x86_64.rpm
[root@cxr ~]# dnf -y install *.rpm //安装当前目录下的所有rpm包
已安装:
mysql-community-client-5.7.37-1.el7.x86_64 mysql-community-common-5.7.37-1.el7.x86_64 mysql-community-devel-5.7.37-1.el7.x86_64 mysql-community-libs-5.7.37-1.el7.x86_64
mysql-community-server-5.7.37-1.el7.x86_64 ncurses-compat-libs-6.1-7.20180224.el8.x86_64
完毕! //安装过程省略一部分
- 设置MySQL开机自启
[root@cxr ~]# systemctl enable --now mysqld
[root@cxr ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: d>
Active: active (running) since Thu 2022-04-21 09:55:34 EDT; 9s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 317813 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/>
Process: 317551 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SU>
Main PID: 317815 (mysqld)
Tasks: 27 (limit: 23648)
Memory: 335.8M
CGroup: /system.slice/mysqld.service
└─317815 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.p>
4月 21 09:55:27 cxr.example.com systemd[1]: Starting MySQL Server...
4月 21 09:55:34 cxr.example.com systemd[1]: Started MySQL Server.
[root@cxr ~]# ss -antl //查看有没有3306端口
State Recv-Q Send-Q Local Address:Prt Peer Address:Port
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
- 使用临时密码登录到MySQL
[root@cxr ~]# grep 'password' /var/log/mysqld.log //查看临时密码
2022-04-21T13:55:31.925649Z 1 [Note] A temporary password is generated for root@localhost: **iA.kF6W/e)_O**
[root@cxr ~]# mysql -uroot -p"iA.kF6W/e)_O"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.37
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('Cxr1234!'); //修改密码
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit //退出
Bye
- 给root授权
[root@cxr ~]# mysql -uroot -pCxr1234!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.37 MySQL Community Server (GPL)
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> GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'Cxr1234!'; //授权
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit //退出
- 安装php
//安装yum源
[root@cxr ~]# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@cxr ~]# rpm -e mysql57-community-release
[root@cxr ~]# yum makecache --enablerepo=remi-php74
//安装依赖包
[root@cxr ~]# 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 php72-php-mysqlnd
Updating Subscription Management repositories.el gmp gmp-devel libmcrypt libmcrypt-de
Unable to read consumer identityslt libxslt-devel mhash mhash-devel php72-php-mysqlnd
//安装过程已省略
//下载php
[root@cxr ~]# cd /usr/src/
[root@cxr src]# wget http://cn.php.net/distributions/php-7.2.8.tar.xz
//下载过程已省略....
//编译安装php
[root@localhost php-7.2.8]# ./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@cxr php-7.2.8]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)
//编译过程已省略
[root@cxr php-7.2.8]# make install
//安装过程已省略
//配置php-fpm
[root@cxr php-7.2.8]# cp php.ini-production /etc/php.ini
[root@cxr php-7.2.8]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@cxr php-7.2.8]# chmod +x /etc/rc.d/init.d/php-fpm
[root@cxr php-7.2.8]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@cxr php-7.2.8]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
[root@cxr php-7.2.8]#
//编辑php-fpm的配置文件(/usr/local/php7/etc/php-fpm.conf):
//配置fpm的相关选项为你所需要的值:
[root@cxr php-7.2.8]# vim /usr/local/php7/etc/php-fpm.conf
; - 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@cxr ~]# 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
//启动php-fpm
[root@cxr ~]# service php-fpm start
Starting php-fpm done
[root@cxr ~]# ss -antl //默认情况下,fpm监听在127.0.0.1的9000端口,也可以使用如下命令验证其是否已经监听在相应的套接字
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
[root@cxr ~]# ps -ef|grep php
root 678041 1 0 11:10 ? 00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody 678042 678041 0 11:10 ? 00:00:00 php-fpm: pool www
nobody 678043 678041 0 11:10 ? 00:00:00 php-fpm: pool www
nobody 678044 678041 0 11:10 ? 00:00:00 php-fpm: pool www
nobody 678045 678041 0 11:10 ? 00:00:00 php-fpm: pool www
nobody 678046 678041 0 11:10 ? 00:00:00 php-fpm: pool www
root 680990 21839 0 11:11 pts/2 00:00:00 grep --color=auto php
-
配置apache
-
启用代理模块
在apache httpd 2.4以后已经专门有一个模块针对FastCGI的实现,此模块为mod_proxy_fcgi.so,它其实是作为mod_proxy.so模块的扩展,因此,这两个模块都要加载,编辑httpd.conf文件,取消以下两行内容的注释: -
LoadModule proxy_module modules/mod_proxy.so
-
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
// 启用httpd的相关模块
[root@cxr conf]# sed -i '/proxy_module/s/#//g' /usr/local/apache/conf/httpd.conf
[root@cxr conf]# sed -i '/proxy_fcgi_module/s/#//g' /usr/local/apache/conf/httpd.conf
- 配置虚拟主机
- 在需要使用fcgi的虚拟主机中添加类似如下两行
ProxyRequests Off //关闭正向代理
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/PATH/TO/DOCUMENT_ROOT/$1
例如:
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/idfsoft.com/$1
以上设置表示把以.php结尾的文件请求发送到php-fpm进程,php-fpm至少需要知道运行的目录和URI,所以这里直接在fcgi://127.0.0.1:9000后指明了这两个参数,其它参数的传递已经被mod_proxy_fcgi.so进行了封装,不需要手动指定。
- 注意:
- 这里写的/var/www/html/是yum源安装方式生成的网页存放目录,这里必须改成你编译安装指定的网页存放路径,禁止直接复制我这里的路径
这里的idfsoft.com是域名,你必须改成你所使用的域名,禁止直接复制此处的域名
这里的$1表示匹配所有以.php结尾的http请求
//创建虚拟主机目录并生成php测试页面
[root@cxr conf]# mkdir /usr/local/apache/htdocs/wangqing.com
[root@cxr conf]# cat > /usr/local/apache/htdocs/wangqing.com/index.php <<EOF
[root@cxr ~]# chown -R apache.apache /usr/local/apache/htdocs/
[root@cxr ~]# ll /usr/local/apache/htdocs/ -d
drwxr-xr-x. 4 apache apache 60 4月 21 11:32 /usr/local/apache/htdocs/
[root@cxr ~]# vim /usr/local/apache/conf/httpd.conf
//在配置文件的最后加入以下内容
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/test.com"
ServerName www.test.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/test.com/$1
<Directory "/usr/local/apache/htdocs/test.com">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@cxr ~]# vim /usr/local/apache/conf/httpd.conf
//搜索AddType,添加以下内容
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
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@cxr ~]# sed -i '/ DirectoryIndex/s/index.html/index.php index.html/g' /usr/local/apache/conf/httpd.conf
[root@cxr ~]# apachectl stop
[root@cxr ~]# apachectl start
[root@cxr ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
- 验证