1. 程式人生 > >Centos7安裝Apache伺服器和PHP

Centos7安裝Apache伺服器和PHP

1. 安裝Apache

參考文件:  http://blog.51cto.com/13525470/2070375

(1) 使用yum包安裝Apache軟體 , 並檢視

[[email protected] ~]# yum -y install httpd*
[[email protected] ~]# rpm -qa | grep httpd     --檢視安裝的http包
httpd-manual-2.4.6-67.el7.centos.6.noarch
httpd-tools-2.4.6-67.el7.centos.6.x86_64
httpd-2.4.6-67.el7.centos.6.x86_64
httpd-devel-2.4.6-67.el7.centos.6.x86_64

 (2) 啟動Apache網站

[[email protected] ~]# systemctl start httpd.service  -- 啟動服務
[[email protected] ~]# netstat -an | grep :80     --檢視httpd的埠
[[email protected] ~]# ps -ef |grep httpd      --檢視httpd是否啟動
[[email protected] ~]# ps -aux | grep httpd    --檢視httpd是否啟動
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   20585   root    4u  IPv6 402909      0t0  TCP *:http (LISTEN)
httpd   20586 apache    4u  IPv6 402909      0t0  TCP *:http (LISTEN)
httpd   20587 apache    4u  IPv6 402909      0t0  TCP *:http (LISTEN)
httpd   20588 apache    4u  IPv6 402909      0t0  TCP *:http (LISTEN)
httpd   20589 apache    4u  IPv6 402909      0t0  TCP *:http (LISTEN)
httpd   20590 apache    4u  IPv6 402909      0t0  TCP *:http (LISTEN)

(3) 測試完成.

(4) 安裝編譯所需要的信賴軟體包 (可選)

[[email protected] ~]# yum -y install gcc* make* apr apr-util pcre apr-devel apr-util-devel  pcre-devel

2.安裝PHP

參考文件: https://blog.csdn.net/ixsure/article/details/73852406

參考文件主要: https://blog.csdn.net/sdd220/article/details/77327776

(1)  安裝PHP

yum -y install php

 檢視PHP的安裝包

rpm -qa | grep php

(2) 安裝SCL

yum install centos-release-scl

(3) 安裝 php55

yum install php55 php55-php php55-php-gd php55-php-mbstring

(4) 使用 php -v 檢視到php的版本完成

 

注意:

1. 後期部署專案時根據個人情況的不同可能會發生缺少某些依賴,如有需要安裝缺少的即可.

2. 如果專案部署需要用到許可權問題導致專案無法訪問,請看我的這篇部落格->

https://blog.csdn.net/qq_40820862/article/details/83832221