准备篇:

    1.清空防火墙 iptables -F 或者关闭防火墙 /etc/init.d/iptables stop,如果要防火墙开机不要启动 chkconfig iptables off

    2.关闭SELINUX

        1.vim /etc/selinux/config 

        SELINUX=enforcing #注释掉 

        SELINUXTYPE=targeted #注释掉

        SELINUX=disabled #增加

        :wq保存退出

        2.setenforce 0 临时修改成Permissive,开机启动后会生效

    3.修改镜像源,原来的镜像源下载速度太慢现在修改成163镜像源

        1.访问http://mirrors.163.com/

        2.首先备份/etc/yum.repos.d/CentOS-Base.repo

            mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

        3. 下载对应linux版本的repo文件,这里我下载的是centos6的

        wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

        4.修改刚才下载的repo文件

        mv /etc/yum.repos.d/CentOS6-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo

        5. yum clean all

        6.yum makecache

安装篇

  一.安装Apache

    1.yum install httpd -y

    2./etc/init.d/httpd start #启动Apache

    3.chkconfig httpd on #设为开机启动

    4./etc/init.d/httpd restart #重启Apache

  二.安装MySQL

    1.yum install mysql mysql-server -y

    2./etc/init.d/mysqld start #启动MySQL

    3.chkconfig mysqld on #设为开机启动

    4.cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

    5.为root账户设置密码

    mysql_secure_installation
    回车,根据提示输入Y
    输入2次密码,回车
    根据提示一路输入Y
    最后出现:Thanks for using MySQL!
    MySql密码设置完成,重新启动 MySQL
    /etc/init.d/mysqld restart #重启
    /etc/init.d/mysqld stop #停止
    /etc/init.d/mysqld start #启动

  三.安装PHP

    1.yum install php -y

    2.安装PHP组件,使PHP支持MySQL等等

    yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt -y

    3./etc/init.d/mysqld restart #重启MySql
    /etc/init.d/httpd restart #重启Apache

配置篇 

    一、Apache配置   

    1.vim /etc/httpd/conf/httpd.conf #编辑文件

 

  二.php配置

    /etc/init.d/httpd restart #重启Apche

测试篇
    cd /var/www/html
    vim index.php #输入下面内容
    <?php
        phpinfo();
    ?>
    :wq! #保存退出
    在客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!
    注意:apache默认的程序目录是/var/www/html

相关文章: