码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS 7.x 安装LAMP

时间:2018-10-11 11:40:16      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:var   添加   org   centos7   evel   .com   1.7   文本编辑   登陆   

CentOS 7.x 安装apache
[root@localhost ~]#yum -y install httpd httpd-devel
[root@localhost ~]# systemctl start  httpd
[root@localhost ~]# systemctl enable  httpd
 
CentOS 7.x 安装 Mariadb 数据库
[root@localhost ~]# yum -y install mariadb mariadb-server mariadb-libs mariadb-devel
[root@localhost ~]# systemctl start mariadb [root@localhost ~]# systemctl enable mariadb
数据库安全设置:
[root@localhost ~]# mysql_secure_installation
登陆数据库:
[root@localhost ~]# mysql -uroot -p
 
Centos7.x 使用yum安装php7
1.安装epel-release 
通过命令: 
yum -y install epel-release 
成功安装。 
2.安装PHP7 
终端再次运行如下命令: 
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 
成功获取PHP7的yum源,然后再执行: 
yum -y install php70w 
 
Centos7.x 使用yum安装php7.2
1、如果之前已经安装低版本php,先卸载:
[root@localhost ~]#yum -y remove php*
2、由于linux的yum源不存在php7.x,所以我们要更改yum源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm   rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
3、yum 安装php72w和各种拓展模块,选自己需要的即可
yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
4、最后,写一个PHP探测指针,测试PHP:
[root@localhost ~]#cd  /var/www/html/
[root@localhost ~]#vi info.php
<?php
        phpinfo();
?>
保存并退出
5、重启apache服务器:
[root@localhost ~]# systemctl restart httpd
6、访问 http://localhost/info.php
*将php与数据库关联:
[root@localhost ~]#yum install php-mysql
 
CentOS 7.x 安装phpmyadmin
1、先安装epel,不然安装pgpmyadmin时会出现找不到包。
[root@localhost ~]# yum install epel-release
[root@localhost ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
2、[root@localhost ~]# sudo yum install phpmyadmin
3、用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行。会有四处这样的代码行,用"Require all granted"取而代之
[root@localhost ~]# sudo vi /etc/httpd/conf.d/phpMyAdmin.conf
修改后的文件内容
  1. <Directory /usr/share/phpMyAdmin/>
  2.    AddDefaultCharset UTF-8
  3.    <IfModule mod_authz_core.c>
  4.      # Apache 2.4
  5.      <RequireAny>
  6.       # Require ip 127.0.0.1  #注释掉
  7.       # Require ip ::1   #注释掉
  8.       Require all granted   #新添加
  9.      </RequireAny>
  10. </IfModule>
  11. <IfModule !mod_authz_core.c>
  12.      # Apache 2.2
  13.      Order Deny,Allow
  14.      Deny from All
  15.      Allow from 127.0.0.1
  16.      Allow from ::1
  17.    </IfModule>
  18. </Directory>
  19. <Directory /usr/share/phpMyAdmin/setup/>
  20.    <IfModule mod_authz_core.c>
  21.      # Apache 2.4
  22.      <RequireAny>
  23.       #Require ip 127.0.0.1  #注释掉
  24.       #Require ip ::1   #注释掉
  25.       Require all granted   #新添加
  26.      </RequireAny>
  27.    </IfModule>
  28.    <IfModule !mod_authz_core.c>
  29.      # Apache 2.2
  30.      Order Deny,Allow
  31.      Deny from All
  32.      Allow from 127.0.0.1
  33.      Allow from ::1
  34.    </IfModule>
  35. </Directory>
4、[root@localhost ~]# systemctl restart  httpd

CentOS 7.x 安装LAMP

标签:var   添加   org   centos7   evel   .com   1.7   文本编辑   登陆   

原文地址:https://www.cnblogs.com/ponfey/p/9771086.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!