How to install apache and php using yum

藏色散人
Release: 2023-03-02 14:30:02
Original
4058 people have browsed it

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
Copy after login

#验证是否安装成功
[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
Copy after login

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
Copy after login

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
Copy after login

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

vi  /etc/httpd/conf/httpd.conf
Copy after login

in the file Finally add: ServerName 127.0.0.1:80

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

This error is no longer reported.

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

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

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
Copy after login

Need to restart the Apache service:

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

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!