系统平台 | IP | 需要安装的服务 |
Redhat8 | 192.168.160.130 | httpd-2.4 mysql php php-mysql |
httpd——MySQL——php
在阿里云里找
再把云相关的干掉
[root@localhost yum.repos.d]# 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 12053 0 --:--:-- --:--:-- --:--:-- 11995
[root@localhost yum.repos.d]# ls
CentOS-Base.repo
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost yum.repos.d]# cd
[root@localhost ~]# yum clean all //清理一下缓存
正在更新 Subscription Management 软件仓库。
无法读取客户身份
本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。
0 文件已删除
[root@localhost ~]#
[root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@localhost ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache //重建缓存
[root@localhost ~]# yum -y install wget vim //下载一下wget和vim命令
Index of /apache 在里面找源码包(apr和httpd文件夹里)
[root@localhost ~]# yum groups mark install 'Development Tools' //标记安装一下
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache //-r系统用户,-M没有目录,-s不允许登录,创建用户的时候会自动创建跟用户名相同的组
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make //安装依赖包
//下载源码包
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
[root@localhost ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz
//解压
[root@localhost ~]# tar xf apr-1.7.0.tar.gz
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz
[root@localhost ~]# tar xf httpd-2.4.53.tar.gz
//编译apr-1.7.0
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# vim configure
$RM "$cfgfile" //把这个删掉
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install
//编译apr-util-1.6.1
[root@localhost ~]# cd apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install
//编译httpd-2.4.53
[root@localhost ~]# cd httpd-2.4.53
[root@localhost 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@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install
//设置环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@localhost ~]# source /etc/profile.d/apache.sh
[root@localhost ~]# which httpd
/usr/local/apache/bin/httpd
//映射
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/apache
//man文档
[root@localhost ~]# vim /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man
//怎么来启动使用这个服务
//关闭防火墙
[root@localhost ~]# systemctl disable --now firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# vim /etc/selinux/config
SELINUX=disabled //把这个改为disabled
//启动服务
[root@localhost ~]# 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 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
//如果想设置成systemctl来控制启动,并且设置开机自启
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# ls sshd.service
sshd.service
[root@localhost system]# cp sshd.service httpd.service
cp:是否覆盖'httpd.service'? y
[root@localhost system]# vim httpd.service //配置修改
[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@localhost system]# systemctl daemon-reload
[root@localhost system]# cd
[root@localhost ~]# systemctl status httpd //查看一下这个服务,有了
[root@localhost ~]# systemctl start httpd //现在可以用systemctl来控制启动了
[root@localhost ~]# systemctl enable httpd //设置开机自启
//用xftp传输到虚拟的/usr/src里
[root@localhost ~]# ls /usr/src
debug kernels mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
//创建用户的时候会自动创建组
[root@localhost ~]# cd /usr/src
[root@localhost src]# useradd -r -M -s /sbin/nologin mysql
[root@localhost src]# id mysql
uid=995(mysql) gid=992(mysql) groups=992(mysql)
[root@localhost src]# ls /usr/local
bin games lib libexec share
etc include lib64 sbin src
[root@localhost src]# tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# ls /usr/local
bin include libexec share
etc lib mysql-5.7.37-linux-glibc2.12-x86_64 src
games lib64 sbin
[root@localhost src]# cd /usr/local/
[root@localhost local]#
//更改名字为mysql
[root@localhost local]# mv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ls
bin games lib libexec sbin src
etc include lib64 mysql share
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Jun 21 2021 bin
drwxr-xr-x. 2 root root 6 Jun 21 2021 etc
drwxr-xr-x. 2 root root 6 Jun 21 2021 games
drwxr-xr-x. 2 root root 6 Jun 21 2021 include
drwxr-xr-x. 2 root root 6 Jun 21 2021 lib
drwxr-xr-x. 3 root root 17 Apr 27 16:32 lib64
drwxr-xr-x. 2 root root 6 Jun 21 2021 libexec
drwxr-xr-x. 9 root root 129 Jun 28 17:04 mysql
drwxr-xr-x. 2 root root 6 Jun 21 2021 sbin
drwxr-xr-x. 5 root root 49 Apr 27 16:32 share
drwxr-xr-x. 2 root root 6 Jun 21 2021 src
//修改目录/usr/local/mysql的属主属组
[root@localhost local]# chown -R mysql.mysql mysql
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Jun 21 2021 bin
drwxr-xr-x. 2 root root 6 Jun 21 2021 etc
drwxr-xr-x. 2 root root 6 Jun 21 2021 games
drwxr-xr-x. 2 root root 6 Jun 21 2021 include
drwxr-xr-x. 2 root root 6 Jun 21 2021 lib
drwxr-xr-x. 3 root root 17 Apr 27 16:32 lib64
drwxr-xr-x. 2 root root 6 Jun 21 2021 libexec
drwxr-xr-x. 9 mysql mysql 129 Jun 28 17:04 mysql
drwxr-xr-x. 2 root root 6 Jun 21 2021 sbin
drwxr-xr-x. 5 root root 49 Apr 27 16:32 share
drwxr-xr-x. 2 root root 6 Jun 21 2021 src
[root@localhost local]# ls mysql/
bin include LICENSE README support-files
docs lib man share
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh
[root@localhost local]# which mysql
/usr/local/mysql/bin/mysql
//要告诉路径
[root@localhost local]# cd mysql/
[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]# ls
bin include LICENSE README support-files
docs lib man share
[root@localhost mysql]# ls /usr/
bin include lib64 local share tmp
games lib libexec sbin src
[root@localhost mysql]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@localhost mysql]# vi /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@localhost mysql]# ldconfig //重新读取一下路径
[root@localhost mysql]# cd
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data
[root@localhost ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Jun 28 17:31 data
[root@localhost ~]# which mysqld
/usr/local/mysql/bin/mysqld
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data
2022-06-28T09:35:52.428070Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-06-28T09:35:52.617289Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-06-28T09:35:52.652877Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-06-28T09:35:52.706287Z 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: b3cb1102-f6c5-11ec-a88a-000c29d84a24.
2022-06-28T09:35:52.706953Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-06-28T09:35:53.108617Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-06-28T09:35:53.108629Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-06-28T09:35:53.109012Z 0 [Warning] CA certificate ca.pem is self signed.
2022-06-28T09:35:53.140487Z 1 [Note] A temporary password is generated for root@localhost: /cNErFpy9A#> //临时密码只能用一次
//先将密码保存下来
nerated for root@localhost: /cNErFpy9A#>
[root@localhost ~]# echo '/cNErFpy9A#>' > pass
[root@localhost ~]# ls
anaconda-ks.cfg pass
[root@localhost ~]# cat /etc/my.cnf
cat: /etc/my.cnf: No such file or directory
[root@localhost ~]# vi /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[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
#sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[root@localhost ~]#
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin include LICENSE README support-files
docs lib man share
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[root@localhost support-files]# cp mysql.server mysqld
[root@localhost support-files]# ll
total 36
-rw-r--r--. 1 mysql mysql 773 Nov 30 2021 magic
-rwxr-xr-x. 1 root root 10576 Jun 28 17:47 mysqld
-rwxr-xr-x. 1 mysql mysql 1061 Nov 30 2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql 894 Nov 30 2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Nov 30 2021 mysql.server
[root@localhost support-files]# chown -R mysql.mysql mysqld
[root@localhost support-files]# ll
total 36
-rw-r--r--. 1 mysql mysql 773 Nov 30 2021 magic
-rwxr-xr-x. 1 mysql mysql 10576 Jun 28 17:47 mysqld
-rwxr-xr-x. 1 mysql mysql 1061 Nov 30 2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql 894 Nov 30 2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Nov 30 2021 mysql.server
[root@localhost support-files]# vi mysqld
basedir=/usr/local/mysql
datadir=/opt/data //找到里面这个为空的地方加上这些 比如:datadir=
[root@localhost ~]# /usr/local/mysql/support-files/mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]# ps -ef|grep mysqld
root 1862 1 0 17:57 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pid
mysql 2050 1862 0 17:57 pts/0 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=localhost.localdomain.err --pid-file=/opt/data/mysql.pid --socket=/tmp/mysql.sock --port=3306
root 2086 1668 0 18:00 pts/0 00:00:00 grep --color=auto mysqld
[root@localhost ~]# ls
anaconda-ks.cfg pass
[root@localhost ~]# cat pass
/cNErFpy9A#>
[root@localhost ~]# mysql -uroot -p'/cNErFpy9A#>'
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory //出现这个报错,没有这个包
[root@localhost ~]# yum provides libncurses.so.5 //查看属于哪个包
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:00:26 ago on Tue 28 Jun 2022 06:12:22 PM CST.
ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses
...: compatibility libraries
Repo : base
Matched from:
Provide : libncurses.so.5
[root@localhost ~]# yum -y install ncurses-compat-libs
//登录
//修改密码
[root@localhost ~]# mysql -uroot -p'/cNErFpy9A#>'
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('ltt429520.');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
Bye
//用新密码验证一下
[root@localhost ~]# mysql -uroot -p'ltt429520.'
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> quit
Bye
[root@localhost ~]#
[root@localhost ~]# cp /usr/lib/systemd/system/sshd.service mysqld.service
[root@localhost ~]# ls
anaconda-ks.cfg mysqld.service pass
[root@localhost ~]# vim mysqld.service
[root@localhost ~]# cat mysqld.service
[Unit]
Description=mysql server daemon
After=network.target sshd-keygen.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysqld start
ExecStop=/usr/local/mysql/support-files/mysqld stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@localhost ~]# mv mysqld.service /usr/lib/systemd/system/
[root@localhost ~]# ls
anaconda-ks.cfg pass
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/selinux/config
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl status mysqld
● mysqld.service - mysql server daemon
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; dis>
Active: inactive (dead)
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]# pkill mysqld
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]# systemctl start mysqld //启动
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]# mysql -uroot -p'ltt429520.'
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 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> quit
Bye
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# systemctl status mysqld
● mysqld.service - mysql server daemon
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; ena>
Active: active (running) since Tue 2022-06-28 18:48:13 CST;>
Main PID: 10913 (mysqld_safe)
Tasks: 29 (limit: 11216)
Memory: 186.0M
CGroup: /system.slice/mysqld.service
├─10913 /bin/sh /usr/local/mysql/bin/mysqld_safe -->
└─11103 /usr/local/mysql/bin/mysqld --basedir=/usr/>
Jun 28 18:48:12 localhost.localdomain systemd[1]: Starting mys>
Jun 28 18:48:13 localhost.localdomain mysqld[10900]: Starting >
Jun 28 18:48:13 localhost.localdomain systemd[1]: Started mysq>
[root@localhost ~]# reboot
//看看开机自启设置成功没
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# echo $?
0
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]# systemctl status mysqld
● mysqld.service - mysql server daemon
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; ena>
Active: active (running) since Tue 2022-06-28 18:50:34 CST;>
Process: 987 ExecStart=/usr/local/mysql/support-files/mysqld>
Main PID: 1011 (mysqld_safe)
Tasks: 28 (limit: 11216)
Memory: 217.0M
CGroup: /system.slice/mysqld.service
├─1011 /bin/sh /usr/local/mysql/bin/mysqld_safe --d>
└─1399 /usr/local/mysql/bin/mysqld --basedir=/usr/l>
Jun 28 18:50:31 localhost.localdomain systemd[1]: Starting mys>
Jun 28 18:50:34 localhost.localdomain mysqld[987]: Starting My>
Jun 28 18:50:34 localhost.localdomain systemd[1]: Started mysq>
[root@localhost ~]# mysql -uroot -p'ltt429520.'
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 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> quit
Bye
//安装依赖包
[root@localhost ~]# 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 sqlite-devel libzip-devel
[root@localhost ~]# yum -y install https://repo.almalinux.org/almalinux/8/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
[root@localhost ~]# yum install -y libzip-devel
//下载php源码包
[root@localhost ~]# wget https://www.php.net/distributions/php-7.4.29.tar.xz
//解压
[root@localhost ~]# tar xf php-7.4.29.tar.xz
[root@localhost ~]# cd php-7.4.29/
./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 \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-json \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
[root@localhost ~]# make
[root@localhost ~]# make install //make编译
//创建环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@localhost ~]# source /etc/profile.d/php7.sh
[root@localhost ~]# which php
/usr/local/php7/bin/php
[root@localhost php-7.4.29]# ln -s /usr/local/php7/include/ /usr/include/php
[root@localhost php-7.4.29]# echo '/usr/local/php7/lib' > /etc/ld.so.conf.d/php.conf
[root@localhost php-7.4.29]# ldconfig
//配置php-fpm
[root@localhost php-7.4.29]# \cp php.ini-production /etc/php.ini
[root@localhost php-7.4.29]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.4.29]# chmod +x /etc/rc.d/init.d/php-fpm
[root@localhost php-7.4.29]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@localhost php-7.4.29]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
[root@localhost php-7.4.29]# cd /usr/local/php7/etc/php-fpm.d/
[root@localhost php-fpm.d]# pwd
/usr/local/php7/etc/php-fpm.d
[root@localhost php-fpm.d]# vim www.conf
listen = 127.0.0.1:9000
//启动php-fpm
[root@localhost php-fpm.d]# service php-fpm start
Starting php-fpm done
[root@localhost php-fpm.d]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
//配置service文件
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# cp httpd.service php.service
[root@localhost system]# vi php.service
[root@localhost system]# cat php.service
[Unit]
Description=php-fpm server daemon
After=network.target sshd-keygen.target
[Service]
Type=forking
ExecStart=/etc/init.d/php-fpm start
ExecStop=/usr/bin/kill -9 $MAINPID
ExecReload=/usr/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@localhost system]# systemctl daemon-reload
//启动代理模块
[root@localhost ~]# cd /usr/local/apache/conf/
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# vim httpd.conf
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so //将#删掉,取消注释
//创建测试文件
[root@localhost ~]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# mkdir test.example.com
[root@localhost htdocs]# cd test.example.com/
[root@localhost test.example.com]# vi index.php
//将署组更改
[root@localhost test.example.com]# chown -R apache.apache /usr/local/apache/htdocs/
[root@localhost test.example.com]# cd ..
[root@localhost htdocs]# ls
index.html test.example.com
[root@localhost htdocs]# ll
total 4
-rw-r--r--. 1 apache apache 45 Jun 12 2007 index.html
drwxr-xr-x 2 apache apache 23 Jul 6 17:46 test.example.com
//配置虚拟主机
[root@localhost ~]# cd /usr/local/apache/conf/
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# vim httpd.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
DocumentRoot "/usr/local/apache/htdocs/test.example.com"
ServerName test.example.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/test.example.com/$1
Options none
AllowOverride none
Require all granted
//在配置文件的最后加入以下内容
//搜索AddType,添加以下内容
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php //添加
AddType application/x-httpd-php-source .phps //添加
//同时在DirectoryIndex index.html中间加上 index.php
DirectoryIndex index.php index.html
[root@localhost ~]# systemctl restart httpd //重启apache服务
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
在真机的host文件添加ip对应的域名做映射
192.168.160.130为虚拟机ip
test.example.com为域名
//记事本里添加
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 activate.navicat.com
192.168.160.130 test.example.com
[root@localhost ~]# systemctl stop httpd
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
192.168.160.130访问
test.example.com访问