Recently, we began migrating some of our clients to a new dedicated-virtual server hosted by MediaTemple. Unlike most other servers and the grid-server (GS) service also provided by MediaTemple, the dedicated-virtual server doesn’t allow much file write access by default.
Who This Will Help
- Developers unable to programmatically “write” to their server or child directories
- Developers using WordPress who find that they can’t upload images or files through WordPress
- Developers using WordPress who find that they can’t adjust their permalinks automatically
What Is SSH? Why Must I Use It?
Secure Shell (SSH) is a network protocol for secure data communication and command execution for unsecure networks. Since MediaTemple’s dedicated-virtual servers are technically unsecure in the traditional sense, MediaTemple removes the permissions that allow programmers to alter server-level files through standard FTP protocols.
In order for us to allow our programs to automatically create and alter files, we must override the default settings and grant the appropriate permissions.
How Do I SSH In?
While SSH is handled through command-line, it cannot be done through traditional means. It requires an assist-program that allows for specific SSH connections. I recommend using PuTTy. You can download PuTTy here.
Once you’ve downloaded and installed PuTTy, run the program and you’ll be prompted with this screen:
From here, enter your hostname and click the “Open” button. You will now be prompted with a command-line screen asking for your username. Enter your “root” or whatever your root username is and press enter. When it prompts for password, enter the root user password. If the program closes, then you entered incorrect credentials. If not, you will see something similar to this:
Now we need to adjust some settings in our server before we can make the actual permission change. Enter the following:
To prevent any accidental changes from crashing your server, make a backup of your group file by typing:
cp /etc/group /etc/group.BAK
Now we can really begin. Use the “vi” protocol to open your group file to change overall server permissions:
vi /etc/group
This should load the contents of the folder into the command-line. Use your arrow keys and find these lines:
apache:x:48:apache
psacln:x:2524:
and change them to read:
apache:x:48:apache,domainuser
psacln:x:2524:apache,psaadm,psaftp
‘domainuser’ is the primary username you use to FTP into your site.
There are special key-functions you must press to alter data. The main keys you will use are:
- To delete a single character at cursor: x
- Insert text before the cursor: i
- Insert text after the cursor: a
- Insert text at start of line: I
- Insert text at end of line: A
- To exit: ESC :q
- Exit (and save changes): :wq
Now we have to write group permissions for the folders that you would like to be writable. Enter the following:
chmod -R g+w /var/www/vhosts/example.com/httpdocs/wp-content
chmod g+w /var/www/vhosts/example.com/httpdocs/.htaccess
‘example.com’ is your domain.
To Apply The Changes, Restart Apache
You can do this by entering the following in the PuTTy command-line:
/etc/init.d/httpd restart
Your problems should be solved. To test if it worked, try to upload some type of media to the server via a program like WordPress. You can also try modifying your permalink structure or trying some custom PHP code that interacts with the server’s directory system.
If you run into anymore problems, be sure to let me know in the comment section. I will be happy to help you out.