<?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>configure php &#8211; Scott Mcintyre</title>
	<atom:link href="https://scott.cm/tag/configure-php/feed/" rel="self" type="application/rss+xml" />
	<link>https://scott.cm</link>
	<description>Web Operations Engineer,  Linux Systems Administrator,  mySQL DBA,  MongoDB DBA,  Python+PHP Developer,  Performance Engineer</description>
	<lastBuildDate>Sat, 19 Jan 2013 06:13:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.2.3</generator>
	<item>
		<title>Setting up an MFA Server</title>
		<link>https://scott.cm/setting-up-an-mfa-server/</link>
				<pubDate>Thu, 30 Aug 2007 08:20:10 +0000</pubDate>
		<dc:creator><![CDATA[Scott Mcintyre]]></dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[apache automate]]></category>
		<category><![CDATA[auto add domains]]></category>
		<category><![CDATA[auto configure apache]]></category>
		<category><![CDATA[auto configure bind]]></category>
		<category><![CDATA[bind auto configure]]></category>
		<category><![CDATA[bind auto generate]]></category>
		<category><![CDATA[bind automate]]></category>
		<category><![CDATA[centos install apache]]></category>
		<category><![CDATA[centos install mySQL]]></category>
		<category><![CDATA[centos install php]]></category>
		<category><![CDATA[centos install vsftpd]]></category>
		<category><![CDATA[configure apache]]></category>
		<category><![CDATA[configure mysql]]></category>
		<category><![CDATA[configure php]]></category>
		<category><![CDATA[mfa server]]></category>

		<guid isPermaLink="false">https://scott.cm/2007/08/30/setting-up-an-mfa-server/</guid>
				<description><![CDATA[Tired of paying someone to setup your server? Want a quick way to setup thousands of domains? Read on&#8230; I have made a quick guide on how to setup a server specifically for MFA sites from start to finish. The server will consist of, Web server &#8211; Apache Database &#8211;]]></description>
								<content:encoded><![CDATA[<p>Tired of paying someone to setup your server?  Want a quick way to setup thousands of domains?  Read on&#8230;</p>
<p>I have made a quick guide on how to setup a server specifically for MFA sites from start to finish. The server will consist of,</p>
<ul>
<li>Web server &#8211; Apache</li>
<li>Database &#8211; mySQL</li>
<li>Scripting Language &#8211; PHP</li>
<li>FTP Daemon &#8211; vsFTPD</li>
<li>DNS Server &#8211; Bind</li>
</ul>
<p>We are going to assume you are using centOS and have yum available.  This should only be used on a fresh install.  So lets begin,</p>
<p><strong>Installing Services</strong></p>
<p>To make this quick we are just going to use the RPM&#8217;s available from the depositories.  At the shell prompt execute,</p>
<p><code><br />
yum -y install httpd httpd-devel mysql mysql-server mysql-devel vsftpd bind bind-libs bind-utils php php-cli<br />
</code></p>
<p>Now that the services are installed it&#8217;s time to configure them.</p>
<p><span id="more-6"></span></p>
<p><strong>Configure Apache</strong></p>
<p>Depending on which centOS version you are using you will either have apache 1.x (centos4) or apache 2.x (centos5) we are going to assume apache 2.x however as the change are only minor config changes they are the same anyway. </p>
<p>Rather than opening and configuring we will just do a quick replacement on the file for the NameVirtualHost and to include a single file in which we will keep all the vhosts.</p>
<p><code><br />
perl -pi -e 's/#NameVirtualHost \*:80/NameVirtualHost \*:80\ninclude conf\/domains.conf/g' /etc/httpd/conf/httpd.conf<br />
</code></p>
<p>This will edit the config for you and if you view the config you should see something like this</p>
<p><a href='https://scott.cm/wp-content/uploads/2007/08/2.png' title='Apache Configuration'><img src='https://scott.cm/wp-content/uploads/2007/08/2.thumbnail.png' alt='Apache Configuration' /></a></p>
<p><strong>Configure DNS</strong></p>
<p>When configuring the DNS we are only going to setup 1 domain which will be the primary nameservers,  we will use masterdomain.com as an example throughout.  There will not be any domains actually setup other than the primary nameserver domain as these will be setup later with the script we build.</p>
<p><i>Setup the standard configuration (recreating as centOS 5 does not provide /etc/named.conf)</i><br />
<code><br />
cat &gt;/etc/named.conf &lt;&lt;EOM<br />
// Default named.conf generated by AdminGeekZ</p>
<p>//Add your machines IP if you wish to use this server as the resolvers<br />
acl &quot;trusted&quot; {127.0.0.1;};<br />
options {<br />
version &quot;Bind&quot;;<br />
allow-recursion { trusted; };<br />
allow-notify { trusted; };<br />
allow-transfer { trusted; };</p>
<p>        directory &quot;/var/named&quot;;<br />
        dump-file &quot;/var/named/data/cache_dump.db&quot;;<br />
        statistics-file &quot;/var/named/data/named_stats.txt&quot;;<br />
};<br />
include &quot;/etc/rndc.key&quot;;</p>
<p>EOM<br />
</code></p>
<p>Now setup the nameservers we will be using the following for our example,</p>
<p>&#8211; ns1.masterdomain.com -> 10.1.1.1<br />
&#8211; ns2.masterdomain.com -> 10.2.2.2</p>
<p><code><br />
cat &gt;/var/named/masterdomain.com.db &lt;&lt;EOM<br />
$TTL 6200<br />
@       6200   IN      SOA     ns1.masterdomain.com.      server.masterdomain.com.    (<br />
                                        2006070312<br />
                                        6200<br />
                                        7200<br />
                                        1419200<br />
                                        6200<br />
                                        )</p>
<p>masterdomain.com.  6200   IN      NS      ns1.masterdomain.com.<br />
masterdomain.com.  6200   IN      NS      ns2.masterdomain.com.</p>
<p>masterdomain.com.  6200   IN      MX      5       mail.masterdomain.com.</p>
<p>mail    6200   IN      CNAME   masterdomain.com.<br />
www     6200   IN      CNAME   masterdomain.com.</p>
<p>ns1     6200   IN      A       10.1.1.1<br />
ns2     6200   IN      A       10.2.2.2</p>
<p>masterdomain.com.  6200   IN      A       10.1.1.1<br />
EOM</p>
<p>#Now add the domain to the named configuration</p>
<p>cat &gt;&gt;/etc/named.conf &lt;&lt;EOM<br />
zone &quot;masterdomain.com&quot; {<br />
        type master;<br />
        file &quot;/var/named/masterdomain.com.db&quot;;<br />
};<br />
EOM<br />
#Now restart bind</p>
<p>/etc/init.d/named restart<br />
</code></p>
<p>Now we create a dns zone template, this is for our bulk setup script later.</p>
<p><code><br />
cat &gt;/etc/template.named &lt;&lt;EOM<br />
$TTL 6200<br />
@       6200   IN      SOA     ns1.cdomain.com.      server.cdomain.com.    (<br />
                                        2006070312<br />
                                        6200<br />
                                        7200<br />
                                        1419200<br />
                                        6200<br />
                                        )</p>
<p>cdomain.com.  6200   IN      NS      ns1.masterdomain.com.<br />
cdomain.com.  6200   IN      NS      ns2.masterdomain.com.</p>
<p>cdomain.com.  6200   IN      MX      5       mail.cdomain.com.<br />
mail    6200   IN      CNAME   cdomain.com.<br />
www     6200   IN      CNAME   cdomain.com.</p>
<p>cdomain.com.  6200   IN      A       10.1.1.1<br />
EOM<br />
</code></p>
<p>Your /etc/named.conf should look something like this now,</p>
<p><a href='https://scott.cm/wp-content/uploads/2007/08/3.png' title='Named Configuration'><img src='https://scott.cm/wp-content/uploads/2007/08/3.thumbnail.png' alt='Bind Configuration' /></a></p>
<p>That&#8217;s all that is required for this section of bind now.</p>
<p><strong>Setting up FTP/SSH Account</strong></p>
<p>For ease of use we will have all domains managed by one FTP account of the username node which accesses /home/httpd/domains</p>
<p><code><br />
mkdir -p /home/httpd/domains<br />
adduser -d /home/httpd/domains node<br />
echo "my??password12" | passwd node --stdin<br />
</code></p>
<p>You will have to chown and chmod this directory later for extra security.</p>
<p><strong>Creating Setup Script</strong></p>
<p>We will now use a script which can be used to add domains easily,  this will use the base we already setup earlier. </p>
<p><i>The Script</i><br />
<code><br />
cat &gt;/root/setup.sh &lt;&lt;EOF<br />
#!/bin/bash</p>
<p>if [ -z &quot;$1&quot; ]; then<br />
echo -n &quot;Syntax: setup.sh domain.com&quot;<br />
exit 0<br />
fi</p>
<p>if [ ! -d &quot;/home/httpd/domains/\$1&quot; ]<br />
then<br />
mkdir /home/httpd/domains/\$1</p>
<p>cat &gt;&gt;/etc/httpd/conf/domains.conf &lt;&lt;EOM<br />
&lt;VirtualHost *:80&gt;<br />
    ServerAdmin sysadmin@admingeekz.com<br />
    ServerName server.masterdomain.com<br />
    ServerName \$1<br />
    ServerAlias www.\$1<br />
    DocumentRoot /home/httpd/domains/\$1<br />
&lt;/VirtualHost&gt;</p>
<p>EOM</p>
<p>cat &gt;&gt;/etc/named.conf &lt;&lt;EOM<br />
zone &quot;\$1&quot; {<br />
        type master;<br />
        file &quot;/var/named/\$1.db&quot;;<br />
};</p>
<p>EOM</p>
<p>cp -f /etc/template.named /etc/buffernamed<br />
replace &quot;cdomain.com&quot; &quot;\$1&quot; -- /etc/buffernamed<br />
mv /etc/buffernamed /var/named/\$1.db<br />
chown named:named /var/named/\$1.db</p>
<p>chown -R node:node /home/httpd/domains/\$1<br />
/etc/init.d/named reload<br />
/etc/init.d/httpd reload</p>
<p>echo &quot;Added \$1 has been setup&quot;<br />
else<br />
        echo &quot;\$1 is already setup&quot;<br />
	exit 0<br />
fi</p>
<p>EOF<br />
chmod 700 /root/setup.sh<br />
</code></p>
<p>That&#8217;s the script created and to add a domain you simply run</p>
<p><i>/root/setup.sh domain.com</i></p>
<p><strong>Bulk Adding Domains</strong></p>
<p>Now that everything is setup and ready the last part is to bulk add all of your domains.  To do this we are going to have them in a list (without www.) so have a file called domains.txt which should look something like this,</p>
<blockquote><p>
google.com<br />
msn.com<br />
yahoo.com
</p></blockquote>
<p>When you have your list and want to setup the domains first comment out the apache and named reload lines from the /root/setup.sh script to make this go much faster (you can reload once completed) and then loop through the domains by using something like this,</p>
<p><code><br />
for i in `cat domains.txt`;do /root/setup.sh $i;done<br />
</code></p>
<p>Once completed reload named and apache</p>
<p><code><br />
/etc/init.d/named reload<br />
/etc/init.d/apache reload<br />
</code></p>
<p><strong>Final Touches</strong></p>
<p>Now that your server is setup and you can add domains easily the last thing to do is to start all the services and make sure they start on boot.  You may wish to optimize the server aswell as any other misc tweaks (Such as adding index.php to the DirectoryIndex).</p>
<p><code><br />
/etc/init.d/httpd restart<br />
/etc/init.d/mysqld restart<br />
/etc/init.d/vsftpd restart<br />
/etc/init.d/named restart<br />
chkconfig httpd on<br />
chkconfig mysqld on<br />
chkconfig vsftpd on<br />
chkconfig named on<br />
</code></p>
<p><strong>Summary</strong></p>
<p>We setup the following,</p>
<ul>
<li>3 Domains (google.com/msn.com/yahoo.com) for both dns and web</li>
<li>A master FTP account (username: node / password: my??password12)</li>
<li>1 master nameserver (masterdomain.com) which all domains use</li>
</ul>
<li>A domain setup script for adding new domains easily (/root/setup.sh)</li>
<p>If you followed this from start to finish you should now have a fully working server for your MFA sites where you can add new domains easily and manage all the domains from one account.</p>
]]></content:encoded>
										</item>
	</channel>
</rss>
