Installing Drupal on Centos5

Here is how to install Drupal on a Centos5 Linux installation

  1. Install Centos5 including web server and mysql
  2. log in as root
  3. Update to latest version with: yum -y update yum ; yum -y update
  4. Install modules with: yum -y install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel
  5. Enable .htaccess: cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.sav
    vi /etc/httpd/conf/httpd.conf
    and in two places change AllowOverride None to All
  6. Start apache with: service httpd start
  7. Run: system-config-securitylevel-tui and enable firewall for ssh and http, plus port 10000 for webmin
  8. Open a browser window pointed to the server to check if apache is running
  9. Create test script: echo "<html><head><title>Test Page</title></head><body><?php phpinfo(); ?></body></html>" > /var/www/html/testphp.php
  10. Make sure php is running by visiting: http://servername/testphp.php
  11. download webmin: wget http://prdownloads.sourceforge.net/webadmin/webmin-1.470-1.noarch.rpm
  12. Install webmin with: rpm -U webmin-1.470-1.noarch.rpm
  13. Check it is working by visiting: http://servername:10000
  14. Install MySQL with: yum -y install php-mysql mod_auth_mysql mysql-server php-gd php-mbstring
  15. Start MySQL: /etc/init.d/mysqld start
  16. Now setup MySQL: mysqladmin -u root password rootsqlpassword
  17. Make sure mysqld and httpd start on boot by checking the boxes: webmin / system / bootup and shutdown
  18. Download your preferred version of Drupal and unarchive it with: tar -zxvf drupal-x.x.tar.gz
  19. Move drupal to web root: mv /nameofdrupalfolder/* /var/www/html
  20. plus .htaccess: mv /nameofdrupalfolder/.h* /var/www/html
  21. Give the installer access to the directory: chmod 777 /var/www/html/sites/default
    mkdir /var/www/html/files
    chmod 777 /var/www/html/files
  22. Create a database (e.g. called drupal) using: webmin / servers / mysql
  23. visit the server's root web page and complete the installation using Drupal
  24. Secure sites access: chmod 775 /var/www/html/sites/default
  25. Well done! You are finished

Saving memory

  • You can save some memory by disabling the following Apache modules by renaming their .conf files in /etc/httpd/conf.d
    manual, perl, proxy_ajp, python, squid, webalizer
  • I saved some more memory by disabling the following services using webmin
    avahi-daemon, gpm, haldaemon, hidd, irqbalance, mdmonitor, netfs, nfslock, pcscd, yumupdatesd

Optional Extras

  • Install subversion yum install subversion
  • Download and install phpmyadmin:
    wget "http://proj.ri.mu/installphpmyadmin.sh"
    bash installphpmyadmin.sh
  • you may wish to disable selinux for httpd
    setsebool -P httpd_disable_trans 1
    service httpd restart
  • for useful notes, see: http://www.howtoforge.com/perfect-server-centos-5.2
  • Install php 5.2 and APC

    cd /etc/yum.repos.d
    wget http://dev.centos.org/centos/5/CentOS-Testing.repo
    
    pecl uninstall apc #in case it was installed
    yum -y --enablerepo=c5-testing update php* 
    service httpd restart
    #
    # to install APC
    #warning: backup your httpd.conf file first, as this may overwrite it
    yum -y install gcc httpd-devel
    yum -y --enablerepo=c5-testing install php-devel php-pear
    pecl -d memory_limit=16M install apc
    echo "extension=apc.so" > /etc/php.d/apc.ini
    service httpd restart
    cp /usr/share/php/apc.php /var/www/html # and visit apc.php to test it is working
    cp /usr/share/pear/apc.php /var/www/html # it may be here instead
    
    • useful link: http://www.agileapproach.com/blog-entry/howto-install-pecl-apc-cache-centos-without-xampp
    • Install apc based on: http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html
      yum install -y php-pear php-devel httpd-devel
      pecl install apc
      echo "extension=apc.so" > /etc/php.d/apc.ini
      service httpd restart
    • To install PHP 5.2, see: http://bluhaloit.wordpress.com/2008/03/13/installing-php-52x-on-redhat-es5-centos-5-etc/