Web服务器群集:OpenEuler 部署 LAMP(LNMP) 基础服务

目录

  一、实验

1.环境

2. 网络配置

3. MobaXterm远程连接

4. apache 2.4.58 源码编译安装

5. php 8.3.1源码编译安装

6.配置httpd 连接 php-fpm

6. nginx 1.24.0源码编译安装

7. mysql 8.0.36安装

二、问题

1.MobaXterm设置右键复制粘贴

2.OpenEuler如何查看CPU的核数

3. Web 浏览器不显示 htdocs 目录中的 index.html

4.设置httpd开机自启报错


  一、实验

1.环境

(1)主机

表1  主机

系统架构版本IP备注
LinuxopenEuler22.03 LTS SP2

192.168.204.131(动态)

192.168.204.141(静态)

192.168.204.142(静态)

apache2.4.58
php8.3.1
nginx1.24.0
mysql8.0.36

(2)查看系统版本

[root@localhost ~]# cat /etc/os-release

(3) 查看当前运行服务

[root@localhost ~]# systemctl list-units --type service | grep running

(4)查看服务文件

[root@localhost ~]# systemctl list-unit-files

2. 网络配置

(1)编辑

目标:配置三个ip,一个动态分配,二个是静态ip

[root@localhost network-scripts]# vim ifcfg-ens33 +$

+$ 直接移动到文件末尾编辑

(2)修改

修改前:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=bbe3cde3-938d-4fad-8ec7-fe30c5cd98de
DEVICE=ens33
ONBOOT=yes

修改后:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=bbe3cde3-938d-4fad-8ec7-fe30c5cd98de
DEVICE=ens33
ONBOOT=yes

IPADDR1=192.168.204.141
IPADDR2=192.168.204.142
NETMASK=255.255.255.0
GATEWAY=192.168.204.2
DNS1=114.114.114.114
DNS2=192.168.204.2

(3)重启服务

[root@localhost network-scripts]# systemctl restart NetworkManager
[root@localhost network-scripts]# systemctl status NetworkManager

(4)重启主机

 [root@localhost network-scripts]# sudo reboot

(5)查看

 [root@localhost ~]# ip addr

一个动态分配(192.168.204.131),二个是静态ip(192.168.204.141、192.168.204.142)

3. MobaXterm远程连接

(1)下载

MobaXterm free Xserver and tabbed SSH client for Windows (mobatek.net)

(2)设置SSH

接受(Accept)

弹出对话框(如不需要免密,可以取消关闭)

输入密码登录

(3)设置免密

输入密码(登录免密)

(4)更新

[root@localhost ~]# sudo dnf update -y

(5)再次更新

[root@localhost ~]# sudo dnf update -y

提示已更新

4. apache 2.4.58 源码编译安装

(1) 官网

Download - The Apache HTTP Server Project

(2)下载

wget https://dlcdn.apache.org/httpd/httpd-2.4.58.tar.gz

(3) 安装依赖组件

[root@localhost ~]# sudo dnf install -y apr-devel apr-util-devel pcre-devel openssl-devel bzip2 tar gcc gcc-c++ make

(4)解压

[root@localhost opt]# tar zxvf httpd-2.4.58.tar.gz

(5)切换目录

[root@localhost opt]# cd httpd-2.4.58

(6)安装前配置

[root@localhost httpd-2.4.58]# sudo ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite

完成

(7)编译

[root@localhost httpd-2.4.58]# sudo make -j 8

完成

(8)安装

默认安装位置是 /usr/local/apache

[root@localhost httpd-2.4.58]# sudo make install

完成:

(9)编写服务配置文件

sudo vim /usr/lib/systemd/system/httpd.service
 [Unit] 
 Description=The Apache HTTP Server
 After=network.target

 [Service] 
 Type=forking
 ExecStart=/usr/local/apache/bin/apachectl $OPTIONS
 ExecReload=/usr/local/apache/bin/apachectl $OPTIONS
 ExecStop=/bin/kill -HUP $MAINPID
 KillMode=process
 Restart=on-failure

 [Install] 
 WantedBy=multi-user.target

(10)服务操作


[root@localhost httpd-2.4.58]# sudo vim /etc/systemd/system/httpd.service

[root@localhost httpd-2.4.58]# sudo systemctl enable httpd

[root@localhost httpd-2.4.58]# sudo systemctl enable --now httpd

[root@localhost httpd-2.4.58]# sudo systemctl daemon-reload

[root@localhost httpd-2.4.58]#  sudo systemctl start httpd

(11)防火墙操作

[root@localhost httpd-2.4.58]# sudo firewall-cmd --zone=public --add-port=80/tcp --permanent

[root@localhost httpd-2.4.58]#  sudo firewall-cmd --reload

(12)测试

[root@localhost httpd-2.4.58]# curl localhost

(13)查看版本信息

[root@localhost httpd-2.4.58]#  /usr/local/apache/bin/httpd -v

查看服务状态

[root@localhost httpd-2.4.58]# sudo systemctl status httpd

(14)访问

http://192.168.204.141/

5. php 8.3.1源码编译安装

(1) 官网

PHP: Downloads

(2)下载

wget https://www.php.net/distributions/php-8.3.1.tar.gz

(3)安装依赖组件

[root@localhost opt]# sudo dnf install -y tar gcc gcc-c++ make

sudo dnf install -y bzip2-devel libcurl-devel libxml2-devel sqlite-devel oniguruma oniguruma-devel libxml2-devel bzip2-devel libcurl-devel libjpeg-devel zstd libzstd-devel libcurl-devel libpng-devel libffi-devel libjpeg-devel libpng-devel sqlite-devel libwebp libwebp-devel openssl-devel libzip-devel

完成

(4)解压缩并进入源码目录

[root@localhost opt]# tar zxvf php-8.3.1.tar.gz

[root@localhost opt]# cd php-8.3.1

(5)配置

sudo ./configure --prefix=/usr/local/php --enable-gd --with-webp --with-jpeg --with-mhash --enable-mbstring --with-imap-ssl --with-mysqli --with-pdo-mysql --enable-exif --with-ffi --with-zip --enable-sockets --with-openssl --with-pcre-jit --enable-fpm --enable-pcntl

完成

(6)编译

[root@localhost php-8.3.1]# sudo make -j 8

完成

(7)安装

[root@localhost php-8.3.1]# sudo make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20230831/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM defconfig:     /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/

(8)查看

[root@localhost php-8.3.1]# whereis php
php: /usr/local/php

[root@localhost php-8.3.1]# cd /usr/local/php/bin/

[root@localhost bin]# ./php -v
PHP 8.3.1 (cli) (built: Feb 27 2024 01:28:10) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies

[root@localhost bin]# ./php --ini
Configuration File (php.ini) Path: /usr/local/php/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

查看组件

[root@localhost bin]# ./php --ri gd

gd

GD Support => enabled
GD Version => bundled (2.1.0 compatible)
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.6.38
WBMP Support => enabled
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
TGA Read Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => On => On
[root@localhost bin]# ./php --ri pdo

PDO

PDO support => enabled
PDO drivers => mysql, sqlite
[root@localhost bin]#

(9)修改配置文件

[root@localhost bin]# cd /usr/local/php/etc/

[root@localhost etc]# ls
php-fpm.conf.default  php-fpm.d

[root@localhost etc]#  mv php-fpm.conf.default php-fpm.conf

[root@localhost etc]# ls
php-fpm.conf  php-fpm.d

[root@localhost etc]# cd php-fpm.d/

[root@localhost php-fpm.d]# ls
www.conf.default

[root@localhost php-fpm.d]#  mv www.conf.default www.conf

[root@localhost php-fpm.d]# ls
www.conf

(10)复制服务配置文件

[root@localhost fpm]# cp /opt/php-8.3.1/sapi/fpm/php-fpm.service /usr/lib/systemd/system/

(11)查看配置文件

[root@localhost fpm]# sudo vim  /usr/lib/systemd/system/php-fpm.service

# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades.  If you want to customize,
# the best way is to use the "systemctl edit" command.

[Unit]
Description=The PHP FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

# Set up a new file system namespace and mounts private /tmp and /var/tmp directories
# so this service cannot access the global directories and other processes cannot
# access this service's directories.
PrivateTmp=true

# Mounts the /usr, /boot, and /etc directories read-only for processes invoked by this unit.
ProtectSystem=full

