zoukankan      html  css  js  c++  java
  • CentOS 5.5使用yum来安装LAMP(php运行环境)(转)

    1、配置防火墙,开启80端口、3306端口
     

      vi /etc/sysconfig/iptables
       -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(允许80端口通过防火墙)
       -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT(允许3306端口通过防火墙)
    特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
    添加好之后防火墙规则如下所示:
    #########################################################

    # Firewall configuration written by system-config-firewall
    # Manual customization of this file is not recommended.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT
    #########################################################
     
    /etc/init.d/iptables restart  #最后重启防火墙使配置生效
    2、关闭SELINUX
       vi /etc/selinux/config
       #SELINUX=enforcing       #注释掉
       #SELINUXTYPE=targeted    #注释掉
       SELINUX=disabled         #增加
       :wq  保存,关闭
       shutdown -r now   #重启系统


    系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容?版权所有,转载请注明出处及原文链接
    yum安装lamp环境详解

     

    1、yum update 检查一下系统更新 初次安装可能更新的时间会比较长,请耐心等待。

     

    2、yum install gcc gcc-c++ ;安装gcc软件编译环境。

     

    3、yum erase httpd  ;卸载系统自带的httpd (apache2.2.3)

     

    4、yum install zlib-devel libtool ncurses-devel libxml2-devel

    (zlib-devel 安装apache需要,否则出错 .libtool安装mysql时候需要.同时附带了autoconf automake imake 编译mysql 5.1.48时候会出错 需要autoconf重新配置一下)

    //两份合并后 测试成功

     

    1. 换源,sohu的相当好用。
    1.1备份CentOS-Base.repo
    cd /etc/yum.repos.d/
    cp CentOS-Base.repo CentOS-Base.repo.bak
    1.2替换源
    用vi打开CentOS-Base.repo,并将内容清空,然后将下面的内容复制进去,并保存。
    # CentOS-Base.repo
    #
    # This file uses a new mirrorlist system developed by Lance Davis for CentOS.
    # The mirror system uses the connecting IP address of the client and the
    # update status of each mirror to pick mirrors that are updated to and
    # geographically close to the client. You should use this for CentOS updates
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you can try the
    # remarked out baseurl= line instead.
    #
    #
    [base]
    name=CentOS-$releasever - Base
    baseurl=http://mirrors.sohu.com/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
    #released updates
    [updates]
    name=CentOS-$releasever - Updates
    baseurl=http://mirrors.sohu.com/centos/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
    #packages used/produced in the build but not released
    [addons]
    name=CentOS-$releasever - Addons
    baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras
    baseurl=http://mirrors.sohu.com/centos/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever - Plus
    baseurl=http://mirrors.sohu.com/centos/$releasever/centosplus/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5
    1.3更新一下。
    yum -y update
    2. 用yum安装Apache,Mysql,PHP.
    2.1安装Apache
    yum install httpd httpd-devel
    安装完成后,用/etc/init.d/httpd start 启动apache
    设为开机启动:chkconfig httpd on
    2.2 安装mysql
    2.2.1 yum install mysql mysql-server mysql-devel
    同样,完成后,用/etc/init.d/mysqld start 启动mysql
    2.2.2 设置mysql密码
    mysql>; USE mysql;
    mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
    mysql>; FLUSH PRIVILEGES;
    2.2.3 允许远程登录
    mysql -u root -p
    Enter Password: <your new password>
    mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
    完成后就能用mysql-front远程管理mysql了。
    2.2.4 设为开机启动
    chkconfig mysqld on
    3. 安装php
    yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
    /etc/init.d/httpd start
    4. 测试一下
    4.1在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。
    <?
    phpinfo();
    ?>
    4.2 防火墙配置
    a.添加.允许访问端口{21: ftp, 80: http}.
    iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT
    iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
    b.关闭防火墙{不推荐}.
    service iptables stop
    c.重置加载防火墙
    service iptables restart
    4.3然后在客户端浏览器里打开http://serverip/test.php,若能成功显示,则表示安装成功。
    至此,安装完毕。感慨,yum真是太好用了。

  • 相关阅读:
    最短路径之spfa
    最短路径之Bellman-Ford——解决负权边
    最短路径之Floyd-Warshall算法
    图上最短路径问题
    它们其实都是图(二分图)
    记忆化结果再利用 进一步探讨递推关系
    leetcode 376. 摆动序列 java
    leetcode 368. 最大整除子集 java
    leetcode 96. 不同的二叉搜索树 java
    leetcode 454. 四数相加 II java
  • 原文地址:https://www.cnblogs.com/zox2011/p/2443934.html
Copyright © 2011-2022 走看看