先安装mysql不做介绍

安装Apache

1.apache安装方法相对简单

yum install httpd

2.外网访问虚拟机中的地址,我们就需要修改一下apache的配置文件/etc/httpd/conf/httpd.conf

找到  #ServerName www.example.com:80 改为  ServerName localhost:80

找到  #Listen   改为  Listen:8080(linux中开放的端口号80XX)

3.修改完成之后我们需要再次启动httpd服务,并查看启动状态

service httpd start

Redirecting to /bin/systemctl start  httpd.service

service httpd status

Redirecting to /bin/systemctl status  httpd.service

4.此时你就可以访问你的服务器了,输入localhost或者ip地址,出现一 个Apache test page powered by centos的测试页面

安装PHP

1.php安装命令

yum install php

2.直接一路安装,安装完成之后再次重启httpd服务

service httpd start

Redirecting to /bin/systemctl start  httpd.service

3.重启之后我们进行测试PHP相关信息,我们新建一个PHP界面进行测试

在apache默认页面路径/var/www/html下新建一个test.php页面,添加代码

<?php phpinfo();?>

 

4.访问这个页面,输入localhost/test.php,或者

ip:端口号/test.php就可以看见php环境的配置信息了。

关联php和mysql

1.搜索模块

yum search php

2.安装相关模块

 yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml  php-xmlrpc

如果mysql版本过高可能安装 yum install php-mysql会报错解决方法参见下面链接

https://www.cnblogs.com/liquan-anran/p/10224177.html

3.安装完成,重启mysqld,重启httpd

重新访问刚才的info.php,我们发现已经多了MySQL的相关信息。

至此,php在linux中的运行环境就已经成功配置完成了。

mysql yum安装默认文件夹及相关命令

停止命令:service mysql stop

运行状态:service mysql status

 

配置文件路径:/etc/httpd/conf/httpd.confapache

service httpd start

service httpd stop

运行状态:service httpd status

 

php

php默认页面路径:/var/www/html

 

 

posted on 2019-01-05 13:50  小人物-烟火  阅读(676)  评论(0编辑  收藏  举报