Category: "LAMP"

Shared Hosting - In a pinch permission updates

After a long day working on an upgrade, I realized I needed to adjust the permissions of directories and files that were owned by nobody.nobody.

I was about to send a ticket to the hosting company, when I realized you can use PHP to change the permissions, and invoke the script through the browser.

It wasn’t graceful, or efficient, but, it did let me change permissions and continue.

The real lesson is to wait until the last minute to ask the hosting company to change ownership of the files. I hurried, because the server was hacked when I logged in.

Apache configuration for a simple development server

I’m setting up a CentOS 5.4 laptop to build a new site for St. Kathryn’s Church in Hudson, NH (http://stkathryns.org).

I want to use the server to run other sites as well, so setting up virtual hosts was one of the first steps.

I like to use a dedicated /etc/httpd/conf.d/vhost.conf file for settings that affect all sites on the server.

/etc/httpd/conf.d/vhost.conf

ServerName 127.0.0.1
NameVirtualHost *:80

/etc/httpd/conf.d/localhost.conf has the localhost settings.

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName 127.0.0.1
ServerAlias localhost
</VirtualHost>

/etc/httpd/conf.d/stkathryns.conf has the settings for St. Kathryn’s new site.

<VirtualHost *:80>
DocumentRoot /var/www/html/stk
ServerName stkathryns.org
ServerAlias stk
</VirtualHost>

The final adjustment is to add the domain name for stkathryns.org into the /etc/hosts file, so I can develop locally, with the correct domain name.

127.0.0.1 localhost.localdomain localhost stkathryns.org stk

How to kill processes out of a ps list

ps eaux | grep  'uniquestring' | sed "s/^root *\([0-9]*\).*$/\1/" | xargs kill -9

SugarCRM Extension/Modules/Integration Notes

  • Under custom/Extension/modules/[module to extend/modify]/Ext/Menus add a [new module].ext.php file with the additional menu options.
  • If you want to change a menu option, loop through the menu array and replace that option with the new one, in the menu.ext.php file.
  • Be sure to rebuild/repair the module before testing changes.
  • Spend a good amount of time looking at the Sugar code as you’re working. It’s very powerful, and the less code you write, the better the solution will be.
  • If you’re just modifying existing functionality, copy as much code as possible, the update it.
  • Understand PHP classes and extensions.
  • Never modify the distributed code.

Rebuilding PHP Under CentOS5

  1. Configure firewall to allow httpd requests: system-config-securitylevel

  2. Get PHP development RPM: http://rpm.pbone.net/index.php3/stat/4/idpl/8077900/com/php-devel-5.1.6-20.el5.i386.rpm.html

  3. Get PHP source RPM: ftp://ftp.pbone.net/mirror/ftp.centos.org/5.3/os/SRPMS/php-5.1.6-23.el5.src.rpm

  4. Use yum to handle RPM dependencies. yum install php-5.1.6-23.el5.src.rpm
  5. Update SPECS/php.spec and enable/disable options as necessary.
  6. rpmbuild -bb –target=i386 SPECS/php.spec - It’s good to specify the target, since otherwise, the RPM build may take a very long time.
  7. Force the installation of the updated RPMs. I did an ls of the RPMS directory and forced them all.
    rpm -i –force php-5.1.6-23.i386.rpm php-bcmath-5.1.6-23.i386.rpm php-cli-5.1.6-23.i386.rpm php-common-5.1.6-23.i386.rpm php-dba-5.1.6-23.i38
    6.rpm php-debuginfo-5.1.6-23.i386.rpm php-devel-5.1.6-23.i386.rpm php-gd-5.1.6-23.i386.rpm php-imap-5.1.6-23.i386.rpm php-ldap-5.1.6-23.i386.
    rpm php-mbstring-5.1.6-23.i386.rpm php-mysql-5.1.6-23.i386.rpm php-ncurses-5.1.6-23.i386.rpm php-odbc-5.1.6-23.i386.rpm php-pdo-5.1.6-23.i386
    .rpm php-pgsql-5.1.6-23.i386.rpm php-snmp-5.1.6-23.i386.rpm php-soap-5.1.6-23.i386.rpm php-xml-5.1.6-23.i386.rpm php-xmlrpc-5.1.6-23.i386.rpm