Redhat6下LAMP环境的搭建

LAMP是服务器系统中开源软件的一个十分普遍的组合。LAMP分别代表Linux + Apache + Mysql + Php | Python | Perl。就系统工程师来说,除了会部署LAMP环境,还应该熟练的掌握对环境的操作调优。


本文仅用于新手安装参考!


注意:自从Mysql被Oracle收购之后,很多时候使用MarriDB来代替Mysql!


环境介绍:

    操作系统:RHEL6.4

    IP地址:192.168.0.254



1. 安装Redhat6操作系统。

    具体安装视个人需求而定!


2. 安装Apache

    在命令行模式下,执行如下命令即可!

        #yum install httpd -y

    启动Apache 并配置 Apache开机自动运行

        #service httpd start

        #chkconfig httpd on

    配置防火墙允许访问Apache80端口[默认]

        #vim /etc/sysconfig/iptables

            .......

            -A INPUT -p udp --dport 80 -m state --state NEW -j ACCEPT

            -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT

            .......

        #service iptables restart

    测试Apache

        打开浏览器输入 http://192.168.0.254 即可看到Apache的Test Page 


3. 安装MarriDB

    在安装之前,确认系统中是否存在Mysql,如果存在则使用如下命令移除

        #yum remove mysql  mysql-server  mysql-devel  mysql-libs -y

    为了使得MarriDB能够兼容Mysql,需要安装REMI库来解决兼容性 和 安装MarriDB时软件包的依赖性问题,命令如下:

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

    安装兼容Mysql5.5的软件包命令如下:

        #yum -enablerepo=remi-test -disablerepo=remi install compat-mysql55

    创建安装MarriDB的repo文件

        32位

            # vi /etc/yum.repos.d/mariadb.repo

                # MariaDB 5.5 repository list

                # http://mariadb.org/mariadb/repositories/

                [mariadb]

                name = MariaDB

                baseurl = http://yum.mariadb.org/5.5/redhat6-x86

                gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

                gpgcheck=1

        64位

            # vi /etc/yum.repos.d/mariadb.repo

                # MariaDB 5.5 repository list

                # http://mariadb.org/mariadb/repositories/

                [mariadb]

                name = MariaDB

                baseurl = http://yum.mariadb.org/5.5/redhat6-amd64

                gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

                gpgcheck=1

    开始安装MarriDB,并配置MarriDB开机自动启动

        #yum update

        #yum install MariaDB-devel MariaDB-client MariaDB-server -y

        #chkconfig mysql on

        #service mysql start

    为Mysql的root账户设置密码,默认情况下,root账户的密码是空的

        #/usr/bin/mysql_secure_installation

            按照提示输入root新密码并移除匿名用户以及禁止root远程登录功能


4. 安装Php

    安装php,在命令行执行如下命令即可

        #yum install php -y

    测试php是否安装成功

        #service httpd restart

        #vim /var/www/html/phpinfo.php

            <?php

                phpinfo();

            ?>

        在网页输入 http://192.168.0.254/phpinfo.php,如果页面显示关于php的详细信息页,则成功

    说明:如果需要安装所有的php模块,执行如下命令;并重启httpd,然后访问http://192.168.0.254/phpinfo.php即可!

        #yum install php*

        #service httpd restart


5. 安装phpmyadmin

    PHPMyAdmin是Mysql的网页管理工具,默认情况下,RHEL的库中没有附带该软件包,需要使用epel来安装

    安装epel库

        # rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

    安装phpmyadmin

        # yum install phpmyadmin -y

    phpMyAdmin.conf文件在/etc/httpd/conf/phpMyAdmin.conf,只保留下面的两行,其余行注释

        Alias /phpMyAdmin /usr/share/phpMyAdmin

        Alias /phpmyadmin /usr/share/phpMyAdmin

    修改config.inc.php文件,将cookie修改为http

        # cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php

        

        # vi /usr/share/phpMyAdmin/config.inc.php

            [...] 

            /* Authentication type */

            $cfg['Servers'][$i]['auth_type'] = ‘http‘;

            [...]

        # service httpd restart

    测试PHPMyAdmin

        在网页输入http://192.168.0.254/phpmyadmin,输入Marridb用户名密码,即可看到管理界面!


到此为止,环境搭建完毕!












你可能感兴趣的:(lamp,redhat6)