# Sets up a new /dev namespace for the executed processes and only adds API pseudo devices
# such as /dev/null, /dev/zero or /dev/random (as well as the pseudo TTY subsystem) to it,
# but no physical devices such as /dev/sda.
PrivateDevices=true

# Explicit module loading will be denied. This allows to turn off module load and unload
# operations on modular kernels. It is recommended to turn this on for most services that
# do not need special file systems or extra kernel modules to work.
ProtectKernelModules=true

# Kernel variables accessible through /proc/sys, /sys, /proc/sysrq-trigger, /proc/latency_stats,
# /proc/acpi, /proc/timer_stats, /proc/fs and /proc/irq will be made read-only to all processes
# of the unit. Usually, tunable kernel variables should only be written at boot-time, with the
# sysctl.d(5) mechanism. Almost no services need to write to these at runtime; it is hence
# recommended to turn this on for most services.
ProtectKernelTunables=true

# The Linux Control Groups (cgroups(7)) hierarchies accessible through /sys/fs/cgroup will be
# made read-only to all processes of the unit. Except for container managers no services should
# require write access to the control groups hierarchies; it is hence recommended to turn this on
# for most services
ProtectControlGroups=true

# Any attempts to enable realtime scheduling in a process of the unit are refused.
RestrictRealtime=true

# Restricts the set of socket address families accessible to the processes of this unit.
# Protects against vulnerabilities such as CVE-2016-8655
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX

# Takes away the ability to create or manage any kind of namespace
RestrictNamespaces=true

[Install]
WantedBy=multi-user.target

修改后:

# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades.  If you want to customize,
# the best way is to use the "systemctl edit" command.

[Unit]
Description=The PHP FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

# Set up a new file system namespace and mounts private /tmp and /var/tmp directories
# so this service cannot access the global directories and other processes cannot
# access this service's directories.
PrivateTmp=true

# Takes away the ability to create or manage any kind of namespace
RestrictNamespaces=true

[Install]
WantedBy=multi-user.target

(12)启动

[root@localhost fpm]# sudo systemctl enable --now php-fpm

[root@localhost fpm]# sudo systemctl status php-fpm

(13) 申明变量

[root@localhost fpm]# sudo vim /etc/profile +$

export PATH=.:$PATH:/usr/local/php/bin

更新

[root@localhost fpm]# source /etc/profile

(14)查看版本

[root@localhost fpm]# php -v

(15)查看模块

[root@localhost fpm]# php -m
[PHP Modules]
Core
ctype
date
dom
exif
FFI
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
random
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip

[Zend Modules]

6.配置httpd 连接 php-fpm

(1)创建目录

[root@localhost ~]# mkdir -p /var/www

(2)创建网页文件

[root@localhost ~]# sudo vim /var/www/index.php

<?php
phpinfo();

(3)修改配置文件

[root@localhost ~]#  vim /usr/local/apache/conf/httpd.conf

开启序号

set nu

启用119行

启用123行

修改189行

修改198行

修改257行

大G 切换最后一行

(4) 重启主机

[root@localhost ~]# sudo reboot

(5)重启服务

[root@localhost ~]# sudo systemctl daemon-reload
[root@localhost ~]# sudo systemctl start httpd
[root@localhost ~]# sudo systemctl status httpd

(6)访问

http://192.168.204.141/index.php

gd组件

pdo组件

版本

(7)修改时区

复制配置文件

[root@localhost ~]# ls /usr/local/php/lib
php

[root@localhost ~]# cd /opt/php-8.3.1/

[root@localhost php-8.3.1]# ls
appveyor             configure.ac     Makefile.fragments   scripts
benchmark            CONTRIBUTING.md  Makefile.objects     SECURITY.md
build                docs             modules              tests
buildconf            ext              NEWS                 travis
buildconf.bat        EXTENSIONS       pear                 TSRM
CODEOWNERS           include          php.ini-development  UPGRADING
CODING_STANDARDS.md  libs             php.ini-production   UPGRADING.INTERNALS
config.log           libtool          README.md            win32
config.nice          LICENSE          README.REDIST.BINS   Zend
config.status        main             run-tests.php
configure            Makefile         sapi

[root@localhost php-8.3.1]# sudo cp php.ini-production  /usr/local/php/lib/php.ini

