ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Building a LAMP Server on Fedora 25 with SaltStack

    IT Discussion
    salt saltstack devops linux lamp apache mariadb mysql php fedora fedora 25
    1
    1
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by scottalanmiller

      A LAMP server is one of the most basic builds that you can do on Linux, and also one of the most useful. In our LAMP setup here we will have PHP 7, MariaDB and Apache. Some optional pieces, like Fail2Ban are included as well. This quick installation just gets you up and running, it does not configure SSL but does install certbot for LetsEncrypt to make it easier. This is just a LAMP starter template onto which you can deploy your own applications or files.

      # cat /srv/salt/lamp.sls

      install_network_packages:
        pkg.installed:
          - pkgs:
            - wget
            - unzip
            - firewalld
            - net-tools
            - php
            - mariadb
            - mariadb-server
            - mod_ssl
            - php-pecl-apcu
            - httpd
            - fail2ban
            - certbot
            - varnish
            - memcached
            - php-pecl-memcache
            - php-pecl-memcached
            - php-mysqlnd
            - php-pdo
            - php-gd
            - php-mbstring
            - php-imap
            - ImageMagick
            - nginx
            - htop
            - glances
            - ZipArchive
            - php-pecl-zip
            - php-theseer-fDOMDocument
            - sysstat
            - dnf-automatic
      
      /var/www/html/:
        file.directory:
          - user: apache
          - group: apache
          - recurse:
            - user
            - group
      
      FedoraServer:
        firewalld.present:
          - name: FedoraServer
          - block_icmp:
            - echo-reply
            - echo-request
          - default: False
          - masquerade: False
          - ports:
            - 22/tcp
            - 80/tcp
            - 443/tcp
      
      httpd:
        pkg.installed: []
        service.running:
          - require:
            - pkg: httpd
      
      mariadb:
        pkg.installed: []
        service.running:
          - require:
            - pkg: mariadb
      

      After this has been run, you should have both Apache and MariaDB up and running and ready for use. Your firewall will be configured and you should be able to see a web page immediately. Of course this is overly simplistic with everything thrown into a single SLS file rather than broken up as you would expect to do in product. Also this does not set a secure password for the database server, that would be a more advanced topic to tackle using a Salt Pillar. This is a basic LAMP install, but very serviceable.

      If you don't want to expose SSH at all, simply remove the line "-22/tcp" and SSH will be closed completely.

      If you have your Salt Master and Salt Minion all set up, you can apply this SaLt State file with a command like this one, assuming that "lamp1" is the name of your new server.

      salt 'lamp1' state.apply lamp
      
      1 Reply Last reply Reply Quote 3
      • 1 / 1
      • First post
        Last post