Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

Setting up and configuring Apache Problem

Hi,

I have been attempting to configure my Fedora Core server with Apache, MySQL, PHP, etc. I attempted to use the shell script below to setup and configure the main items for my server and it returned several errors while attempting to decompress the necessary files and it then asked me to generate some keys (I assume for the SSL it was attempting to enable with Apache). I finally aborted the script and it has left three files in my root directory: localhost.key, server.key, and localhost.key.csr. Can anyone help me out and tell me what those files would be for and how I might remove them. Simply attempting to delete them has proved ineffective.

Thanks.
-- Matt

--------------------------------------
Shell Script
--------------------------------------

#!/bin/sh
# Script to build a Fedora based Linux server

# 1. Install Fedora Core 4 with only Development tools installed (use Custom Install)
# 2. Run this script to complete server build, remember to put the latest tar balls/rpms in /usr/local/src first

#******** Software to install, edit to latest versions ************************************
mysql=mysql-standard-5.0.21-linux-i686
set apache = httpd-2.2.2
set apc = APC-3.0.10
set php = php-5.1.3
set webmin = webmin-1.270-1.noarch.rpm
set Net_SSLeay = Net_SSLeay.pm-1.30

##############################################################################
cd /usr/local/src

tar -zxvf $apache.tar.gz
tar -zxvf $apc.tgz
tar -zxvf $php.tar.gz
tar -zxvf $Net_SSLeay.tar.gz
tar -zxvf $mysql.tar.gz

#**** Use Yum to update the server first
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* #fixes GPG key errors for ghostscript fonts
yum install ImageMagick
yum update openssh*
yum update zlib-devel*

# ****************** Install MySQL (binary distro) ******************
groupadd mysql
useradd -g mysql mysql
cd /usr/local
tar -zxvf /usr/local/src/$mysql.tar.gz
ln -s $mysql mysql
cd mysql
scripts/mysql_install_db --user=mysql
chown -R root:mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 0755 /etc/rc.d/init.d/mysqld
chkconfig --levels 2345 --add mysqld # for auto startup

#****************** Apache *********************************************
cd /usr/local/src/$apache

./configure \
--prefix=/usr/local/apache2 \
--enable-so \
--enable-ssl

make
make install

mkdir /usr/local/apache2/conf/ssl.key
mkdir /usr/local/apache2/conf/ssl.crt

cd /usr/local/apache2/conf/ssl.key
openssl genrsa -des3 -rand some_big_file_1:some_big_file_2 -out localhost.key 1024
openssl rsa -in localhost.key -out server.key
openssl req -new -key localhost.key -out localhost.key.csr
openssl x509 -req -days 365 -in localhost.key.csr -signkey localhost.key -out /usr/local/apache2/conf/ssl.crt/server.crt

#*** Create a Simple Apache Startup script in /etc/init.d
echo "#!/bin/sh
# description: apache2
# chkconfig: 2345 99 00

case \"\$1\" in
'start')
/usr/local/apache2/bin/apachectl startssl
touch /var/lock/subsys/httpd
;;
'stop')
/usr/local/apache2/bin/apachectl stop
rm -f /var/lock/subsys/httpd
;;
*)
echo \"Usage: \$0 { start | stop }\"
;;
esac
exit 0" > /etc/init.d/httpd
chkconfig --levels 2345 --add httpd # for auto startup
chmod 0775 /etc/init.d/httpd

# ********************* PHP ***********************************************
cd /usr/local/src/$php
if [ -f config.cache ] ; then
rm config.cache
make clean
fi

./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysql=/usr/local/mysql \
--with-zlib \
--with-zlib-dir \
--with-curl \
--enable-track-vars \
--with-config-file-path=/usr/local/apache2/conf \
--enable-trans-id \
--enable-mbstring \
--enable-sockets \
--with-openssl

make
make install

cp /usr/local/src/$php/php.ini-dist /usr/local/apache2/conf/php.ini
echo "AddType application/x-httpd-php .php" >> /usr/local/apache2/conf/httpd.conf
echo "<?phpinfo()?>" > /usr/local/apache2/htdocs/phpinfo.php

#*********** APC (PHP opcode cache) *************************************
cd /usr/local/src/$apc
phpize
./configure --enable-apc \
--with-apxs=/usr/local/apache2/bin/apxs \
--with-php-config=/usr/local/bin/php-config
make
make install

EXT=$(find /usr/local/apache2/conf/ -name 'php.ini' -exec grep -li 'extension=apc.so' {} \;)

if [ ! $EXT ] ; then
echo "extension=apc.so" >> /usr/local/apache2/conf/php.ini
fi

EXT=$(find /usr/local/apache2/conf/ -name 'php.ini' -exec grep -li 'extension_dir = "/usr/local/lib/php/extensions/"' {} \;)

if [ ! $EXT ] ; then
echo "extension_dir = \"/usr/local/lib/php/extensions/"\" >> /usr/local/apache2/conf/php.ini
fi

if [ ! -f /usr/local/lib/php/extensions/apc.so ] ; then
APC_SO=$( find /usr/local/lib/php/extensions/ -name apc.so )
ln -s $APC_SO /usr/local/lib/php/extensions/apc.so
fi

#********** Net_SSLeay SSL for Webmin *********************
#********* export command fixes bug in perl makefile ******
cd /usr/local/src/$Net_SSLeay
export LANG=en_US
perl Makefile.PL
make install

#*************** Webmin ***********************************
cd /usr/local/src/
rpm -U $webmin

echo "************************************"
echo "************************************"
echo "Script has finished"
echo "Stop iptables \"/etc/init.d/iptables stop\""
echo "Open port 10000 & 443 in Webmin->Networking->Linux Firewall"
echo "Go into Webmin->System->Bootup and disable all non esential services"
echo "You should reboot server now, then check PHP with http://localhost/phpinfo.php"

0
aaron_karp
Asked:
aaron_karp
  • 2
1 Solution
 
m1tk4Commented:
those files are self-generated keys, one for the host, one for the server, and the CSR (certificate signing request) - used to sign your server certificate with host's. They are created during these steps:

openssl genrsa -des3 -rand some_big_file_1:some_big_file_2 -out localhost.key 1024
openssl rsa -in localhost.key -out server.key
openssl req -new -key localhost.key -out localhost.key.csr
openssl x509 -req -days 365 -in localhost.key.csr -signkey localhost.key -out /usr/local/apache2/conf/ssl.crt/server.crt

Most likely you can just

chmod 666 *.crt *.csr

them and then delete.
0
 
aaron_karpAuthor Commented:
The files had a ? at the end and when I go to delete them it asks:

rm: remove regular file 'server.key\r'?

What is a regular file and should I just return y?

Thanks.
-- Matt
0
 
m1tk4Commented:
Oh.

Most likely, the script you run was copied from Windows machine and has windows linebreaks (\r\n) instead of Unix (\n). In effect, this appends \r character to the end of every line in your script, so

openssl rsa -in localhost.key -out server.key

really becomes

openssl rsa -in localhost.key -out server.key\r

that's why it created these strange files and that's why it failed, most likely. You can convert the linebreaks to unix using dos2unix command. Delete the files and try again.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now