Showing posts with label LAMP. Show all posts
Showing posts with label LAMP. Show all posts

Saturday, April 2, 2011

Install an FTP server on Amazon EC2 LAMP

I've recently created my first server on Amazon EC2 (more on that soon) and I needed to move some stuff over. Here's how to setup a secure FTP server and configure it for your LAMP.

First, install the ftp software:
   apt-get install vsftpd

Next, edit /etc/vsftpd.conf and uncomment or change the following:
   listen=YES
   anonymous_enable=NO
   local_enable=YES
   write_enable=YES
   connect_from_port_20=YES
   guest_enable=NO

Add following lines at the end of file:
   pasv_enable=YES
   pasv_min_port=1044
   pasv_max_port=1048

Next, you'll want to create a local user and a home directory where files will be saved. This keeps your www directory safe from intrusion. Upon connecting over FTP you'll be able to see and read from anywhere on the system, but only upload to one directory.
   adduser ftp_user
   passwd ftp_user
   mkdir /home/ftp_user
   chown ftp_user:users /home/ftp_user

You might only need the first command as your distro will take care of all the rest by prompting you.

Now you need to restart the ftp server to load the new configuration:
   /etc/init.d/vsftpd restart

If you are wondering why I chose to restrict the passive ports to 1044 - 1048, this is because Amazon blocks all ports unless specifically allowed by the security group. You will need to open those ports in your Amazon Console. Click Security Groups, chose your group, click the Inbound tab and create a new Custom TCP rule. Specify ports 1044-1048, click Add Rule and Apply Rule Changes.

Presto! You can now connect to your LAMP over FTP using ftp_user. Your files will be uploaded to /home/ftpuser

Wednesday, March 9, 2011

How to install cURL

If you are making your first shopping cart, crawler or simply need cURL to make existing code work, here's how to get it.

First things first, check to see if cURL is already running. Create the following PHP page:
<?php
   phpinfo();
?>
Visit that page and search for "curl". If nothing is found, you don't have cURL. A proper installation should have a reference under "Additional .ini files parsed" as well as a section called "curl" with all the details.

There are several ways to install/enable cURL, depending on your setup. Here are the two most common:

LAMP (as root or using sudo)
apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
XAMPP (edit xampp\apache\bin\php.ini and uncomment or add this line)
extension=php_curl.dll
In either case you'll need to restart Apache to load cURL after the installation.

To verify the installation, go to the PHP page you created and search for "curl".

Friday, March 4, 2011

Manage Your Code Deployment: Subversion To Web Server In One Click

Here's the simplest way to push a folder out of your repository onto your web server for testing.

<?php
$result = array();
$command  = 'svn export ';
$command .= 'https://your_server/svn/project /path/to/www ';
$command .= '--username USER --password PASS --force ';
$command .= '--non-interactive --trust-server-cert';
exec($command, $result);
print_r($result);
?>

- Host name HAS to match certificate (where I have "your_server")
- check .htaccess files, mod rewrite, ensure permissions are 755 and www-data is owner
- Version # can be forced with -r switch (svn -r 5 export ...)