Install Apache,MySQL,PHP By ‘yum’ Command

环境:阿里云ECS CentOS 7.3

首先更新yum:

yum -y update

安装Apache:

yum install httpd, httpd-devel

安装完后,httpd文件在/etc/下

打开httpd:

httpd -k start

出现错误:AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 172.19.114.38. Set the ‘ServerName’ directive globally to suppress this message

修改httpd.conf文件,路径/etc/httpd/conf下

vim httpd.conf

找到 # ServerName www.example.com:80 将其修改为 ServerName [ip地址 or 域名]:80

比如 ServerName 47.100.121.40:80或者ServerName www.fixbugs.cn:80

最后在输入:

httpd -k start

通过浏览器访问可测试apache是否搭建成功。

安装MariaDB:

yum install -y mariadb mariadb-server

启动MariaDB:

systemctl start mariadb

设置开机自启:

systemctl enable mariadb

对MariaDB进行设置:

mysql_secure_installation

最后:mysql -uroot -p重新登录

安装PHP5.6

yum install epel-release

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

yum –enablerepo=remi-php56 install php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd php-redis

安装php-fpm:

yum –enablerepo=remi-php56 install php-fpm

验证版本:

php -v

打开php-fpm:

systemctl start php-fpm.service

php-fpm状态查看:

systemctl status php-fpm.service

Apache配置php:

找到httpd.conf文件

vim httpd.conf

找到DirectoryIndex index.html:

修改为DirectoryIndex index.html index.php

找到AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

添加:

AddType application/x-httpd-php-source .phps

AddType application/x-httpd-php .php

Apache重启:

httpd -k restart

测试:在网站根目录下可在httpd.conf中查看根目录路径,默认在/var/www/html下,添加一个index.php文件

过程:

vim index.php

写入:

<?php

phpinfo();

?>

保存退出.

通过浏览器输入ip地址,如果查看到许多php相关的信息则表示成功。如下图

“Install Apache,MySQL,PHP By ‘yum’ Command”的2个回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注