Skip to content
字数
708 字
阅读时间
4 分钟

安装开发环境

dnf groupinstall "Development Tools" -y
dnf install -y libtirpc libtirpc-devel rpcgen

安装Apache-httpd

安装编译环境

dnf install -y gcc gcc-c++ make pcre-devel openssl-devel expat-devel

上传软件包

![[Pasted image 20251111152810.png]] 解压软件包

tar -zxvf apr-1.7.6.tar.gz && tar -zxvf apr-util-1.6.3.tar.gz && tar -zxvf httpd-2.4.65.tar.gz

解压后的目录 ![[Pasted image 20251111152917.png]] 将apr复制到httpd中

mv apr-1.7.6 httpd-2.4.65/srclib/apr
mv apr-util-1.6.3 httpd-2.4.65/srclib/apr-util

创建编译脚本

cd httpd-2.4.65

./configure \
  --prefix=/usr/local/apache \
  --enable-so \
  --enable-ssl \
  --enable-rewrite \
  --enable-cgi \
  --enable-suexec \
  --enable-auth-digest \
  --with-ssl=/usr/lib \
  --with-suexec-caller=daemon \
  --with-suexec-docroot=/usr/local/apache/htdocs \
  --with-included-apr

出现下图表示编译脚本校验完成 ![[Pasted image 20251111153131.png]] 编译并安装

make -j$(nproc)
make install

添加到系统服务

创建系统服务文件

vi /etc/systemd/system/httpd.service

写入系统服务文件

[Unit]
Description=Apache HTTPD
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/usr/local/apache/bin/apachectl graceful
PIDFile=/usr/local/apache/logs/httpd.pid

[Install]
WantedBy=multi-user.target

重载systemctl

systemctl daemon-reload

![[Pasted image 20251111153359.png]] 查看编译安装的版本 ![[Pasted image 20251111153503.png]] 放行防火墙

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

网页访问 ![[Pasted image 20251111153716.png]]

部署静态网页

上传静态网页 ![[Pasted image 20251111154538.png]] 重启服务 访问浏览器 ![[Pasted image 20251111154610.png]]

DNS解析

在/var/named/mlishu.local.zone添加www指向服务器的解析 ![[Pasted image 20251111154713.png]] 编辑完成后重启named服务 如下图就是带域名的解析 ![[Pasted image 20251111154937.png]]

安装MairaDB

安装依赖

dnf remove -y mariadb mariadb-server

dnf install -y cmake gcc-c++ libstdc++-devel ncurses-devel \
libaio-devel openssl-devel bison zlib-devel

创建用户和目录

groupadd mysql
useradd -d /usr/local/mysql -s /sbin/nologin -g mysql mysql

mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/data
mkdir -p /var/run/mysqld
mkdir -p /var/lib/mysql

chown -R mysql:mysql /usr/local/mysql /var/lib/mysql
chmod 777 -R /usr/local/mysql /var/lib/mysql

下载并解压源码

cd /opt/software
wget https://mirror.mariadb.org/mariadb-10.11.15/source/mariadb-10.11.15.tar.gz
tar -zxvf mariadb-10.11.15.tar.gz

为了提高编译速度,优先下载fmt包 ![[Pasted image 20251118150557.png]]

wget https://github.com/fmtlib/fmt/releases/download/11.0.2/fmt-11.0.2.zip
mv fmt-11.0.2.zip /opt/softwares/mariadb-10.11.15/extra/libfmt/src/

编译MariaDB

cd mariadb-10.11.15/
rm -f CMakeCache.txt
cmake . \
 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
 -DMYSQL_DATADIR=/usr/local/mysql/data \
 -DSYSCONFDIR=/etc \
 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
 -DWITH_READLINE=1 \
 -DWITH_SSL=system \
 -DWITH_ZLIB=system \
 -DWITH_LIBWRAP=0 \
 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
 -DDEFAULT_CHARSET=utf8 \
 -DDEFAULT_COLLATION=utf8_general_ci \
 -DWITHOUT_TOKUDB=1

![[Pasted image 20251118150202.png]]

make -j$(nproc) && make install

初始化MariaDB

/usr/local/mysql/scripts/mysql_install_db \
 --basedir=/usr/local/mysql \
 --datadir=/usr/local/mysql/data \
 --user=mysql \
 --defaults-file=/etc/my.cnf \
 --socket=/var/lib/mysql/mysql.sock

![[Pasted image 20251118152931.png]]

vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
vim /etc/systemd/system/mysqld.service
[Unit]
Description=MariaDB 10.11.15 database server
After=network.target

[Service]
User=mysql
Group=mysql
Type=simple
ExecStart=/usr/local/mysql/bin/mariadbd --defaults-file=/etc/my.cnf
Restart=on-failure
PIDFile=/run/mariadb/mariadb.pid

[Install]
WantedBy=multi-user.target

安装PHP

安装编译包

dnf install -y libxml2-devel libcurl-devel libxslt-devel \
libzip-devel bzip2-devel oniguruma oniguruma-devel \
krb5-devel sqlite-devel libjpeg-devel libpng-devel freetype-devel

下载源码并解压

cd /opt/softwares/
wget https://www.php.net/distributions/php-8.4.14.tar.gz
tar -zxvf php-8.4.14.tar.gz
cd php-8.4.14

配置编译参数

./configure \
 --prefix=/usr/local/php \
 --with-apxs2=/usr/local/apache/bin/apxs \
 --enable-mbstring \
 --enable-sockets \
 --with-mysqli \
 --with-pdo-mysql=mysqlnd \
 --with-openssl \
 --with-zlib \
 --enable-fpm

![[Pasted image 20251118125459.png]]

正式编译安装

make -j$(nproc)
make install

检查PHP版本

/usr/local/php/bin/php -v

![[Pasted image 20251118125959.png]] ``

LoadModule php_module modules/libphp.so
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html

部署phpMyAdmin

解压文件到/opt/softwares

[root@mlishu softwares]# ls -l
总用量 4
drwxr-xr-x. 12 root root 4096 10月  7 16:40 phpMyAdmin

找到blowfish_secret字符串,添加32位字符串

$cfg['blowfish_secret'] = 'gjer$fdS023fFSdf2kfhLKJH3298sfhs';

贡献者

The avatar of contributor named as lishu620 lishu620

文件历史

撰写