We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
Here’s a detailed step-by-step guide to configure two HTML sites on an Apache web
server in Fedora:
---
### **Step 1: Install Apache**
1. Open a terminal and install Apache if it’s not already installed: ```bash sudo dnf install httpd -y ``` 2. Start the Apache service: ```bash sudo systemctl start httpd ``` 3. Enable Apache to start at boot: ```bash sudo systemctl enable httpd ```
---
### **Step 2: Create the Directories for the Websites**
1. Create directories for the two websites. For example: ```bash sudo mkdir -p /var/www/site1 sudo mkdir -p /var/www/site2 ``` 2. Set proper permissions: ```bash sudo chown -R apache:apache /var/www/site1 /var/www/site2 sudo chmod -R 755 /var/www/site1 /var/www/site2 ```
---
### **Step 3: Create the HTML Files**
1. Create an `index.html` file for each website: ```bash echo "<h1>Welcome to Site 1</h1>" | sudo tee /var/www/site1/index.html echo "<h1>Welcome to Site 2</h1>" | sudo tee /var/www/site2/index.html ```
---
### **Step 4: Configure Virtual Hosts**
1. Create separate configuration files for each website: ```bash sudo nano /etc/httpd/conf.d/site1.conf ``` Add the following content for Site 1: ```apache <VirtualHost *:80> ServerName site1.local DocumentRoot /var/www/site1 <Directory /var/www/site1> AllowOverride All Require all granted </Directory> </VirtualHost> ```
2. Repeat for Site 2:
```bash sudo nano /etc/httpd/conf.d/site2.conf ``` Add the following content for Site 2: ```apache <VirtualHost *:80> ServerName site2.local DocumentRoot /var/www/site2 <Directory /var/www/site2> AllowOverride All Require all granted </Directory> </VirtualHost> ```
---
### **Step 5: Update `/etc/hosts` for Local Testing**
1. Edit the `/etc/hosts` file to map the domain names to localhost: ```bash sudo nano /etc/hosts ``` 2. Add the following lines: ```plaintext 127.0.0.1 site1.local 127.0.0.1 site2.local ```
---
### **Step 6: Test the Configuration**
1. Check the Apache configuration for syntax errors: ```bash sudo apachectl configtest ``` - If there are no errors, you should see: `Syntax OK`.
---
### **Step 7: Restart Apache**
1. Restart the Apache service to apply the changes: ```bash sudo systemctl restart httpd ```
---
### **Step 8: Access the Websites**
1. Open a web browser and visit: - [http://site1.local](http://site1.local) for Site 1 - [http://site2.local](http://site2.local) for Site 2
---
### **Optional: Enable SELinux and Firewall Rules**
1. Allow HTTP traffic in the firewall: ```bash sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload ``` 2. Adjust SELinux context for the directories if needed: ```bash sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/site1(/.*)?" sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/site2(/.*)?" sudo restorecon -Rv /var/www/site1 sudo restorecon -Rv /var/www/site2 ```
---
These steps should successfully configure two separate HTML sites on your Apache server in Fedora. Let me know if you encounter any issues!