LCA Web Server & Database Administration 3 — Questions and Answers
Question 1: Which Apache directive sets the document root for a virtual host?
- RootDir
- DocumentRoot (Correct answer)
- ServerRoot
- WebRoot
Correct answer: DocumentRoot
DocumentRoot specifies the directory from which Apache serves files for a given virtual host or global server context.
Question 2: What does the MySQL innodb_flush_log_at_trx_commit=1 setting guarantee?
- Logs are flushed every second regardless of transactions
- Logs are flushed to disk on every transaction commit ensuring ACID compliance (Correct answer)
- InnoDB skips log flushing for performance
- Logs are written only when the buffer is full
Correct answer: Logs are flushed to disk on every transaction commit ensuring ACID compliance
Setting innodb_flush_log_at_trx_commit=1 ensures the redo log is flushed to disk at every commit, providing full ACID durability.
Question 3: In Nginx, how do you enable gzip compression for HTML and CSS responses?
- compress on; types text/html text/css;
- gzip on; gzip_types text/html text/css; (Correct answer)
- deflate enable; mime text/html;
- zip_output on; content text/css;
Correct answer: gzip on; gzip_types text/html text/css;
The gzip on directive enables compression, and gzip_types specifies which MIME types should be compressed.
Question 4: Which command backs up a single PostgreSQL database to a file?
- pgdump dbname > file.sql
- pg_dump dbname > file.sql (Correct answer)
- psql dump dbname file.sql
- postgres-backup dbname file.sql
Correct answer: pg_dump dbname > file.sql
pg_dump is the PostgreSQL utility that creates a consistent backup of a single database in SQL or custom format.
Question 5: What is the effect of the Apache directive 'Options -Indexes' in a Directory block?
- Disables all mod_rewrite rules
- Prevents Apache from generating directory listings when no index file exists (Correct answer)
- Blocks access to hidden files
- Removes execute permissions from CGI scripts
Correct answer: Prevents Apache from generating directory listings when no index file exists
Options -Indexes prevents Apache from generating a directory listing, returning a 403 Forbidden instead when no index file is found.
Question 6: Which MySQL statement creates a user and sets a password in one step?
- INSERT INTO mysql.user VALUES ('user','host','pass')
- CREATE USER 'user'@'host' IDENTIFIED BY 'password' (Correct answer)
- ADD USER 'user' PASSWORD 'password'
- GRANT USER 'user'@'host' WITH PASSWORD 'password'
Correct answer: CREATE USER 'user'@'host' IDENTIFIED BY 'password'
CREATE USER 'user'@'host' IDENTIFIED BY 'password' is the standard SQL statement to create a MySQL user account with authentication.
Question 7: In Nginx, what does the try_files directive do?
- Tries multiple SSL certificate files in order
- Checks for the existence of files in order and serves the first match (Correct answer)
- Attempts to connect to multiple upstream backends
- Loads configuration files from multiple directories
Correct answer: Checks for the existence of files in order and serves the first match
try_files checks for each specified file or directory in order and serves the first one found, falling back to the final argument (often a named location or error code).
Which Apache directive sets the document root for a virtual host?