Linux服务器下载apache

Linux服务器下载apache

centos7安装Apache

  • 安装Apache

yum install httpd
  • 设置httpd服务开机启动

systemctl enable httpd
  • 启动Apache

systemctl start httpd
  • 查看Apache的状态

## systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2020-04-12 09:10:39 CST; 44s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 32781 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─2580 /usr/sbin/httpd -DFOREGROUND
           ├─2581 /usr/sbin/httpd -DFOREGROUND
           ├─2582 /usr/sbin/httpd -DFOREGROUND
           ├─2583 /usr/sbin/httpd -DFOREGROUND
           ├─2584 /usr/sbin/httpd -DFOREGROUND
           └─2585 /usr/sbin/httpd -DFOREGROUND
  • 确认80端口的状态

##  netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:http            0.0.0.0:*               LISTEN      2580/httpd         
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      2185/sshd           
tcp        0      0 localhost:32000         0.0.0.0:*               LISTEN      1161/java           
udp        0      0 0.0.0.0:bootpc          0.0.0.0:*                           683/dhclient        
udp        0      0 iZ1i4qd6oynml0Z:ntp     0.0.0.0:*                           771/ntpd            
udp        0      0 localhost:ntp           0.0.0.0:*                           771/ntpd            
udp        0      0 0.0.0.0:ntp             0.0.0.0:*                           771/ntpd            
udp        0      0 0.0.0.0:56212           0.0.0.0:*                           683/dhclient        
udp6       0      0 [::]:ntp                [::]:*                              771/ntpd            
udp6       0      0 [::]:63075              [::]:*                              683/dhclient        
  • 查看Apache的版本

##  httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug  8 2019 11:41:18
  • Apache命令

systemctl stop httpd   停止Apache服务
systemctl start httpd  启动Apache服务
systemctl restart httpd  重启Apache服务
systemctl disable httpd  禁用Apache开机自启动
systemctl enable httpd  Apache开机自启动
systemctl reload httpd  更改配置后重新加载Apache服务

ubuntu版本安装apache2

  • 安装apache2

sudo apt-get install apache2
  • 手动启动使用(默认安装完成后是启动的)

sudo /etc/init.d/apache2 start
  • 测试安装成功

ps -ef | grep httpd 
  • 重启服务器

sudo /etc/init.d/apache2 restart

下载完成后需要打开安全组设置开放80端口

apache2的部署目录 /var/www/html
如果当前用户没有权限操作/var/www/html
使用sudo临时提升权限,将 /var/www/html的权限设置成777,原先是755。设置了之后,ubuntu用户就可以往html目录中放置文件或文件夹了
sudo chmod -R 777 /var/www/html
编写一个网页使用fileZilla部署到apache上,远程访问

开放关闭服务器防火墙

CentOs7关闭防火墙的命令

1:查看防火状态

systemctl status firewalld

service  iptables status

2:暂时关闭防火墙

systemctl stop firewalld

service  iptables stop

3:永久关闭防火墙

systemctl disable firewalld

chkconfig iptables off

4:重启防火墙

systemctl enable firewalld

service iptables restart

posted on   Chase_Hanky  阅读(895)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示