<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ray Heffer &#187; yum</title>
	<atom:link href="http://www.rayheffer.com/tag/yum/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rayheffer.com</link>
	<description>Enterprise Technologies</description>
	<lastBuildDate>Thu, 05 Aug 2010 09:34:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Building a secure web server with CentOS 5, part 2</title>
		<link>http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/</link>
		<comments>http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 20:44:02 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[http.conf]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[secure]]></category>
		<category><![CDATA[vsftp]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://wp.rayheffer.com/?p=91</guid>
		<description><![CDATA[Part 1 &#124; Part 2 &#124; Part 3 &#124; Troubleshooting Part 2: Configuring the Server Configuring CentOS Edit /etc/hosts and /etc/sysconfig/network with hostnames Install Packages Example of /etc/hosts: # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost 67.34.32.11 www.mydomain.com Example of /etc/sysconfig/network NETWORKING=yes HOSTNAME=www.mydomain.com Installing Packages # yum [...]]]></description>
			<content:encoded><![CDATA[<!-- wp-jquery-lightbox, a WordPress plugin by ulfben --> <div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F91%2Fbuilding-a-secure-web-server-with-centos-5-part-2%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F91_2Fbuilding-a-secure-web-server-with-centos-5-part-2_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F91%2Fbuilding-a-secure-web-server-with-centos-5-part-2%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.rayheffer.com/36/building-a-secure-web-server-with-centos-5-part-1/">Part 1</a> | <strong>Part 2</strong> | <a href="http://www.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/">Part 3</a> | <a href="http://www.rayheffer.com/117/troubleshooting-your-centos-5-web-server/">Troubleshooting</a></p>
<p><strong>Part 2: Configuring the Server</strong></p>
<p><strong>Configuring CentOS</strong></p>
<ul>
<li>Edit <code>/etc/hosts</code> and <code>/etc/sysconfig/network</code> with hostnames</li>
<li>Install Packages</li>
</ul>
<p><strong>Example of /etc/hosts:</strong></p>
<p><code># Do not remove the following line, or various programs<br />
# that require network functionality will fail.<br />
127.0.0.1 localhost<br />
67.34.32.11 www.mydomain.com</code></p>
<p><strong>Example of /etc/sysconfig/network</strong></p>
<p><code>NETWORKING=yes<br />
HOSTNAME=www.mydomain.com</code></p>
<p><strong>Installing Packages</strong></p>
<p><code># yum -y install httpd openssl-devel openssl mod_ssl vsftpd rpm-build rpm-devel autoconf automake lynx gcc<br />
# yum -y install mysql mod_auth_mysql mysql-devel mysql-server<br />
# yum -y install mod_python python python-devel<br />
# yum -y install perl mod_perl mod_perl-devel openssl-perl perl-Convert-ASN1 perl-Date-Calc perl-DateManip perl-HTML-Parser perl-libwww-perl perl-CPAN perl-DBD-MySQL perl-XML-Parser<br />
# yum -y install php-devel php php-domxml php-gd php-mbstring php-mysql php-ncurses php-pear<br />
# yum -y install webalizer<br />
# yum -y install sendmail sendmail-cf</code><br />
<span id="more-91"></span><br />
<strong>Creating Directory Structure</strong></p>
<p>All websites will be held in <code>/home/.sites/</code>. The first site that needs to be created is the <code>_default</code> site, which will be used as this servers default website.</p>
<p><code># mkdir /home/.sites<br />
# cd /home/.sites<br />
# mkdir _default<br />
# cd _default<br />
# mkdir logs private cgi-bin web<br />
# cd web<br />
# mkdir stats</code></p>
<p>Now change the ownership of these directories to adminftp as follows:</p>
<p><code># cd /home/.sites<br />
# chown adminftp _default -R</code></p>
<p>Configure the required system services sto start at boot:</p>
<p><code># chkconfig httpd on<br />
# chkconfig mysqld on<br />
# chkconfig vsftpd on<br />
# chkconfig sshd on</code></p>
<p><strong>Configuring Apache</strong></p>
<p>Apache runs as the httpd service, and it’s configuration file is contained in <code>/etc/httpd/conf</code>. To run in a ‘virtual’ hosting environment, we will now configure the httpd.conf file. But first things first, lets backup the httpd.conf file!</p>
<p><code># cd /etc/httpd/conf<br />
# cp httpd.conf httpd.conf.backup</code></p>
<p>Now edit httpd.conf and make the following changes, substituting <code>mydomain.com</code> for your own domain:</p>
<p><code>ServerAdmin admin@mydomain.com<br />
ServerName www.mydomain.com:80<br />
NameVirtualHost *:80<br />
DirectoryIndex index.html index.htm index.html.var</code></p>
<p><code><br />
ServerAdmin admin@mydomain.com<br />
DocumentRoot /home/.sites/_default/web<br />
ServerName www.mydomain.com<br />
ScriptAlias /cgi-bin/ /home/.sites/_default/cgi-bin/<br />
ErrorLog /home/.sites/_default/logs/error_log<br />
TransferLog /home/.sites/_default/logs/access_log</code></p>
<p><code> </code></p>
<p><code>Options FollowSymLinks<br />
Options +Includes<br />
AllowOverride All</code></p>
<p><code> </code></p>
<p>Save and exit the httpd.conf file and then restart the httpd service.</p>
<p><code># /etc/init.d/httpd restart</code></p>
<p><strong>Configuring VSFTP</strong></p>
<p>VSFTP stands for Very Secure File Transfer Protocol. However using the installation defaults isn&#8217;t actually that secure as it allows anonymous access and doesn&#8217;t restrict which users can access the servers FTP service. In order to harden the security of VSFTP, several configuration changes must be made. Please note that some of these lines may be commented out by default, with a #, so remember to remove this if required.</p>
<p><code># vi /etc/vsftpd/vsftpd.conf</code></p>
<p><code>anonymous_enable=NO<br />
xferlog_file=/var/log/vsftpd.log<br />
idle_session_timeout=600<br />
nopriv_user=nobody<br />
ascii_upload_enable=YES<br />
ftpd_banner= **** WARNING - Your actions are being logged ****</code></p>
<p><code>pam_service_name=vsftpd<br />
userlist_enable=YES<br />
listen=YES<br />
tcp_wrappers=YES<br />
chroot_local_user=YES<br />
userlist_deny=NO</code></p>
<p>Next, we need to configure <code>vsftpd.userlist</code> and specify which users can FTP to the server. This compliments the <code>userlist_deny</code> setting in vsftpd.conf. When set to <code>NO</code>, this makes the <code>vsftpd.userlist</code> file a list of users that ARE allowed to log in.</p>
<p><code># vi /etc/vsftpd/user_list</code></p>
<p>Remove all of the users that are listed in this file by default, and add ONLY the users that require access to the FTP server.</p>
<p><strong>Configuring MySQL</strong></p>
<p>MySQL is configured using /etc/my.cnf, but prior to any configuration this configuration file has only the bare minimum required to start the MySQL daemon. However there are 5 templates that we can base the configuration on; <code>my-huge.cnf</code>, <code>my-innodb-heavy-4G.cnf</code>, <code>my-large.cnf</code>, <code>my-medium.cnf</code>, and <code>my-small.cnf</code>. These are each configured depending on the RAM and the priority that MySQL has on this server.</p>
<p>We will use my-medium.cnf as this has been based on a web server where MySQL is not the primary role of the server but could have frequent use. If you are hosting a few sites with light use then use <code>my-small.cnf</code>.</p>
<p><code># cd /usr/share/doc/mysql-server-<br />
# cp my-medium.cnf /etc/my.cnf</code></p>
<p>Once this has overwritten my.cnf, the mysqld service must be restarted.</p>
<p><code># /etc/init.d/mysqld restart</code></p>
<p>Now the root password for MySQL must be set using the following command. Do NOT use the same root password as the Linux root password.</p>
<p><code># mysqladmin -u root password </code></p>
<p><strong>Setting up phpMyAdmin</strong></p>
<p>Administration of MySQL is carried out using phpMyAdmin which is a free open source software package licensed under the GNU. Nearly all hosting providers use this, and is pretty much the de-facto standard these days.</p>
<p>1) Download <a href="http://www.phpmyadmin.net" onclick="pageTracker._trackPageview('/outgoing/www.phpmyadmin.net?referer=');">phpMyAdmin</a>,<br />
2) Extract the contents to a directory called phpMyAdmin (case sensitive)<br />
3) Transfer the phpMyAdmin directory to /home/.sites/_default/web (Use FTP and login using the user you setup previously, as described in the Configuring FTP using VSFTPD section).</p>
<p>Now we need to configure the <code>confic.inc.php</code> file as follows:</p>
<p><code># vi /home/.sites/_default/web/phpMyAdmin/config.inc.php</code></p>
<p>Look for:</p>
<p><code>$cfg['Servers'][$i]['auth_type'] = 'config’;</code></p>
<p>Change ‘<code>config</code>’ to ‘<code>http</code>’ then restart MySQL.</p>
<p><code># /etc/init.d/mysqld restart</code></p>
<p>You should now be able to log into phpMyAdmin by going to http://www.mydomain.com/phpMyAdmin. Log on using ‘root’ and the password you specified for MySQL. You will now be presented with the phpMyAdmin web control panel. By default, MySQL contains a test database which is not required, so as a security measure, this needs to be deleted. To do this, click on ‘Databases’, then tick test. Click ‘Drop’ and then click ‘Yes’ to confirm.</p>
<p>When you are ready proceed to <a href="http://wp.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/" onclick="pageTracker._trackPageview('/outgoing/wp.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/?referer=');">part 3</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