[root@localhost php-8.3.1]#  sudo vim /usr/local/php/lib/php.ini

搜索timezone

修改前:

修改后:

date.timezone = PRC

重启服务

[root@localhost php-8.3.1]# sudo systemctl restart php-fpm

测试

sudo vim /var/www/d.php
 <?php
 echo date('Y-m-d H:i:s')

6. nginx 1.24.0源码编译安装

(1) 官网

Index of /download/ (nginx.org)

(2)下载

 wget http://nginx.org/download/nginx-1.24.0.tar.gz

(3)解压

[root@localhost opt]#  tar zxvf nginx-1.24.0.tar.gz

(4)安装依赖组件

[root@localhost opt]# sudo dnf install -y pcre-devel openssl openssl-devel gcc gcc-c++ make

(5)切换目录

[root@localhost opt]# cd nginx-1.24.0

(6)配置

自动配置 默认安装在/usr/local/nginx 目录下

[root@localhost nginx-1.24.0]# sudo ./configure

完成

(7)编译

[root@localhost nginx-1.24.0]# sudo make -j 8

完成

(8)安装

[root@localhost nginx-1.24.0]# sudo make install

(9)查看

[root@localhost nginx-1.24.0]# whereis nginx

(10)配置服务文件

[root@localhost nginx-1.24.0]#  sudo vim /usr/lib/systemd/system/nginx.service

 [Unit]
 Description=nginx
 After=network.target remote-fs.target nss-lookup.target
 
 [Service]
 Type=forking
 ExecStart=/usr/local/nginx/sbin/nginx
 ExecReload=/usr/local/nginx/sbin/nginx -s reload
 ExecStop=/usr/local/nginx/sbin/nginx -s stop
 PrivateTmp=true

 [Install]
 WantedBy=multi-user.target

(11)配置nginx

[root@localhost nginx-1.24.0]# sudo vim /usr/local/nginx/conf/nginx.conf

修改前:

修改后:添加index.php

取消注释

修改前:

修改后:添加 $document_root

(12)启动

如httpd占用80端口,需要将其关闭

[root@localhost nginx-1.24.0]# ps -ef |grep httpd

[root@localhost nginx-1.24.0]# sudo systemctl stop httpd

[root@localhost nginx-1.24.0]# sudo reboot

启动nginx服务


[root@localhost ~]#  sudo systemctl enable --now nginx

[root@localhost ~]# sudo systemctl status nginx

查看进程

[root@localhost ~]# ps -ef |grep nginx

查看端口占用

[root@localhost ~]# netstat -antpl

(13)配置环境变量

[root@localhost sbin]# vim /etc/profile
[root@localhost sbin]# source /etc/profile

export PATH=.:$PATH:/usr/local/php/bin:/usr/local/nginx/sbin

查看版本

[root@localhost sbin]# nginx -v

(14)新建文件

[root@localhost ~]# sudo vim /usr/local/nginx/html/index.php

<?php
    phpinfo();

(15)访问

http://192.168.204.141/

查看nginx版本

7. mysql 8.0.36安装

(1) 官网

MySQL :: Download MySQL Community Server

(2)下载

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.36-linux-glibc2.28-x86_64.tar.xz

(3) 新建用户

[root@localhost opt]# groupadd -r -g 306 mysql
[root@localhost opt]# useradd -r -u 306 -g 306 -s /bin/false mysql

(4)解压

[root@localhost opt]# tar xf mysql-8.0.36-linux-glibc2.28-x86_64.tar.xz -C /usr/local/

(5)软链接

[root@localhost opt]# ln -s /usr/local/mysql-8.0.36-linux-glibc2.28-x86_64/ /usr/local/mysql

(6)初始化

需要记住最后生成的密码

[root@localhost opt]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2024-02-27T13:11:56.263920Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.36) initializing of server in progress as process 2504
2024-02-27T13:11:56.298069Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-02-27T13:11:57.751470Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-02-27T13:12:04.149485Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >.BjWK3q(qAp

(7)提供配置文件和服务脚本

[root@localhost opt]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost opt]# chkconfig --add mysqld
[root@localhost opt]# chkconfig mysqld on


[root@localhost opt]# vim /etc/my.cnf.d/mysql-server.cnf

