美文网首页
08. centos7 LAMP环境搭建简述

08. centos7 LAMP环境搭建简述

作者: Lv_0 | 来源:发表于2018-03-15 19:17 被阅读0次
    • Apache

    1. 检查是否安装
    rpm -qa | grep httpd 或者 yum list installed | grep httpd
    
    1. 查看yum源上软件版本信息
    yum list | grep httpd 或者 yum -y list httpd*
    
    1. 安装httpd
    yum install -y httpd
    
    1. 安装结果
    rpm -qa | grep httpd 或者 yum list installed | grep httpd
    
    1. 启动Apache
    service httpd start  启动
    service httpd stop  停止
    service httpd restart  重启
    service httpd status  状态
    ps -ef|grep httpd  查看进程
    
    1. 设置开机启动
    systemctl enable httpd.service 或 chkconfig httpd on
    
    1. 设置防火墙
    firewall-cmd --permanent --zone=public  --add-service=http
    firewall-cmd --permanent --zone=public  --add-service=https
    firewall-cmd --reload
    
    1. 查看监听
    netstat -tulp
    
    1. 测试apache
    http://ip
    
    • MariaDB

    1. 检查是否安装
    rpm -qa | grep maria或者 yum list installed | grep maria
    
    1. 查看yum源上软件版本信息
    yum list | grep maria或者 yum -y list maria*
    
    1. 安装mariadb
    yum -y install mariadb mariadb-server (mariadb-libs mariadb-devel)
    
    1. 安装结果
    rpm -qa | grep maria或者 yum list installed | grep maria
    
    1. 启动mariadb
    service mariadb start  启动
    service mariadb stop  停止
    service mariadb restart  重启
    service mariadb status  状态
    ps -ef|grep mariadb  查看进程
    
    1. 设置开机启动
    systemctl enable mariadb.service 或 chkconfig mariadb on
    
    1. 查看监听
    netstat -tulp
    
    1. 安全设置
    mysql_secure_installation
    Enter y y n y y
    
    1. 测试数据库
    mysql -u root -p
    show databases
    
    • PHP

    1. 检查是否安装
    rpm -qa | grep php或者 yum list installed | grep php
    
    1. 查看yum源上软件版本信息
    yum list | grep php或者 yum -y list php*
    
    1. 安装php
    yum -y install php
    
    1. 安装组件
    yum install -y php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
    
    1. 安装结果
    rpm -qa | grep php或者 yum list installed | grep php
    
    1. 测试文件
    路径:/var/www/html/
    新建:info.php
    内容:
      <?php
        phpinfo();
      ?>
    
    1. 重启apache
    systemctl restart httpd.service
    
    1. 查看监听
    netstat -tulp
    
    1. 测试php
    http://ip/info.php(若为index.php,则直接http://ip即可)
    
    • Tomcat

    1. 安装jdk
    rpm -qa | grep jdk
    yum list | grep jdk
    yum -y install java-1.8.0-openjdk*
    java -version
    
    1. 安装tomcat
    rpm -qa | grep tomcat
    yum list | grep tomcat
    yum -y install tomcat
    
    1. 环境变量配置
    用户:
      echo $HOME/.bashrc
    全部:
      /etc/profile
    
    JAVA_HOME=/usr/lib/jvm/java
    PATH=$PATH:$JAVA_HOME/bin
    CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    CATALINA_BASE=/usr/share/tomcat
    CATALINA_HOME=/usr/share/tomcat
    export JAVA_HOME PATH CLASSPATH CATALINA_BASE CATALINA_HOME
    
    source  /etc/profile
    echo $JAVA_HOME
    
    1. 配置防火墙
    添加
    firewall-cmd --zone=public --add-port=80/tcp --permanent
    firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent 
    重新载入
    firewall-cmd --reload
    查看
    firewall-cmd --zone=public --query-port=80/tcp
    删除
    firewall-cmd --zone=public --remove-port=80/tcp --permanent
    参数
    --permanent设置永久生效
    
    1. 重启tomcat
    systemctl start tomcat.service
    systemctl enable tomcat.service
    
    1. 结果查看
    ps -ef | grep tomcat
    netstat -tulp | grep pid
    

    相关文章

      网友评论

          本文标题:08. centos7 LAMP环境搭建简述

          本文链接:https://www.haomeiwen.com/subject/xkqafftx.html