Rheladvancedlinux Cheat Sheet r3v1
Rheladvancedlinux Cheat Sheet r3v1
This cheat sheet should help you get started with developing a (web) application on Red
Hat Enterprise Linux (RHEL). We’ll assume you have a VM running RHEL, by - for example
- having run through the steps in the “Using Vagrant to Get Started with RHEL” blog
# systemctl start httpd mariadb Start the httpd and mariadb services. Instead
of ‘start’, you can also use stop or restart, for
obvious use cases.
# systemctl enable httpd mariadb Enable the httpd and mariadb services to
start at next boot. You can also use disable,
mask or unmask.
So the framework is installed and services should be running; let’s check if everything
is ok by checking out the logs. (You must either be a member of the ‘adm’ group on the
system, or run these commands with ‘sudo’ prepended to them to see all log messages.)
1
Now in order to test our app in the VM, we need the IP address of the server. For that
we want to see the IP address configured for the first network card, called ‘eth0’ in most
virtual machines:
Now let’s drop an example PHP file in /var/www/html to see if everything works
$ cat << EOF > /var/www/html/test.php All text between the first line and EOF
<?php
will be added to /var/www/html/test.php.
phpinfo();
?> Any existing content in that file will be
EOF overwritten. This is called a ‘heredoc’.
Now we can download the test.php file from either the same machine, or our local
workstation:
Generally, files in /var/www/html are owned by apache.In a dev environment, you might
want to make those files owned by apache and a developer group. Here are some
commands that are useful to make that a reality.
2
# chown -R :developers /var/www/html Change ownership of /var/www/html and
all files in that directory to the developers
group.
# chmod g+s /var/www/html Special command to make sure that all files
created in /var/www/html are owned by the
group that own /var/www/html; it sets to
so-called sticky bit.
Maybe you have a script that you want to use on that server, too. You’ll need to make it
executable first:
Red Hat Enterprise Linux 7 ships with a security feature called SELinux. SELinux basically
labels all files, and then whitelists what labels a program (e.g. Apache) is allowed to read.
# ausearch -sv no --comm httpd Search the audit log for recently denied
events triggered by Apache (‘httpd’). Useful
for debugging an application that might be
running into SELinux related problems.
# semanage fcontext -l | grep '/var/ View all SELinux rules that potentially apply
www'
to /var/www in the extensive SELinux docs.
Install the policycoreutils-python package
with yum to get the ‘semanage’ command.
If you have a database on a separate server, you need to allow Apache to initiate network
connections, which SELinux denies by default. This is done by setting an SELinux boolean.
3
The above should hopefully get you started with developing on RHEL, but you can do so
much more! For example, here are some commands to run a program in the background in
your shell.
And if you need to get an idea on how your application or system is performing, you might
like these commands
Finally, maybe you want to use Java instead of PHP. These two commands install some
programs you might want to use in that case
# subscription-manager repos --enable Enable the Software Collections
rhel-server-rhscl-7-rpms
repositories to install packages from
(required for Maven)
4
About the Author
Maxim has done some development in Ruby, PHP and Python in the
past and is currently learning Java, because, well,
just because.
@MaximBurgerhout Linkedin