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

news2024/11/20 10:45:24

目录

  一、实验

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

修改前:

修改后:

成功:

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

String LCM

题目链接&#xff1a;Problem - 1473B - Codeforces 解题思路&#xff1a; 先算出两个字符串的最小公倍数&#xff0c;再分别除以字符串长度&#xff0c;构造出两个新的字符串&#xff0c;就是最小公倍数除以老字符串长度个老字符串相加&#xff0c;打个比方&#xff0c;a字符…

STM32驱动SHT30温湿度传感器

这次分享stm32驱动sht30温湿度传感器的方法和代码&#xff0c;这款传感器是仪器仪表行业上常用的一款型号。 目录 1.配置IO 2.写上通用的IIC协议 3.主函数获取数据 1.配置IO 我用到的IO口是 PB15---SCL PB14---SDA IIC中SDA和SCL引脚是开漏电路形式&#xff0c;所以SDA…

小程序框架(概念、工作原理、发展及应用)

引言 移动应用的普及使得用户对于轻量级、即时可用的应用程序需求越来越迫切。在这个背景下&#xff0c;小程序应运而生&#xff0c;成为一种无需下载安装、即点即用的应用形式&#xff0c;为用户提供了更便捷的体验。小程序的快速发展离不开强大的开发支持&#xff0c;而小程…

Java+SpringBoot+Vue:瑜伽馆管理的黄金组合

✍✍计算机毕业编程指导师 ⭐⭐个人介绍&#xff1a;自己非常喜欢研究技术问题&#xff01;专业做Java、Python、微信小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。 ⛽⛽实战项目&#xff1a;有源码或者技术上的问题欢迎在评论区一起讨论交流&#xff01; ⚡⚡ Java、…

中科数安 | 公司办公终端、电脑文件防泄密管理系统——自动智能透明加密保护核心文件数据\资料,防止外泄

中科数安提供的电脑文件防泄密管理系统是一种专门设计用于保护企业内部敏感文件不被非法复制、传播或泄露的安全软件。这种管理系统采用了自动智能透明加密技术&#xff0c;可以对核心文件数据和资料进行保护&#xff0c;防止外泄。 ——广东中科数安信息有限公司—— www.weae…

半导体行业案例:Jira与龙智插件助力某半导体企业实现精益项目管理

近日&#xff0c;龙智Atlassian技术团队收到了国内一家大型半导体企业的感谢信。龙智团队提供的半导体行业项目管理解决方案和服务受到了客户的好评&#xff1a; 在龙智团队的支持下&#xff0c;我们的业务取得了喜人的成果和进步。龙智公司的专业服务和产品&#xff0c;是我们…

【UE 材质】水晶材质

效果 步骤 1. 先在Quixel Bridge上下载冰纹理 2. 新建一个材质&#xff0c;这里命名为“M_Ice”并打开&#xff0c;添加如下纹理采样节点 继续添加如下节点 此时效果如下&#xff1a; 可以看到此时的材质颜色比较浅&#xff0c;如果希望颜色深一点可以继续添加如下节点 此时效…

三、西瓜书——神经网络

一、神经元模型 在M-P神经网络模型中&#xff0c;神经元接 收到来自n个其他神经元传递过来的输入信号&#xff0c;这些输入信号通过带权重的连接(connection)进行传递&#xff0c;神经元接收到的总输入值将与神经元的阈值进行比较&#xff0c;然后通过“激活函数”(activation …

大数据集群管理软件 CDH、Ambari、DataSophon 对比

文章目录 引言工具介绍CDHAmbariDataSophon 对比分析 引言 大数据集群管理方式分为手工方式和工具方式&#xff0c;手工方式一般指的是手动维护平台各个组件&#xff0c;工具方式是靠大数据集群管理软件对集群进行管理维护。本文针对于常见的方法和工具进行比较&#xff0c;帮助…

naive-ui-admin 表格去掉工具栏toolbar

使用naive-ui-admin的时候&#xff0c;有时候不需要显示工具栏&#xff0c;工具栏太占地方了。 1.在src/components/Table/src/props.ts 里面添加属性 showToolbar 默认显示&#xff0c;在不需要的地方传false。也可以默认不显示 &#xff0c;这个根据需求来。 2.在src/compo…

