Monday, 10 December 2012

Upload files in PHP when running plesk

  1. Log into Plesk and enable CGI/FastCGI support. Go to Tools and Settings>Apache Modules> Check fcgid
  2. Enable fcgid for your domain : /usr/local/psa/bin/domain -u example.com -php_handler_type fastcgi -fastcgi true
  3. Log into your server as root or sudoer account via SSH.
     
  4. Make a local copy of the PHP CGI binary program for your domain:
    cp /usr/bin/php5-cgi /var/www/vhosts/example.com/bin/
  5. Change the ownership of the bin directory and your new local copy of PHP:
    chown -R domainuser:psacln /var/www/vhosts/example.com/bin/
  6. Modify or create your local Apache configuration file, vhost.conf:
    vim /var/www/vhosts/example.com/conf/vhost.conf
    Add the following lines to the file: (may need to be created first)
    vhost.conf
    AddHandler fcgid-script .php
    SuexecUserGroup domainuser psacln
    <Directory /var/www/vhosts/example.com/httpdocs> FcgidWrapper /var/www/vhosts/example.com/bin/php5-cgi .php Options +ExecCGI +FollowSymLinks allow from all </Directory>
  7. Enable shared memory for FCGID:  echo "SharememPath /var/run/fcgid_shm" >> /etc/apache2/apache2.conf
  8. Reload your Apache configuration settings:
    /usr/local/psa/admin/bin/httpdmng  --reconfigure-domain example.com
  9. Restart Apache:
    /etc/init.d/apache2 graceful
PHP will now be running as FastCGI as the same user and group that owns your website files.
Adjust your sessions directory:

Since PHP will now be running as the script's user rather than apache, the permissions for the session folder need adjusted to account for this.

chmod 777 /var/lib/php5
Adjust permissions:

If you have already modified permissions, or your site has been running for a while on your server, you may need to correct file ownership and permissions. You can use the following commands to reset permissions and ownership to a "standard" state. You probably don't need to run these commands if you're configuring a new domain or have just installed your CMS.

cd /var/www/vhosts/example.com/httpdocs && \
chown -R domainuser:psacln * &&\
find . -type f -exec chmod 644 {} \; &&\
find . -type d -exec chmod 755 {} \;


You should consider adjusting the number of simultaneous FastCGI processes allowed for each domain and for the server overall, based on the number of domains that you have running FastCGI. The default configuration allows 64 total processes and 8 per domain. Edit your configuration file:
vim /etc/httpd/conf.d/fcgid.conf
Update the following variables, if desired:

fcgid.conf
MaxProcessCount 64
DefaultMaxClassProcessCount 8


You should set the DefaultMaxClassProcessCount to the number of processes you want a single domain to be able to run simultaneously. Multiply that number by the number of domains that are running FastCGI, and use that number for the MaxProcessCount. For example, if you have 4 domains using FastCGI, and you want them to run a maximum of 10 simultaneous processes each, you can set the following values:

fcgid.conf
MaxProcessCount 40
DefaultMaxClassProcessCount 10


Do not set these values arbitrarily high, as this may interfere with your server's memory usage. Alternately, you can pick a server maximum first for the MaxProcessCount, and then divide by the number of your domains to set the DefaultMaxClassProcessCount value.

Sunday, 21 October 2012

MariaDB

Inspired by KP's post, here's how to install MariaDB on Centos.

For those interested, MariaDB is an alternative to MySQL that is (supposedly) 100% compatible with MySQL.

Considering the uncertain future of the MySQL project and the general attitude of Oracle, it's definitely worth a shot to give a try and test it out in your dev/test environment.

First, let's assume you use yum (if you're installing from source, I don't think you really need any help there).

Create a new repo in /etc/yum.repos.d/ (in my example it's for mariadb 5.5 and centos 6 64bits)

cat << EOF > /etc/yum.repos.d/mariadb.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgcheck=1 EOF
import the GPG keys:

rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB

then just install it by running:

yum install MariaDB-Server

Tuesday, 24 July 2012

Why, aunic, why?

com.com.au is apparently an existing domain now (and has been for a while).

That makes DNS troubleshooting that much more interesting (especially when it's 2AM and you forget the trailing dot in your dns queries)

Thursday, 28 July 2011

Sending emails from scripts inside zimbra

If you're using zimbra on a linux system with package dependancy management (so pretty much any linux system nowadays) You find it a bit "quirky" to use the "mail" command or mutt (if you need to use attachments).

First you should install this:

 http://ubuntu.lnix.net/misc/mta-dummy/mta-dummy_1.0_all.deb

then run this command:

update-alternatives --install /usr/sbin/sendmail mta /opt/zimbra/postfix/sbin/sendmail 90

Which should convince your system that, no, you don't need to install postfix to run mutt.

After that, it's as easy as installing mutt or mailx.

Tuesday, 12 July 2011

I like Windows 7

I really do, and was quite quick in doing the switch from XP on my home machine (albeit I do keep a fondness for Mac OS X)

One of its most annoying quirks tho, is that most people keep developing applications with two misconceptions in mind:
- The user is still using windows XP
- The user is a local administrator and UAC has been disabled.

Two different programs, two different problems, one unique reason: Poor design.

An application wouldn't run without admin privileges. The reason was it needed to punch a hole in the firewall, on a unprivileged port, on an already disabled firewall. Good job. Using tools like the Application Compatibility Toolkit is a good start, by forcing the program to run anyway.
A better idea would have been to check whether the port was already open, and if not request permission to open it indefinitely.

Second application was even trickier. This plugin for 3DS max would display no warnings, no pop ups, just plain nothing. The whole issue boiled down to the developer trying to edit a log file in the plugin sub folder. Since windows 7, said folder is actually protected in write access, unless you specifically run a program as administrator. Once again, poor design at its best, when it would have been much easier to call the local variable %TEMP% and write the file there...

Sunday, 5 June 2011

Finder crashing on Mac OS X 10.6

Sometimes you will notice that opening a folder (either locally or on the network) will take a loooooooooooooooooooooooooooooooong time, if not just crash and burn after displaying the rainbow wheel for 15 minutes.

It could either be a corrupted PDF file, or a particularly heavy image file, or just the fact your folder contains 25 000 pictures.

To alleviate this problem, try to go, from the finder, to "View", then, at the bottom "show view options".

Uncheck the option at the bottom "Show icon preview" and click on "use as defaults"

A snappy finder coming right up!