Installing Drupal on Centos5

Please note that more up-to-date instructions are available here:
http://drup.org/installing-drupal-rimuhostingcom

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 system-config-securitylevel-tui
    Note that this is called system-confi-firewall in CentOS 6
  5. Enable .htaccess: cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.original
    vi /etc/httpd/conf/httpd.conf
    and in two places change AllowOverride None to All (may not be needed in CentOS 6
  6. Uncomment NameVirtualHost *:80
  7. Start apache with: service httpd start
  8. Run: system-config-securitylevel-tui and enable firewall for ssh and http, plus port 10000 for webmin
  9. Open a browser window pointed to the server to check if apache is running
  10. Create default page: echo "<html><head><title>Name of Server</title></head><body><h1>Name of Server</h1></body></html>" > /var/www/html/index.html
  11. Make sure server is running by visiting: http://servername/
  12. Create test script: echo "<html><head><title>Test Page</title></head><body><?php phpinfo(); ?></body></html>" > /var/www/html/testphp.php
  13. Make sure php is running by visiting: http://servername/testphp.php
  14. download and install webmin:
    WMVER=1.630-1
    wget http://prdownloads.sourceforge.net/webadmin/webmin-$WMVER.noarch.rpm
    rpm -U webmin-$WMVER.noarch.rpm
    system-config-firewall #to open port 10000
    
  15. Check it is working by visiting: http://servername:10000
  16. Use webmin to create a virtual server at /var/www/html with no server name. (This will be the default and must come first)
  17. Install MySQL with: yum -y install php-mysql mod_auth_mysql mysql-server php-gd php-mbstring
  18. Start MySQL: /etc/init.d/mysqld start
  19. Now setup MySQL: mysqladmin -u root password rootsqlpassword
  20. Make sure mysqld and httpd start on boot by checking the boxes: webmin / system / bootup and shutdown
  21. Download and install Drupal following the instructions here: http://drup.org/acquia-drupal-svn
  22. 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/
    As an alternative to installing php 5.2, it is possible to keep 5.1.6 and still install json and apc: http://maisonbisson.com/blog/post/12137/json-rhel-centos-php-516/ http://maisonbisson.com/blog/post/12589/installing-php-apc-on-rhel-centos/

    CentOS 6

    Command line config of ports by installing system-config-firewall

    Then configure services with ntsysv