Difference between revisions of "Tung httpd conf"
(→Running and Configuring Apache Server) |
(→Serving Personal Home Page) |
||
Line 16: | Line 16: | ||
===Serving Personal Home Page=== | ===Serving Personal Home Page=== | ||
− | + | # Login as root user | |
+ | # Edit Apache Server configuration file <b><code><font color=brown > /etc/httpd/conf/httpd.conf </font></code></b> | ||
+ | #* Inside IfModule tag, comment <b>“UserDir disable”</b> and uncomment <b>“UserDir public_html”</b> | ||
+ | # Restart the Apache server: <b><code><font color=green > service httpd restart</font></code></b> | ||
+ | # Logout root | ||
+ | # Create a <b>public_html</b> directory inside your home directory | ||
+ | # Change the permission of your home directory and the <b>public_html</b> to read and execute for other, so that the server can assess files in <b>public_html</b> by name. Enter follow command: | ||
+ | #* <b><code><font color=green > chmod 705 /home/user/public_html </font></code></b> | ||
+ | #* <b><code><font color=green > chmod 705 /home/user </font></code></b> | ||
+ | # Create index.html in <b>public_html</b> directory, write some html code in the file. | ||
+ | # Change the permission of index.htm to read only for other: <b><code><font color=green >chmod 704 /home/user/public_html/index.html </font></code></b> | ||
+ | # By default, selinux doesn't allow Apache Server to read file inside user's home. Change the default setting: <b><code><font color=green >setsebool -P httpd_enable_homedirs 1 </font></code></b> | ||
+ | # Check the context of public_html and index | ||
+ | #* By default, selinux has <code><font color=purple >context type httpd_user_content_t</font></code> for <code><font color=purple >/home/[^/]*/((www)|(web)|(public_html))(/.+)?</font></code> | ||
+ | #* Confirm the context type is correct: <b><code><font color=green >ls -Z public_html</font></code></b> | ||
+ | # Open a browser, and enter <code> http://hostname/~your-user-id/</code>. Your personal page should display. |
Revision as of 17:37, 27 July 2011
Running and Configuring Apache Server
Introduction
In this page, you are going to set up a Apache server and allow a user create his own personal web page.
Creating a Public Web Page
- Login as root user
- Configure the Apache server to start when the Fedora is booted:
chkconfig httpd on
- Start the Apache server:
service httpd start
- Create index.html in
/var/www/html/
directory, write some html code in the file - Open a browser, and enter
http://localhost
. Your page should display. - Make web page accesses by other hosts:
iptables -I INPUT -p tcp --dport http -j ACCEPT
Serving Personal Home Page
- Login as root user
- Edit Apache Server configuration file
/etc/httpd/conf/httpd.conf
- Inside IfModule tag, comment “UserDir disable” and uncomment “UserDir public_html”
- Restart the Apache server:
service httpd restart
- Logout root
- Create a public_html directory inside your home directory
- Change the permission of your home directory and the public_html to read and execute for other, so that the server can assess files in public_html by name. Enter follow command:
-
chmod 705 /home/user/public_html
-
chmod 705 /home/user
-
- Create index.html in public_html directory, write some html code in the file.
- Change the permission of index.htm to read only for other:
chmod 704 /home/user/public_html/index.html
- By default, selinux doesn't allow Apache Server to read file inside user's home. Change the default setting:
setsebool -P httpd_enable_homedirs 1
- Check the context of public_html and index
- By default, selinux has
context type httpd_user_content_t
for/home/[^/]*/((www)|(web)|(public_html))(/.+)?
- Confirm the context type is correct:
ls -Z public_html
- By default, selinux has
- Open a browser, and enter
http://hostname/~your-user-id/
. Your personal page should display.