• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3106
  • Last Modified:

Guidance with CentOS 7 startup basics

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.

$ ./ctlscript.sh 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.
3 Solutions
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)
Zephyr ICTCloud ArchitectCommented:
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.
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

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
ubixtechAuthor Commented:
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/ctlscript.sh start"
Launch at system startup. What is the best way to approach this with CentOS 7?
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.
Aman SubhanCommented:
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/ctlscript.sh start

Open in new window

This will hopefully start your services as a part of server startup :)
ubixtechAuthor Commented:
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.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now