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.
Awesome write up you have here. We always like seeing customers taking server education into their own hands. If you find any other cool tips/tricks in the future that we don’t provide in our (mt) KnolwedgeBase, feel free to add to our (mt) Wiki http://wiki.mediatemple.net/w/Welcome. Hope everything is going well so far, and feel free to catch us on Twitter or the phones if you have any questions.
A better fix for this is probably to just use suPHP or FastCGI. You can enable FastCGI in Plesk in the domain controls. Using either of these methods makes PHP run as your domain’s administrative user, so files don’t get written as ‘apache’, but as your user. It’s cleaner, and you don’t have to worry about adding group write (g+w) to all your files.
http://kb.mediatemple.net/questions/1890/#dv4
Thank you for your contribution to this article. I will explore the options that you just laid out, and if they’re fit, I will add them to the article.
If you would like to provide me with a link so that I can attribute your addition with a backlink, I would be more than happy to do so.
@d6fc00f49bdc794a701ee6f1fb8020da:disqus Matt, thank you for taking the time to stop by and comment. I would be more than happy to contribute to MediaTemple’s knowledgebase. Lord knows I’ve been recommending them to clients for years — the least I could do is add to the knowledgebase I’ve referenced for so long.
Finally, a quick and easy solution to this age-old problem. Thanks so much for posting! Worked like a charm.
I’m glad that we could help, Brandon!
My business partners were needing NY DTF ST-330 a few days ago and saw a document management site that has a huge forms library . If you need NY DTF ST-330 too , here’s
http://goo.gl/qUavCw