Guidance with CentOS 7 startup basics

Posted on 2014-08-15
Last Modified: 2014-08-26
I have been charged with the responsibility of rolling out a few Centos 7 based webservers based on the bitnami wordpress stack. I have everything working well expect for the following items I am stuck on.

1. How do I make it so the apache and mySQL services run at startup? If i run this command by hand it works until the next reboot.

$ ./ start

2. How do I open up web traffic (port 80) using firewallld.

I am familiar with doing this with CentOS 6 using iptables and init.d but this new version is very different. Any guidance is appreciated.
Question by:ubixtech
    LVL 61

    Expert Comment

    1) nothing changed:
    chkconfig httpd on
    chkconfig mysqld on
    2) i dont know about firewalld, probrbly it has to be edited in xml files in /etc/firewalld
    you can install system-config-firewall and uninstall firewalld and work like on RHEL6 (at least I did so)
    LVL 25

    Assisted Solution

    by:Zephyr ICT
    1) The "systemd-way" way of enabling a service to start at next reboot is like this:

    systemctl enable apache2.service

    2) Firewalld isn't that difficult
    - First try to determine your default zone:
    firewall-cmd --get-default-zone
    - Make sure the zone that is default is the one you'd like use, otherwise change it (e.g dmz, trusted):
    firewall-cmd --set-default-zone=zonename
    (you might also be best off if you set the zone in your network-file as well "ZONE=dmz" for example)
    - To set the port for http:
    firewall-cmd --zone=dmz --add-service=http --permanent (use permanent to keep the setting)
    - After configuring all, reload the firewall:
    firewall-cmd --complete-reload

    More info: man firewall-cmd ;-)

    If you get stuck, let us know.
    LVL 2

    Expert Comment

    1) as spravtek said, use "systemctl" , if you use chkconfig as gheist says, CentOS 7 tells you what commands it is using instead.

    2) You can continue using iptables.

    So systemctl stop firewalld / systemctl disable firewalld and then systemctl enable iptables / systemctl start iptables, before that you should put your iptables config into /etc/sysconfig/iptables
    LVL 61

    Expert Comment

    1) it prints commands both ways. There are still some services that are old type and systemctl shows chkconfig command
    2) you can use system-config-network like in EL6
    LVL 2

    Author Comment

    Thanks for all the replies.

    (Worked) chkconfig httpd on
    (Did not work) chkconfig mysqld on

    However they did not persist upon reboot. I am assuming since this is a lamp stack and the software isnt technically installed as a service.

    I think my solution to this is to simple have the command
    "./opt/wordpress/ start"
    Launch at system startup. What is the best way to approach this with CentOS 7?
    LVL 61

    Assisted Solution

    Sorry we wera assuming that you installed LAMP stack using centos packages.
    No idea what you got on your disk, but anything your package left in /etc/init.d/ should be chkconfig-ed on
    And once enabled service starts at every boot.
    LVL 3

    Accepted Solution

    You can place your startup script in /etc/rc.local as this will run after all scripts completes their startup sequence

    Just add your line in the end:
    sh /opt/wordpress/ start

    Open in new window

    This will hopefully start your services as a part of server startup :)
    LVL 2

    Author Closing Comment

    Thanks for the assistance. I was able to modify the start-up script and get things rolling. All of your suggestions helped me achieve a resolution.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
    Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
    The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
    The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now