[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql/
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/mysqld.pid

(8)配置环境变量

[root@localhost opt]# echo 'export PATH=$PATH:/usr/local/mysql/bin/' > /etc/profile.d/mysql.sh
[root@localhost opt]#  source /etc/profile.d/mysql.sh

(9)重启服务

[root@localhost opt]# systemctl restart mysqld

(10)查看版本

[root@localhost opt]# mysql -V

(11)修改密码


[root@localhost opt]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36

Copyright (c) 2000, 2024, 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> alter user root@localhost identified by 'Admin@123';
Query OK, 0 rows affected (0.07 sec)

mysql-> \q
Bye

二、问题

1.MobaXterm设置右键复制粘贴

(1)点击设置

(2)终端

取消右键粘贴

2.OpenEuler如何查看CPU的核数

(1)查看CPU的核数

1)CPU总核数 	= 物理CPU个数 * 每颗物理CPU的核数 

2)逻辑CPU总数 = 物理CPU个数 * 每颗物理CPU的核数 * 超线程数

3)多核超线程:
			1>多个物理CPU:	物理CPU间通过总线进行通信,效率比较低。
			1>多核CPU:		不同的核通过L2 cache进行通信,存储和外设通过总线与CPU通信。
			2>超线程:		每个核有两个逻辑的处理单元,两个处理单元共享一个核的资源。

	

(2)查看

#查看CPU的型号
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
		
#查看物理CPU的个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

#查看每颗物理CPU的核数
cat /proc/cpuinfo| grep "cpu cores"| uniq

#查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"| wc -l

#计算超线程数:
逻辑CPU/CPU总核数 
# 8/(2*4)=1

3. Web 浏览器不显示 htdocs 目录中的 index.html

(1)报错

(2)原因分析

查看版本,系统更新默认dnf 安装了 httpd ,所以默认配置文件在 /etc/httpd/conf/httpd.conf

[root@localhost httpd-2.4.58]# httpd -v

查看配置文件,此为dnf安装的配置文件

[root@localhost httpd-2.4.58]# sudo vim /usr/lib/systemd/system/httpd.service

# See httpd.service(8) for more information on using the httpd service.

# Modifying this file in-place is not recommended, because changes
# will be overwritten during package upgrades.  To customize the
# behaviour, run "systemctl edit httpd" to create an override unit.

# For example, to pass additional options (such as -D definitions) to
# the httpd binary at startup, create an override unit (as is done by
# systemctl edit) and enter the following:

#       [Service]
#       Environment=OPTIONS=-DMY_DEFINE

[Unit]
Description=The Apache HTTP Server
Wants=httpd-init.service
After=network.target remote-fs.target nss-lookup.target httpd-init.service
Documentation=man:httpd.service(8)

[Service]
Type=notify
Environment=LANG=C

ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecStartPost=/usr/bin/sleep 0.1
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
# Send SIGWINCH for graceful stop
KillSignal=SIGWINCH
KillMode=mixed
PrivateTmp=true

[Install]
WantedBy=multi-user.target

(3)解决方法

卸载 dnf安装的httpd

[root@localhost httpd-2.4.58]# dnf remove httpd

 编写编译安装服务配置文件

sudo vim /usr/lib/systemd/system/httpd.service
 [Unit] 
 Description=The Apache HTTP Server
 After=network.target

 [Service] 
 Type=forking
 ExecStart=/usr/local/apache/bin/apachectl $OPTIONS
 ExecReload=/usr/local/apache/bin/apachectl $OPTIONS
 ExecStop=/bin/kill -HUP $MAINPID
 KillMode=process
 Restart=on-failure

 [Install] 
 WantedBy=multi-user.target

服务操作

[root@localhost httpd-2.4.58]# sudo vim /etc/systemd/system/httpd.service

[root@localhost httpd-2.4.58]# sudo systemctl enable httpd

[root@localhost httpd-2.4.58]# sudo systemctl enable --now httpd

[root@localhost httpd-2.4.58]# sudo systemctl daemon-reload

[root@localhost httpd-2.4.58]#  sudo systemctl start httpd

成功:

http://192.168.204.141/

4.设置httpd开机自启报错

(1)报错

