Home  >  Article  >  Backend Development  >  How to install apache and php using yum

How to install apache and php using yum

藏色散人
藏色散人Original
2020-07-14 09:38:044089browse

Yum's method of installing apache and php: first execute the command "yum install -y httpd" to install apache; then start apache; then execute the command "yum install -y php" to install php; finally create a new PHP page. Just test it.

How to install apache and php using yum

yum install apache and php

1: Install apache

[root@ser6-52 ~]# yum install -y httpd

#验证是否安装成功
[root@ser6-52 ~]# rpm -qa | grep httpd
httpd-2.2.15-47.el6.centos.x86_64
httpd-tools-2.2.15-47.el6.centos.x86_64

Shows successfully installed.

#启动apache
[plain] view plain copy
[root@ser6-52 ~]# service httpd start  
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

If, when starting, the above appears:

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Need to modify /etc/httpd/conf/httpd.conf

vi  /etc/httpd/conf/httpd.conf

in the file Finally add: ServerName 127.0.0.1:80

#重启apache:
[root@ser6-52 ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

This error is no longer reported.

#Configure the system to let Apache start with the system:

[root@ser6-52 ~]# chkconfig --levels 235 httpd on

At this time apache has been installed, visit http://192.168.6.52 /You can see the following interface (Note: 192.168.6.52 is the IP of your server)

Note: The default root directory of Apache in CentOS is /var/www/html, configure File /etc/httpd/conf/httpd.conf. Other configuration is stored in the /etc/httpd/conf.d/ directory.

Two: Install php

[root@ser6-52 conf.d]# yum install -y php

Need to restart the Apache service:

[root@ser6-52 conf.d]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Three: Test

In order to test whether the installation is successful, you can create a new PHP page for testing. Use the vim editor to create a new page:

[root@localhost ~]# vi /var/www/html/info.php

Input: welcome,dandan!

Enter in the browser: http:/ /192.168.6.52/info.php

You can see:

indicating that the installation was successful.

--apache can also be started and stopped like this:

/usr/local/apache2/bin/apachectl start/stop

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to install apache and php using yum. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn