$ make
$ makeinstall# 查看结果
ll /usr/local/httpd/
total 36K
drwxr-xr-x. 2 root root 262 Mar 5 06:43 bin/
drwxr-xr-x. 2 root root 167 Mar 5 06:43 build/
drwxr-xr-x. 2 root root 78 Mar 5 06:43 cgi-bin/
drwxr-xr-x. 4 root root 84 Mar 5 06:43 conf/
drwxr-xr-x. 3 root root 4.0K Mar 5 06:43 error/
drwxr-sr-x. 2 root root 24 Aug 1 2020 htdocs/
drwxr-xr-x. 3 root root 8.0K Mar 5 06:43 icons/
drwxr-xr-x. 2 root root 4.0K Mar 5 06:43 include/
drwxr-xr-x. 2 root root 6 Mar 5 06:43 logs/
drwxr-xr-x. 4 root root 30 Mar 5 06:43 man/
drwxr-sr-x. 14 root root 8.0K Aug 1 2020 manual/
drwxr-xr-x. 2 root root 4.0K Mar 5 06:43 modules/
6. 优化执行路径
$ ln -s /usr/local/httpd/bin/* /usr/local/bin/
$ httpd -v
Server version: Apache/2.4.46 (Unix)
Server built: Mar 5 2021 06:42:06
7. 添加httpd服务启动脚本
$ vim /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart= /usr/local/bin/apachectl $OPTIONS
ExecReload= /bin/kill -HUP $MAINPID[Install]
WantedBy=multi-user.target
# 启动
$ systemctl daemon-reload
$ systemctl start httpd
$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2021-03-05 06:49:40 EST; 7s ago
Process: 20356 ExecStart=/usr/local/bin/apachectl $OPTIONS(code=exited, status=0/SUCCESS)
Main PID: 20359 (httpd)
CGroup: /system.slice/httpd.service
├─20359 /usr/local/httpd/bin/httpd
├─20360 /usr/local/httpd/bin/httpd
├─20361 /usr/local/httpd/bin/httpd
└─20362 /usr/local/httpd/bin/httpd
Mar 05 06:49:40 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Mar 05 06:49:40 localhost.localdomain apachectl[20356]: AH00558: httpd: Could not reliably determine the server's ...sage
Mar 05 06:49:40 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
$ systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
二、Apache服务器配置
1. 添加hosts文件解析
$ vim /etc/hosts
192.168.119.136 www.cisco.com
192.168.119.136 www.huawei.com
2. 构建虚拟主机
# 创建网站默认文件
$ cd /usr/local/httpd/htdocs/
$ mkdir cisco
$ mkdir huawei
$ vim ./cisco/index.html
<html><body><h1>www.cisco.com</h1></body></html>
$ vim ./huawei/index.html
<html><body><h1>www.huawei.com</h1></body></html># 修改主配置文件
$ vim /usr/local/httpd/conf/httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
$ vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/usr/local/httpd/htdocs/cisco"
ServerName www.cisco.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory '/usr/local/httpd/htdocs/cisco'>
Require all granted
</Directory></VirtualHost><VirtualHost *:80>
DocumentRoot "/usr/local/httpd/htdocs/huawei"
ServerName www.huawei.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory '/usr/local/httpd/htdocs/huawei'>
Require all granted
</Directory></VirtualHost>
$ apachectl -t
Syntax OK
$ systemctl restart httpd
$ yum install libaio -y
# 创建用户
$ groupadd mysql
$ useradd -r -g mysql -s /bin/flsse mysql
# 下载二进制安装包
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz
2. 解压安装包
$ xz -d mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz
$ tar -xvf mysql-8.0.23-linux-glibc2.12-x86_64.tar -C /usr/local/
3. 创建链接文件mysql
$ cd /usr/local/
$ mv mysql-8.0.23-linux-glibc2.12-x86_64/ mysql
$ cd mysql
$ ls
bin docs include lib LICENSE man README share support-files
4. 添加环境变量
$ vim /root/.bash_profile
export PATH=$PATH:/usr/local/mysql/bin
$ source /root/.bash_profile
5. 安装后设置
$ cd /usr/local/mysql
$ mkdir mysql-files
# 设置属主属组为mysql,并设置权限
$ chown mysql:mysql ./mysql-files/
$ chmod 750 ./mysql-files/
# my.cnf[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/data/www.shengzhe.com.err
user=mysql
secure_file_priv=/usr/local/mysql/mysql-files
local_infile=OFF
$ chmod 644 /etc/my.cnf
# 初始化
$ mysqld --initialize --user=mysql
2021-03-08T02:01:01.726131Z 0 [System][MY-013169][Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 2129
2021-03-08T02:01:01.769911Z 1 [System][MY-013576][InnoDB] InnoDB initialization has started.
2021-03-08T02:01:03.007141Z 1 [System][MY-013577][InnoDB] InnoDB initialization has ended.
2021-03-08T02:01:04.249511Z 6 [Note][MY-010454][Server] A temporary password is generated for root@localhost: Yret+Q*EN9m)
$ mysqld_safe --user=mysql &[1] 2187
$ Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2021-03-08T02:01:09.995113Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
6.测试,并修改root密码
$ mysql -uroot -pYret+Q*EN9m)
mysql> alter user 'root'@'localhost' identified by 'Com.123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
7. 构建systemd服务单元配置文件
$ vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
Type=notify
# Disable service start and stop timeout logic of systemd for mysqld service.
TimeoutSec=0
# Start main service
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf $MYSQLD_OPTS# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql
# Sets open_files_limit
LimitNOFILE = 10000
Restart=on-failure
RestartPreventExitStatus=1
# Set environment variable MYSQLD_PARENT_PID. This is required for restart.
Environment=MYSQLD_PARENT_PID=1
PrivateTmp=false
$ cd /usr/local/httpd/htdocs
$ vim ./cisco/test.php
<?php
phpinfo();
?>
6. 创建MySQL管理员
mysql> create user 'dbadmin'@'%' identified with mysql_native_password by 'Com.123456';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all on *.* to 'dbadmin'@'%';
Query OK, 0 rows affected (0.01 sec)s
mysql> grant GRANT OPTION on *.* to 'dbadmin'@'%';
Query OK, 0 rows affected (0.01 sec)
7. 修改PHP的配置文件
$ vim /etc/php.ini
mysqli.default_socket = /tmp/mysql.sock
8. 创建测试文件
$ vim /usr/local/httpd/htdocs/cisco/mysqltest.php
<?PHP
$conn=mysqli_connect("localhost","dbadmin","123456Abc!");
if($conn){echo"ok";}else{echo"error";}
?>
$ systemctl restart httpd
$ curl www.cisco.com/mysqltest.php
ok
9. 安装phpMyAdmin
# 下载源码包
https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz
# 解压
$ tar -zxvf phpMyAdmin-5.1.0-all-languages.tar.gz -C /usr/local/httpd/htdocs/cisco/
$ cd /usr/local/httpd/htdocs/cisco/
$ mv phpMyAdmin-5.1.0-all-languages phpmyadmin
$ cd phpmyadmin
$ cp config.sample.inc.php config.inc.php
$ vim config.inc.php
cfg['blowfish_secret']='dbadmin'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
# 访问http://www.cisco.com/phpmyadmin/