[root@localhost httpd-2.4.58]# sudo systemctl enable httpd
Failed to enable unit: File httpd.service: Bad message

(2)原因分析

配置文件格式错误

(3)解决方法

修改配置文件

[root@localhost httpd-2.4.58]#  sudo vim /etc/systemd/system/httpd.service

修改前:

修改后:

成功:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/415058.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

网络防御保护3

一、双击热备 1&#xff0c;根据网段划分配置IP地址和安全区域 2&#xff0c;配置双机热备场景 主备场景配置 抢占延时仅对主设备生效。 hello报文周期时间--- 默认为1S&#xff0c;可以修改&#xff0c;但是&#xff0c;主备设备需要同时修改为相同值。 同步配置 双机热备的…

【网站项目】424学报稿件管理系统

&#x1f64a;作者简介&#xff1a;拥有多年开发工作经验&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的项目或者毕业设计。 代码可以私聊博主获取。&#x1f339;赠送计算机毕业设计600个选题excel文件&#xff0c;帮助大学选题。赠送开题报告模板&#xff…

一个注解实现频率控制

1.概述 抹茶项目是一个即时的IM通信项目&#xff0c;并且有着万人大群。但凡有几个人刷屏&#xff0c;那消息爆炸的场景&#xff0c;都不敢想象。如果我们需要对项目特定的接口进行频率控制&#xff0c;不仅是业务上的功能&#xff0c;同样也保护了项目的监控运行。而频控又是…

幻兽帕鲁(1.5.0)可视化管理工具(0.5.7 docker版)安装教程

文章目录 局域网帕鲁服务器部署教程帕鲁服务可视化工具安装配置服务器地址&#xff08;可跳过&#xff09;使用工具管理面板 1.5.0服务端RCON错误1.5.0服务端无法启动RCON端口 解决方法第一步&#xff1a;PalWorldSettings.ini配置第二步&#xff1a;修改PalServer.sh配置 局域…

数据结构--二叉排序树(Binary Search Tree,简称BST)

这里写自定义目录标题 二叉排序树二叉排序树与排序数组没有排序数组&#xff0c;链式存储链表的对比二叉排序树概念对于搜索操作&#xff0c;对于插入操作&#xff0c;对于删除操作&#xff0c; 分析删除节点代码运行结果 二叉排序树 二叉排序树与排序数组没有排序数组&#x…

python自动化管理和zabbix监控网络设备(防火墙和python自动化配置部分)

目录 前言 一、ssh配置 1.FW1 2.core-sw1 3.core-sw2 二、python自动化配置防火墙 三、验证DNAT 四、验证DNAT 前言 视频演示请访问b站主页 白帽小丑的个人空间-白帽小丑个人主页-哔哩哔哩视频 一、ssh配置 给需要自动化管理的设备配置ssh服务端用户名和密码 1.FW1 …

Linux NFC 子系统剖析

1.总览 linux源码中NFC在net/nfc下&#xff0c;文件结构如下图&#xff1a; hci&#xff1a;Host Controller Interface 主要是针对NFC的主机-控制器接口协议 nci&#xff1a;NFC Controller Interface 主要是NFC的控制器接口协议&#xff0c;用于NFCC(NFC Controller)和DH(…

进程的控制

文章目录 进程退出进程等待进程程序替换 正文开始前给大家推荐个网站&#xff0c;前些天发现了一个巨牛的 人工智能学习网站&#xff0c; 通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。 点击跳转到网站。 进程退出 进程的退出一共有三种场景。 程序跑完…

nacos开启鉴权+springboot配置用户名密码

nacos默认没有开启鉴权&#xff0c;springboot无需用户名密码即可连接nacos。从2.2.2版本开始&#xff0c;默认控制台也无需登录直接可进行操作。 因此本文记录一下如何开启鉴权&#xff0c;基于nacos2.3.0版本。 编辑nacos服务端的application.properties&#xff1a; # 开…

硬件工程师入门基础知识(二)片式电阻、片式网络电阻标识和焊接使用注意事项

片式电阻、片式网络电阻标识和使用注意事项 1.概述2.阻值标识2.1 标识原则2.2片式类电阻、片式电阻网络标识方法2.3电阻网络标识方法 3.电阻产品包装3.1片式电阻、片式电阻网络的包装3.2电阻网络的包装 4.使用注意事项4.1 片式电阻推荐焊盘尺寸4.2片式电阻网络推荐焊盘尺寸 5.焊…

