未命名文章
物联网系统实践1:Linux基础 Day 3
一、实验任务及目的
了解下载Typecho源码,通过Web界面完成博客安装
二、实验内容
apache环境配置
httpd命令
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# httpd -v
Server version: Apache/2.4.62 (Rocky Linux)
Server built:   Jan 29 2025 00:00:00
[root@localhost ~]# curl -I 127.0.0.1
HTTP/1.1 403 Forbidden
Date: Thu, 19 Jun 2025 01:09:17 GMT
Server: Apache/2.4.62 (Rocky Linux)
Last-Modified: Sat, 17 May 2025 02:45:05 GMT
ETag: "1dc4-6354be2d9ae40"
Accept-Ranges: bytes
Content-Length: 7620
Content-Type: text/html; charset=UTF-8[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]# httpd -t
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
Syntax OK
[root@localhost ~]# ServerName 127.0.0.1:80
-bash: ServerName: command not found
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]# httpd -t
Syntax OK
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]#  systemctl reload httpdMPM多路处理模块
[root@localhost ~]#  cat /etc/httpd/conf.modules.d/00-mpm.conf |grep mpm
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
#LoadModule mpm_worker_module modules/mod_mpm_worker.so
LoadModule mpm_event_module modules/mod_mpm_event.so
[root@localhost ~]#  ps aux |grep httpd
root       31389  0.0  0.6  20200 11600 ?        Ss   09:08   0:00 /usr/sbin/httpd -DFOREGROUND
apache     34112  0.0  0.4  22272  7400 ?        S    09:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache     34113  0.0  0.6 1440104 11372 ?       Sl   09:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache     34114  0.0  0.6 1440104 11184 ?       Sl   09:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache     34115  0.0  1.1 1571240 19788 ?       Sl   09:15   0:00 /usr/sbin/httpd -DFOREGROUND
root       43794  0.0  0.1   3876  2176 pts/0    S+   09:41   0:00 grep --color=auto httpdprefork模式
[root@localhost ~]# echo "LoadModule mpm_prefork_module modules/mod_mpm_prefork.so" > /etc/httpd/conf.modules.d/00-mpm.conf
[root@localhost ~]# ls -l /usr/lib64/httpd/modules/mod_mpm_prefork.so
-rwxr-xr-x. 1 root root 40272 Apr 29 03:43 /usr/lib64/httpd/modules/mod_mpm_prefork.so
[root@localhost ~]# httpd -S 2>/dev/null | grep "config file"
[root@localhost ~]# chmod 644 /etc/httpd/conf.modules.d/00-mpm.conf
[root@localhost ~]# chown root:root /etc/httpd/conf.modules.d/00-mpm.conf
[root@localhost ~]# httpd -t
Syntax OK
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# httpd -V | grep -i mpm
Server MPM:     prefork主配置⽂件 httpd.conf
[root@localhost ~]# httpd -M |grep dir
 dir_module (shared)
 userdir_module (shared)
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]#  mkdir -p /data/html
[root@localhost ~]# echo "<h1>hello world</h1>" > /data/html/index.html
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]#  systemctl restart httpd
[root@localhost ~]#  chcon -R -t httpd_sys_content_t /data/html
[root@localhost ~]# setenforce 0
[root@localhost ~]# curl 127.0.0.1
<h1>hello world</h1>
[root@localhost ~]# echo "<h1>hello linux</h1>" > /data/html/index.htm
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl 127.0.0.1
<h1>hello world</h1>
[root@localhost ~]#  vim /etc/httpd/conf/httpd.conf
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl 127.0.0.1
<h1>hello world</h1>Options指令

[root@localhost ~]# cat /etc/httpd/conf.d/welcome.conf
#
# This configuration file enables the default "Welcome" page if there
# is no default index page present for the root URL.  To disable the
# Welcome page, comment out all the lines below.
#
# NOTE: if this file is removed, it will be restored on upgrades.
#
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /usr/share/httpd/noindex>
    AllowOverride None
    Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /poweredby.png /usr/share/httpd/icons/apache_pb3.png
Alias /system_noindex_logo.png /usr/share/httpd/icons/system_noindex_logo.png
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
[root@localhost ~]#  mkdir -p /data/html/dir
[root@localhost ~]#  cd /data/html/dir
[root@localhost dir]# touch f1 f2
[root@localhost dir]#  vim /etc/httpd/conf/httpd.conf
[root@localhost dir]#  systemctl restart httpd
[root@localhost dir]# ln -s /etc/hosts /data/html/dir/hostsAllowOverride指令
[root@localhost dir]#  vim /etc/httpd/conf/httpd.conf
[root@localhost dir]# systemctl reload httpd
[root@localhost dir]#  echo "Options FollowSymLinks Indexes" > /data/html/dir/.htaccess
[root@localhost dir]# systemctl reload httpd
[root@localhost dir]# vim /etc/httpd/conf/httpd.conf<Location "/status"> 
    <requireany> 
        require all denied 
        require ip 192.168.88.0/24 
#定义特定的⽹段能够访问
 
    </requireany> 
        SetHandler server-status 
#指定状态信息
 
</Location> 
ExtendedStatus On
httpd -t
systemctl restart httpdecho "This is NO.1 website!" > /data/website1/index.html 
echo "This is NO.2 website!" > /data/website2/index.html 
cho "This is NO.3 website!" > /data/website3/index.htmlLAMP架构部署
安装Apache
yum install -y httpd 
systemctl enable --now httpd
systemctl stop firewalld
setenforce 0
安装php
yum install -y php* 
systemctl enable --now php-fpm 
systemctl status php-fpm 
systemctl restart httpd安装MySQL
yum install -y mariadb-server mariadb
 systemctl enable --now mariadb 
 mysqladmin password '123456' 
 mysql -uroot -p123456 -e "show databases;"PHP探针测试
<?php 
    phpinfo(); 
?>
数据库连接测试
<?php 
$servername = "localhost"; 
$username = "root"; 
$password = "123456"; 
$conn = mysqli_connect($servername, $username, $password); 
 
if (!$conn) { 
         die("Connection failed: " . mysqli_connect_error()); 
    }
    
    echo "连接MySQL...成功!"; 
?> 
安装phpmyadmin
cd /var/www/html 
wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip
unzip phpMyAdmin-5.1.1-all-languages.zip 
mv phpMyAdmin-5.1.1-all-languages phpmyadmin
部署typecho个⼈博客
cd /var/www/html
mkdir typecho 
cd typecho 
wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip 
unzip typecho.zip

三、实验总结
重新用本地数据库部署一遍个人博客,感觉还是怪有意思的,之前用centos和阿里云的服务器部署过一遍,网址贴在这里 zidayo.cn,这个typecho的主题也同样炫酷,哈哈哈。不错不错。至于问题倒是没有遇到,教程还是很详细的!!
            本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 梓dayo
        
     评论
            
                匿名评论
                隐私政策
            
            
                你无需删除空行,直接评论以获取最佳展示效果