
CentOS/RHEL 7.6/6.9 및 Fedora 31/30에 Apache/PHP 7을 설치하는 방법
Apache 웹 서버와 함께 PHP 애플리케이션을 배포할 계획입니까? 이 튜토리얼은 CentOS, Redhat 및 Fedora 시스템에 Apache 웹 서버와 PHP를 설치하는 데 도움이 될 것입니다.권장 문서:
15 Best Security Tips for LAMP Stack (Apache-MySQL-PHP) for Linux
15 Best Security Tips for LAMP Stack (Apache-MySQL-PHP) for Linux Install Apache2, MySQL and PHP5 on Ubuntu and Debian System
15 Best Security Tips for LAMP Stack (Apache-MySQL-PHP) for Linux
1단계 – 전제 조건
우선 시스템에 필요한 rpm 저장소를 추가해야 합니다. 운영 체제에 따라 아래 명령 중 하나를 사용하십시오. CentOS/RHEL 7CentOS/RHEL 6rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Fedora 31rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Fedora 30sudo dnf install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm sudo dnf install http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm sudo dnf install http://rpms.famillecollet.com/fedora/remi-release-31.rpm
Fedora 29sudo dnf install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm sudo dnf install http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm sudo dnf install http://rpms.famillecollet.com/fedora/remi-release-30.rpm
sudo dnf install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm sudo dnf install http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm sudo dnf install http://rpms.famillecollet.com/fedora/remi-release-29.rpm
2단계 – Apache/PHP 설치
yum 시스템에서 필요한 저장소를 활성화한 후 이제 시스템에 Apache 및 PHP 패키지를 설치합니다. 그러면 시스템에 사용 가능한 최신 패키지가 설치됩니다. CentOS 및 RHEL 7/6의 경우 Fedora 31/30/29/28/27/26sudo yum --enablerepo=remi,remi-php71 install httpd php php-common
sudo dnf --enablerepo=remi install httpd php php-common
3단계 – PHP 모듈 설치
의 경우 애플리케이션에 필요한 PHP 모듈도 설치해야 했습니다. . 아래 명령은 자주 사용하는 PHP 모듈을 시스템에 설치합니다. 동일한 명령으로 다른 모듈을 설치할 수 있습니다. CentOS 및 RHEL 7/6의 경우Fedora의 경우 31/30/29/28/27/26sudo yum --enablerepo=remi,remi-php71 install php-cli php-pear php-pdo php-mysqlnd php-gd php-mbstring php-mcrypt php-xml
sudo dnf --enablerepo=remi install php-cli php-pear php-pdo php-mysqlnd php-gd php-mbstring php-mcrypt php-xml
4단계 – Apache 서비스 관리
이 시점에서 시스템에 Apache 웹 서버, PHP 및 모듈. 이제 Apache 서버를 시작하고 시스템 부팅 시 자동 시작되도록 활성화합니다. CentOS/RHEL 7 및 Fedora의 경우 CentOS/RHEL 6sudo systemctl start httpd.service sudo systemctl enable httpd.service
의 경우 이 자습서의 결과로 웹 호스팅 환경을 성공적으로 구성했습니다. Red Hat 기반 시스템.권장 문서:service httpd start chkconfig --levels 235 httpd on