逆向案例二:关键字密文解密,自定义的加密解密。基于企名片科技的爬取。

import requests import execjsfor i in range(4):i i1url https://vipapi.qimingpian.cn/Activity/channelInformationByChannelNamedata {channel_name: 24新声,page: f{i},num: 20,unionid: W9wLD4rHIZrB3GLTUncmHgbZcEepR78xJa5Zit6XTMtata86DehdxDt/fDbcHeeJWqqIs6k…

Mysql8.0 安装错误:只有在任务处于完成状态(RanToCompletion、Faulted 或 Canceled)时才能释放它。

错误信息&#xff1a; Attempting to start service MySQL80... Failed to start service MySQL80. 只有在任务处于完成状态(RanToCompletion、Faulted 或 Canceled)时才能释放它。 Ended configuration step: Starting the server 刚开始以为是3306端口被占用了&#xff0c;然…

【青龙面板Ck工具】RabbitPro—快捷扫码或短信获取ck

注意&#xff1a;本教程基于Cent OS7.6系统&#xff0c;Faker一键安装版Docker 2.11.3青龙配置&#xff0c;如有不同配置自行注意&#xff0c;经测试基本可兼容。 第一步 配置Docker 由于RabbitPro打包较大&#xff0c;我们先配置一下Docker国内源&#xff0c;加速下载。 打…

C++多线程通信

多线程通信 引言区别活锁什么是活锁与死锁的区别如何避免活锁 多线程通信示例运行结果 引言 多线程同步与多线程通信实质上是两种相互关联但又不完全相同的东西。本文注重多线程同步与多线程通信的区别&#xff0c;同时重点讲述多线程通信中的消息队列。 区别 多线程通信通常…

Springboot+vue的考务报名平台(有报告)。Javaee项目,springboot vue前后端分离项目。

演示视频&#xff1a; Springbootvue的考务报名平台&#xff08;有报告&#xff09;。Javaee项目&#xff0c;springboot vue前后端分离项目。 项目介绍&#xff1a; 本文设计了一个基于Springbootvue的前后端分离的考务报名平台&#xff0c;采用M&#xff08;model&#xff0…

SpringMVC了解

1.springMVC概述 Spring MVC&#xff08;Model-View-Controller&#xff09;是基于 Java 的 Web 应用程序框架&#xff0c;用于开发 Web 应用程序。它通过将应用程序分为模型&#xff08;Model&#xff09;、视图&#xff08;View&#xff09;和控制器&#xff08;Controller&a…

Flink SQL 中的流式概念:状态算子

博主历时三年精心创作的《大数据平台架构与原型实现&#xff1a;数据中台建设实战》一书现已由知名IT图书品牌电子工业出版社博文视点出版发行&#xff0c;点击《重磅推荐&#xff1a;建大数据平台太难了&#xff01;给我发个工程原型吧&#xff01;》了解图书详情&#xff0c;…

【MySQL面试复习】了解过索引吗?(索引的底层原理)/B 树和B+树的区别是什么?

系列文章目录 在MySQL中&#xff0c;如何定位慢查询&#xff1f; 发现了某个SQL语句执行很慢&#xff0c;如何进行分析&#xff1f; 系列文章目录了解过索引吗&#xff1f;(索引的底层原理)B 树和B树的区别是什么&#xff1f; 了解过索引吗&#xff1f;(索引的底层原理) 如果没…

K8S之Deployment的介绍和使用

Deployment的理论和实操 Deployment控制器&#xff1a;概念、原理解读概述工作原理 编写Deployment资源清单文件使用案例&#xff1a;创建一个web站点Deployment管理pod&#xff1a;扩容、缩容通过deployment管理应用&#xff0c;实现扩容&#xff0c;把副本数变成3通过deploym…

面试必问但日常不愿意看的题

1&#xff0c;做道 this 相关的题&#xff0c;看你对 js 的 this 掌握的如何2&#xff0c;BFC 这样答才完美 1&#xff0c;什么是 BFC&#xff1f;其规则是什么&#xff1f;2&#xff0c;如何触发 BFC3&#xff0c;BFC 到底可以解决什么问题呢3&#xff0c;作用域4&#xff0c;…