|
Install HTTPD service
|
yum install httpd |
|
Check httpd status
|
systemctl status httpd.service |
|
Inspect Control Script
|
less /etc/systemd/system/multi-user.target.wants/httpd.service |
|
displays the contents of the httpd.service file for the Apache HTTP server in the systemd multi-user target.
|
|
|
Get default start-up state
|
systemctl get-default |
|
shows the default target (runlevel) that the system boots into.
|
|
|
Find config file
|
find / -name httpd.conf |
|
Inspect config file
|
nano /etc/httpd/conf/httpd.conf |
|
nano [location of config file found using
find] |
|
.htaccess & .htpasswd |
Note that these are hidden by default, to prevent files being viewed by web clients
|
ErrorLog |
Find and take note of where the errorlog is located (usually
logs/error_log) |
DocumentRoot |
The web document location is usually the
/var/www/html |
|
List processes and filters for those related to httpd
|
ps -ef ¦ grep httpd |
|
Rules for incoming traffic
|
iptables -L INPUT |
|
Create index.html file
|
1) Navigate to appropriate directory
|
|
e.g.:
cd /var/www/html |
|
|
2) create and edit file using nano
|
|
|
e.g.:
sudo nano index.html |
|
|
View access log
|
cat /var/log/httpd/access_log |
|
Request local page
|
curl http:/localhost |
|
MariaDB Installation
|
yum install mariadb-server |
|
Confirm MySQL/MariaDB is installed
|
find / -name mysql |
|
Start MariaDB
|
systemctl start mariadb |
|
Check MariaDB Status
|
systemctl status mariadb |
|
Confirm servers are running
|
ps -ef |
|
This produces a list of running servers, where you will search for
mysql in the far left column(the UID(User ID)) |
|
|
Set new password for mysqladmin root
|
mysqladmin -u root password [INSERT PASSWORD] |
|
Find config file (my.cnf) location
|
sudo find / -name my.cnf ¦ less |
|
Navigate to config file directory
|
cd [INSERT DIRECTORY] |
|
e.g. in my case, my.cnf was located found to be /etc/my.cnf, so
cd /etc is used |
|
|
View contents of config file
|
cat my.cnf |
|
Locate MySQL Daemon
|
find / -name mysqld |
|
Enter MariaDB Server
|
mysql -h localhost -u root -p |
|
Then enter password created previously. Note, password will not show any typing.
|
|
|
Create database
|
`CREATE DATABASE [database name];
|
|
e.g.
CREATE DATABASE food; |
|
|
Change to created database
|
USE [database] |
|
e.g. `USE food'
|
|
|
Exit MariaDB
|
quit |
|
Confirm database was created outside of MariaDB
|
Change to appropriate directory
cd /var/lib/mysql |
|
Display contents of current directory using
ls |
|
|
Create Table
|
CREATE TABLE restaurant (name VARCHAR(40), type VARCHAR(40), location VARCHAR(4));` |
|
VARCHAR(n) defines variable length
|
|
|
Insert values into restaurant table
|
INSERT INTO restaurant (name, type, location) values ("Pizzahut", "Italian", "SW10"); |
|
Show table
|
SHOW TABLES; DESCRIBE restaurant; SELECT * FROM restaurant; |
|
Delete value from table
|
DELETE FROM restaurant WHERE name="Pizza"&&location="SW10"; |
|
Create new user
|
GRANT SELECT ON food.restaurant TO bayan@localhost IDENTIFIED BY "bayans_password"; |
|
Confirm firewalld is running
|
systemctl status firewalld |
|
Check firewall conifiguration
|
firewall-cmd --list-all |
|
Display firewall rules
|
`iptables -L'
|
|
Services/ports available for sshd
|
systemctl status sshd |
|
Services/ports available for httpd
|
systemctl status httpd |
|
Services/ports available for vsftp
|
systemctl status vsftp |
|
if not installed, use yum install. e.g.
yum install vsftpd |
|
|
Stop firewalld, then check if running to confirm it is infact stopped**
|
systemctl stop firewalld |
|
Start firewalld
|
systemctl start firewalld |
|
Add http service to firewall configuration
|
firewall-cmd --add-service http |
|
Add ftp service to firewall configuration
|
firewall-cmd --add-service ftp |
|
iptables rules for accepting traffic for ports 22(SSH), 80(HTTP), and 21 (FTP)
|
iptables -A INPUT -p tcp --dport 22 -j ACCEPT |
iptables -A INPUT -p tcp --dport 80 -j ACCEPT |
|
iptables -A INPUT -p tcp --dport 21 -j ACCEPT |
|
|
Add rules to output chain
|
iptables -A OUTPUT -m state --state ESTABLISHED, RELATED -j ACCEPT |
|
Dropping default rules for INPUT and OUTPUT traffic
|
iptables -P INPUT DROP |
iptables -P OUTPUT DROP |
|
Install setroubleshoot and httpd
|
sudo yum install setroubleshoot httpd |
|
Enable httpd
|
systemctl enable httpd |
|
Start httpd
|
systemctl start httpd |
|
Check default directory for HTML files
|
cat /etc/httpdconf/httpd.conf | grep DocumentRoot |
|
Check SELinux permissions / context
|
ls -lZ index.html |
|
Temporarily disable SELinux enforcement for troubleshooting or testing without changing the permanent configuration.
|
setenforce 0 |
|
Re-enable SELinux enforcement after it has been disabled, restoring its security policies.
|
setenforce 1 |
|
Apply default SELinux to a file:
|
/sbin/restorecon -v /var/www/html/secret.html |
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.