LAMP部署(二进制安装mysql)
lamp平台构建
环境说明:
系统平台 | IP | 需要安装的服务 |
---|---|---|
redhat8 | 192.168.201.138 | httpd-2.4 mysql-5.7 php php-mysql |
lamp平台软件安装次序:
https --> mysql --> php
配置yum源
//配置centos源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# ls
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//配置epel源
[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*
安装httpd
//配置环境
[root@localhost ~]# yum groups mark install "Development Tools"
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]# grep apache /etc/group
apache:x:973:
//安装依赖包
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
//安装源码包
[root@localhost ~]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
[root@localhost ~]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
[root@localhost ~]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
[root@localhost ~]# ls
公共 视频 文档 音乐 anaconda-ks.cfg apr-util-1.6.1.tar.gz initial-setup-ks.cfg
模板 图片 下载 桌面 apr-1.7.0.tar.gz httpd-2.4.54.tar.gz
//安装apr
[root@localhost ~]# tar xf apr-1.7.0.tar.gz
[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]# dnf -y install make
[root@localhost apr-1.7.0]# make
[root@localhost apr-1.7.0]# make install
//安装apr-util
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz
[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
//安装http
[root@localhost ~]# tar xf httpd-2.4.54.tar.gz
[root@localhost ~]# cd httpd-2.4.54/
[root@localhost httpd-2.4.54]# ./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 httpd-2.4.54]# make
[root@localhost httpd-2.4.54]# make install
//配置httpd
[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 ~]# which apachectl
/usr/local/apache/bin/apachectl
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/apache
[root@localhost ~]# vim /etc/man_db.conf
添加“MANDATORY_MANPATH /usr/local/share/apache”
//启动apache
[root@localhost ~]# systemctl disable --now firewalld.service
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 ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
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 *:80 *:*
//使用systemctl命令设置httpd
[root@localhost ~]# apachectl status
/usr/local/apache/bin/apachectl:行95: lynx: 未找到命令
[root@localhost ~]# systemctl status httpd
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# ls sshd.service
sshd.service
[root@localhost system]# cp sshd.service httpd.service
[root@localhost system]# vi httpd.service
[root@localhost system]# cat 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]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset:>
Active: inactive (dead)
[root@localhost system]# systemctl start httpd
[root@localhost system]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost system]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: >
Active: active (running) since Sun 2022-04-17 22:56:53 CST; 6s ago
Process: 425418 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, st>
Main PID: 425426 (httpd)
Tasks: 6 (limit: 11159)
Memory: 4.8M
CGroup: /system.slice/httpd.service
├─425426 /usr/local/apache/bin/httpd -k start
├─425428 /usr/local/apache/bin/httpd -k start
├─425429 /usr/local/apache/bin/httpd -k start
├─425430 /usr/local/apache/bin/httpd -k start
├─425431 /usr/local/apache/bin/httpd -k start
└─425432 /usr/local/apache/bin/httpd -k start
4月 17 22:56:53 localhost.localdomain systemd[1]: Starting httpd server daemon...
4月 17 22:56:53 localhost.localdomain apachectl[425418]: AH00558: httpd: Could not>
4月 17 22:56:53 localhost.localdomain systemd[1]: Started httpd server daemon.
[root@localhost system]# 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 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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
二进制安装mysql
//安装依赖包
[root@localhost ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
//下载二进制格式的mysql软件包
[root@localhost ~]# ls
公共 文档 anaconda-ks.cfg apr-util-1.6.1.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
模板 下载 apr-1.7.0 httpd-2.4.54
视频 音乐 apr-1.7.0.tar.gz httpd-2.4.54.tar.gz
图片 桌面 apr-util-1.6.1 initial-setup-ks.cfg
//创建用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql
[root@localhost ~]# id mysql
uid=974(mysql) gid=972(mysql) 组=972(mysql)
//解压软件至/usr/local/
[root@localhost ~]# tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
apache apr-util etc include lib64 mysql-5.7.37-linux-glibc2.12-x86_64 share
apr bin games lib libexec sbin src
[root@localhost local]# mv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ls
apache apr apr-util bin etc games include lib lib64 libexec mysql sbin share src
//修改目录/usr/local/mysql的属主属组
[root@localhost local]# chown -R mysql.mysql mysql/
//添加环境变量
[root@localhost local]# ls mysql/
bin docs include lib LICENSE man README share support-files
[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]# ln -s /usr/local/mysql/include/ /usr/include/mysql/
[root@localhost local]# echo '/usr/local/mysql/lib/' > /etc/ld.so.conf.d/mysql.conf
[root@localhost local]# ldconfig
[root@localhost local]# cd mysql/
[root@localhost mysql]# vim /etc/man_db.conf
添加“MANDATORY_MANPATH /usr/local/mysql/man”
//配置服务启动脚本
[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 /etc/init.d/mysqld
[root@localhost support-files]# vim mysqld
[root@localhost support-files]# ls
magic mysqld_multi.server mysql-log-rotate mysql.server
[root@localhost support-files]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/opt/data
//建立数据存放目录
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll /opt/
总用量 0
drwxr-xr-x. 2 mysql mysql 6 7月 5 16:33 data
//初始化数据库
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data
2022-07-05T08:35:58.509890Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-05T08:35:58.998389Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-05T08:35:59.059627Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-05T08:35:59.141869Z 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: 7ec0e62d-fc3d-11ec-b706-000c29246a24.
2022-07-05T08:35:59.143438Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-05T08:36:00.466726Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-05T08:36:00.466769Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-05T08:36:00.467577Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-05T08:36:00.717260Z 1 [Note] A temporary password is generated for root@localhost: ?l?!oS3twQ-R
[root@localhost ~]# echo '?l?!oS3twQ-R' > pass
//生成配置文件
[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# > /etc/my.cnf
[root@localhost ~]# vim /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
//启动mysql
[root@localhost ~]# service 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
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 0.0.0.0:111 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
//修改密码
[root@localhost ~]# cat pass
?l?!oS3twQ-R
[root@localhost ~]# mysql -uroot -p'?l?!oS3twQ-R'
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
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('123.com!');
Query OK, 0 rows affected, 1 warning (0.00 sec)
安装php
//安装依赖包
[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 php-mysqlnd
[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 -y install sqlite-devel
//下载php
root@localhost ~]# ls
公共 文档 anaconda-ks.cfg apr-util-1.6.1.tar.gz mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
模板 下载 apr-1.7.0 httpd-2.4.54 pass
视频 音乐 apr-1.7.0.tar.gz httpd-2.4.54.tar.gz php-7.4.29.tar.xz
图片 桌面 apr-util-1.6.1 initial-setup-ks.cfg
[root@localhost ~]# tar xf php-7.4.29.tar.xz
//编译安装php
[root@localhost ~]# cd php-7.4.29/
[root@localhost php-7.4.29]# ls
appveyor configure main run-tests.php UPGRADING.INTERNALS
azure configure.ac NEWS sapi win32
azure-pipelines.yml CONTRIBUTING.md pear scripts Zend
build docs php.ini-development tests
buildconf ext php.ini-production travis
buildconf.bat EXTENSIONS README.md TSRM
CODING_STANDARDS.md LICENSE README.REDIST.BINS UPGRADING
[root@localhost 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 php-7.4.29]# make
[root@localhost php-7.4.29]# make install
php配置
//创建环境变量
[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 ~]# ln -s /usr/local/php7/include/ /usr/include/php
[root@localhost ~]# echo '/usr/local/php7/lib/' > /etc/ld.so.conf.d/php.conf
[root@localhost ~]# ldconfig
[root@localhost ~]# php -v
PHP 7.4.29 (cli) (built: Jul 5 2022 18:13:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
//配置php-fpm
[root@localhost ~]# cd php-7.4.29/
[root@localhost php-7.4.29]# cp php.ini-production /etc/php.ini
cp:是否覆盖'/etc/php.ini'? yes
[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 ~]# service php-fpm start
Starting php-fpm done
[root@localhost ~]# 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 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 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
[root@localhost ~]# ps -ef |grep php
root 622547 1 0 23:01 ? 00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody 622548 622547 0 23:01 ? 00:00:00 php-fpm: pool www
nobody 622549 622547 0 23:01 ? 00:00:00 php-fpm: pool www
root 623150 336616 0 23:01 pts/0 00:00:00 grep --color=auto php
配置apache
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf
//将这两行注释取消 启动这两个模块
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
//创建虚拟主机目录并生成php测试页面
[root@localhost ~]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# vim index.php
[root@localhost htdocs]# cat index.php
<?php
phpinfo();
?>
[root@localhost htdocs]# ls
index.html index.php
[root@localhost htdocs]# chown -R apache.apache /usr/local/apache/
//配置虚拟主机
[root@localhost htdocs]# cd ..
[root@localhost apache]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@localhost apache]# cd conf/
[root@localhost conf]# ls
extra httpd.conf magic mime.types original
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
httpd-autoindex.conf httpd-info.conf httpd-mpm.conf httpd-userdir.conf
httpd-dav.conf httpd-languages.conf httpd-multilang-errordoc.conf httpd-vhosts.conf
httpd-default.conf httpd-manual.conf httpd-ssl.conf proxy-html.conf
[root@localhost extra]# vim httpd-vhosts.conf
[root@localhost extra]# cat httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs"
ServerName www.example.com
ErrorLog "logs/www.example.com-error_log"
CustomLog "logs/www.example.com-access_log" common
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1
<Directory "/usr/local/apache/htdocs">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@localhost conf]# vim httpd.conf
Include conf/extra/httpd-vhosts.conf #此行取消注释
//搜索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 #添加此行
<IfModule dir_module>
DirectoryIndex index.php index.html #此处添加index.html
</IfModule>
ServerName www.example.com:80 #将这行注释取消
[root@localhost conf]# apachectl stop
[root@localhost conf]# apachectl start
报错
[root@localhost ~]# systemctl status httpd
Unit httpd.service could not be found.
报错原因,Apache安装是编译安装,安装路径不是默认路径,Apache服务没有添加到Linux服务中
解决办法,将Apache服务添加到Linux系统服务中
//解决方案
[root@localhost ~]# find / -name httpd //找到Apache安装路径
find: ‘/proc/346042’: 没有那个文件或目录
/etc/httpd
/root/httpd-2.4.54/httpd
/usr/lib64/httpd
/usr/local/apache/bin/httpd
[root@localhost ~]# cd /usr/local/apache/bin
[root@localhost bin]# pwd
/usr/local/apache/bin
[root@localhost ~]# cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
[root@localhost ~]# ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S61httpd
[root@localhost ~]# cd /etc/rc.d/init.d/
[root@localhost init.d]# vim httpd
//在#!/bin/sh下面添加这两行
#chkconfig:35 61 61
#description:Apache
[root@localhost init.d]# chkconfig --add httpd
[root@localhost init.d]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
httpd 0:关 1:关 2:关 3:开 4:关 5:开 6:关
[root@localhost init.d]# cd
[root@localhost ~]# systemctl status httpd.service
● httpd.service - SYSV: Apache
Loaded: loaded (/etc/rc.d/init.d/httpd; generated)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
Package 'sqlite3', required by 'virtual:world', not found
//解决方案
[root@localhost php-7.4.29]# dnf list all|grep sqlite
[root@localhost ~]# yum -y install sqlite-devel
configure: error: Package requirements (oniguruma) were not met:
Package 'oniguruma', required by 'virtual:world', not found
//解决方案
[root@localhost ~]#yum -y install https://repo.almalinux.org/almalinux/8/PowerTools/x86_64/os/Packages/on
[root@localhost ~]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
//解决方案
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf
ServerName www.example.com:80 #将这行注释取消