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