How To Install Apache, Php 7

Previous= $store.search.results.main.result.stats.totalNbPages" type=button


Traducciones al Español

A LAMP stack is a particular bundle of software packages commonly used for hosting website content. The bundle consists of Linux, Apache, MariaDB, và PHP (LAMP). This guide shows you how to lớn install a LAMP stack on a CentOS 7 obatambeienwasirherbal.com.

Bạn đang xem: How to install apache, php 7

Before You Begin

Apache

Install & Configure

Install Apache using CentOS’s package manager.

Install Apache 2.4:

sudo yum install httpdEnable Apache khổng lồ start at boot and start the Apache service:

sudo systemctl enable httpd.servicesudo systemctl start httpd.serviceCreate a httpd-mpm.conf tệp tin and add the code in the example to lớn turn off KeepAlive và adjust the resource use settings. The settings shown below are a good starting point for a obatambeienwasirherbal.com 2GB:

Note









Create a symbolic links from your virtual hosts file in the sites-available directory lớn the sites-enabled directory. Replace example.com.conf with the name of your own virtual hosts file.

sudo ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf

Configure SELinux to Allow HTTP

SELinux is enabled by mặc định on CentOS 7 obatambeienwasirherbal.coms. Its mặc định setting is to restrict Apache’s access lớn directories until explicit permissions are granted.

Without these steps, Apache does not start & may give the following error:

Jun 21 17:58:09 example.com systemd<1>: Failed khổng lồ start The Apache HTTP Server.Jun 21 17:58:09 example.com systemd<1>: Unit httpd.service entered failed state.Jun 21 17:58:09 example.com systemd<1>: httpd.service failed.Use chown khổng lồ make apache the owner of the web directory:

sudo chown apache:apache -R /var/www/html/example.com/Modify the permissions for files & directories:

cd /var/www/html/example.com/find . -type f -exec sudo chmod 0644 ;find . -type d -exec sudo chmod 0755 ;Use SELinux’s chcon lớn change the file security context for website content:

sudo chcon -t httpd_sys_content_t /var/www/html/example.com -Rsudo chcon -t httpd_sys_rw_content_t /var/www/html/example.com -REnable Apache khổng lồ start at boot & restart the service for the above changes to take place:

sudo systemctl enable httpd.servicesudo systemctl restart httpd.serviceNote
In addition, if you plan to use any HTTPD scripts on the server, update the corresponding SELinux Boolean variable. Khổng lồ allow HTTPD scripts and modules lớn connect lớn the network, use the sudo setsebool -P httpd_can_network_connect on command.

Xem thêm: Thế Nào Là Vpn? Mpls Vpn Là Gì ? Định Nghĩa Và Giải Thích Ý Nghĩa


Configure FirewallD to lớn Allow HTTP Connections

FirewallD is enabled for CentOS 7 obatambeienwasirherbal.coms, but HTTP is not included in the mặc định set of services.

View the default set of services:

sudo firewall-cmd --zone=public --list-servicesssh dhcpv6-clientTo allow connections to Apache, địa chỉ cửa hàng HTTP as a service:

sudo firewall-cmd --zone=public --add-service=http --permanentsudo firewall-cmd --zone=public --add-service=httpVisit your domain name or public IP to test the Apache server & view the mặc định Apache page.

Note

Rename Apache’s mặc định welcome page. When this file is present it takes precedence over other configurations via the LocationMatch directive.

sudo mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.bk

Ensure that all lines noted above are uncommented. A commented line begins with a semicolon (;).