STM32 +合宙1.54“ 电子墨水屏(e-paper)驱动显示示例

STM32 合宙1.54“ 电子墨水屏&#xff08;e-paper&#xff09;驱动显示示例 &#x1f4cd;相关篇《Arduino框架下ESP32/ESP8266合宙1.54“ 电子墨水屏&#xff08;e-paper&#xff09;驱动显示示例》&#x1f516;程序是从GooDisplay品牌和微雪电子下同型号规格墨水屏的示例程序…

Vue项目 快速上手(如何新建Vue项目,启动Vue项目,Vue的生命周期,Vue的常用指令)

目录 一.什么Vue框架 二.如何新建一个Vue项目 1.使用命令行新建Vue项目 2.使用图形化界面新建Vue项目 三.Vue项目的启动 启动Vue项目 1.通过VScode提供的图形化界面启动Vue项目 2.通过命令行的方式启动Vue项目 四.Vue项目的基础使用 常用指令 v-bind 和 v-model v…

【Unity每日一记】角色控制器Character Contorller

&#x1f468;‍&#x1f4bb;个人主页&#xff1a;元宇宙-秩沅 &#x1f468;‍&#x1f4bb; hallo 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! &#x1f468;‍&#x1f4bb; 本文由 秩沅 原创 &#x1f468;‍&#x1f4bb; 收录于专栏&#xff1a;Uni…

c# .net8 香橙派orangepi + hc-04蓝牙 实例

这些使用c# .net8开发,硬件 香橙派 orangepi 3lts和 hc-04蓝牙 使用场景:可以通过这个功能,手机连接orangepi进行wifi等参数配置 硬件: 1、带USB口的linux开发板orangepi 2、USB 转TTL 中转接蓝牙(HC-04) 某宝上买的蓝牙官方网有调试工具:HC-T串口助手 https://www…

leetcode 3.反转链表;

1.题目&#xff1a; 给你单链表的头节点 head &#xff0c;请你反转链表&#xff0c;并返回反转后的链表。 2.用例&#xff1a; 3.题目解析&#xff1a; &#xff08;1&#xff09;函数头&#xff1a; 要求返回结点&#xff0c;就 ListNode* reverseList(ListNode* head)&…

【数据开发】大数据岗位,通用必备技术栈(数据分析、数据工程、数据科学)

【数据开发】大数据岗位&#xff0c;通用必备技术栈&#xff08;数据分析、数据工程、数据科学&#xff09; 文章目录 1、岗位与技术要求1.1 常见岗位介绍1.2 行业发展方向1.3 附部分JD 2、数据开发技术栈2.1 数据处理流程2.2 学习路线与框架 3、数据分析技术栈3.1 基础知识3.2…

如何一步一步地优化LVGL的丝滑度

经过一番周折将LVGL移植到了STM32F407单片机上&#xff0c;底层驱动的LCD是st7789&#xff0c;移植时的条件和环境如下&#xff1a; ●LVGL用的是单缓冲&#xff0c;一次刷新10行&#xff1b; ●刷新函数用的是最原始的一个一个打点的方式&#xff1b; ●ST7789底层发送数据用的…

【MySQL】学习和总结标量子查询

&#x1f308;个人主页: Aileen_0v0 &#x1f525;热门专栏: 华为鸿蒙系统学习|计算机网络|数据结构与算法 ​&#x1f4ab;个人格言:“没有罗马,那就自己创造罗马~” #mermaid-svg-kLo6jykc7AcEVEQk {font-family:"trebuchet ms",verdana,arial,sans-serif;font-siz…

JMeter--9.录制脚本

录制步骤 1.新建线程组&#xff1a;测试计划->线程->线程组 测试计划下&#xff0c;至少要有1个线程组&#xff0c;因为在录制器中需要选择【目标控制器】 2. 新建录制器&#xff1a;测试计划->非测试原件->HTTP(S)测试脚本记录器&#xff08;HTTP代理服务器&…

Linux磁盘如何分区?

首先需要先给虚拟机添加磁盘 sblk #查看磁盘设备 得到以下内容&#xff1a; NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 pa…