zoukankan      html  css  js  c++  java
  • Linux操作系统Centos7.2版本搭建Apache+PHP+Mysql环境

    对于在校大学生来说腾讯云1元主机很划算,所以就申请了一台,打算在上面学习下linux,使用版本为centos7.2版本。在服务器上比较推荐centos,此版本生命周期较长,而且网上有关centos的教程很多,方便学习。

    Centos6版本的推荐看下面这个教程,很详细

    http://blog.csdn.net/u014427391/article/details/51381097

    安装Apache、PHP、Mysql、连接Mysql数据库的包:

    yum -y install httpd 

    yum -y install php 

    yum -y install php-fpm

    yum -y install mysql

    yum -y install mysql-server

    yum -y install php-mysql

    除了mysql-server其他都安装成功

    错误:No package mysql-server available.

    Package php-mysql-5.4.16-36.el7_1.x86_64 already installed and latest version

    Nothing to do

    查找原因是因为CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了,有两种解决方案,一是安装mariadb,二是从官网下载mysql-server.因为对mariadb不熟悉,所以我采用了第二种解决方案。

    wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

    rpm -ivh mysql-community-release-el7-5.noarch.rpm

    yum install mysql-community-server

    然后需要确定,输入y回车即可

    Is this ok[y/d/N]:y

    接下来等待下载,需要确认的输入y回车即可

    成功!

    接下来安装常用扩展包

    安装Apache扩展包

    yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql 

    安装PHP扩展包

    yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-devel

    安装Mysql扩展包

    yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

    配置Apache、mysql开机启动

    chkconfig httpd on  

    chkconfig mysqld on

    没有error,成功

     

    重启Apache、mysql服务(注意这里和centos6有区别,7不能使用6的方式)

    service mysqld restart

    service php-fpm start

    service httpd restart

    打开mysql

    初次安装mysql是没有密码的

    mysql –u root

     

    show databases;  #注意分号

     

    可重置密码

    set password for 'root'@'localhost' =password('xxxxxxxx');

     

    环境检查

    netstat –tunlp

    如下图,php监听9000端口,apache监听80端口,mysql监听3306端口

     

    php测试环境是否成功

    进入apache的web根目录:/var/www/html 中自己写一个最简单的php页面

    cd /var/www/html

    touch test.php

    vi test.php

    进入到了控制模式之后按键盘字母 i 进入到编辑模式,将如下代码输入到文件中

    <?php

    echo "<title>Test Page</title>";

    phpinfo()

    ?>

    按 esc 退出编辑模式,回到控制模式,输入 :wq 然后回车,在浏览器中输入服务器IP地址+php文件名,例:115.115.115.115/test.php

    出现下图则成功。

     

    初学linux,如有错误模糊之处,欢迎指正交流,接下来的学习中,我都将记录下自己的学习过程与心得与大家分享。

  • 相关阅读:
    POJ 2506 Tiling
    POJ 2586 Y2K Accounting Bug
    POJ 2965 The Pilots Brothers' refrigerator (DFS)
    POJ 2499 Binary Tree
    POJ 3006 Dirichlet's Theorem on Arithmetic Progressions (素数)
    beautifulsoup 基本语法 含class属性查找小技巧class_
    xlrd库的使用
    pytest框架 里 fixture 参数化的方法
    ddt数据驱动
    mac电脑 pip安装包后 撞到了系统python里面的解决方法
  • 原文地址:https://www.cnblogs.com/MemoryLily/p/5722357.html
Copyright © 2011-2022 走看看