Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having a nightmare setting up a decent environment for developing Wordpress on a local machine.

  1. I'm constantly manually tweaking file permissions every time I add a plugin.
  2. I can't install themes or plugins through the Wordpress interface.
  3. I have to keep sudo-ing every time I need to modify the contents of the site folder I'm working on (theme files, etc.)
  4. I've tried using XAMPP, which comes with a built-in FTP setup, but then all the files uploaded via the web interface are given the permissions of user nobody.

What are some best-practices for setting up a decent LAMP environment that simulates -- at least partially -- the convenience of a hosted environment?

I guess it might start with modifying the apache configuration to point to a develoment folder in my ~/ folder, but I've had terrible problems with permissions there.

For the record, I'm running Xubuntu 9.10 on one system, and Ubuntu-netbook 9.10 on the other.

Any advice or guide I can refer to for this?

[edit] I'm not entirely opposed to using a VM (as seen here, but only as a last resort; the netbook probably isn't powerful enough, and I generally refer to work on a local copy of things. [/edit]

share|improve this question
    
SO or serverfault.com ? –  ukanth Jan 15 '10 at 13:37
    
No. It's not a programming question, and I'm not setting up a network of PCs that I don't own. –  Jono Jan 15 '10 at 21:26
    
serverfault would be best - this is a sysadmin question really. –  gbjbaanb Jan 22 '10 at 22:45
    
Intuitively, it's a sysadmin question. But in reality, it's a developer question, but not a programming question. If you read the definitions on serverfault, you'll see it's not appropriate. –  Jono Jan 23 '10 at 18:21

4 Answers 4

Looks like your apache (and hence XAMPP) is running as user 'nobody', whereas your Wordpress install is owned by your login userid. I'm guessing its a non-internet-accessible development server, in which case easiest thing is to change the run-as user in apache's httpd.conf to your login userid.

Better practice would be to install suPHP or suexec, but setting them up is a bit harder than the above.

share|improve this answer
    
User nobody is the default for XAMPP's ftp component, that much I know. The whole point of XAMPP was that I just stick in and it works, but that's not the case. But anyway, I'm only using XAMPP on the netbook. –  Jono Jan 15 '10 at 12:46
    
On the other hand, the run-as for apache sounds important. Maybe that will solve my latest problem. –  Jono Jan 15 '10 at 12:50
    
Have you also considered looking at mod_userdir? –  Remy Jan 17 '10 at 17:20

For starters, it's not a good idea to stick everything under /var/www and point the browser to http://localhost/somesite/. For one, it complicates things when you move to a new server later on. It's best to create a virtual host on your computer, by creating a new file called somesite (your site name) under

/etc/apache2/conf/sites-available/

Create a VirtualHost for the full URL. This way, when you migrate a wordpress database, you don't have to edit the site address. In our example, it would be a virtual host for www.somesite.com.

Here's an example of such a file:

<VirtualHost somesite:80>
ServerAdmin username@localhost
ServerName somesite
DocumentRoot /var/www/somesite
<Directory />
    AllowOverride All
    Options FollowSymLinks
</Directory>

ErrorLog /var/log/apache2/error.log

LogLevel debug

</VirtualHost>

Then execute the following commands:

$ sudo a2ensite somesite
$ sudo /etc/init.d/apache2 reload

You'll also need to update your /etc/hosts file by changing the first line from

127.0.0.1    localhost

to

127.0.0.1    localhost, somesite, www.somesite.com

but then I run into a problem:

I'd like to place the files on my home folder, where I have full permissions, instead of sticking it under /var/www. This way I neither have to sudo every time I want to do something, nor do I risk messing up the system when I do. I can also work with SVN more easily.

But if I create such a configuration, when I point the browser to http://www.somesite.com/ I end up getting a 403 error, with no permissions.

Even when I set the entire somesite folder to permissions 777 I still get this error. What else should I be doing?

share|improve this answer

I would use a VM and use the same distribution that the target host will use. This could eliminate a lot of frustrations later. As far as the VM and the netbook goes, I thought the whole point of the "NETbook" was that local storage was only a cache and the bulk of the work was to be dome remotely in the "cloud?"

You could find an old beater desktop to setup as a temporary host and develop on that. If you make your site work there, then moving it to a host will only improve performance, and if you are using shared hosting (most people do) then the results from the old machine will more closely match what you can expect from your hosting service anyways.

share|improve this answer

It sounds like you're unpacking the addins as yourself, and then having to chmod them to the user apache is running as. This is normal, don't fret about it.

The point of it is that you're running apache as a low-privilege user that only has permissions for some things, like access only its files and none of the ones in, say, your home directory ('cos you'd be annoyed if Sam Hacker could download your private files). Whatever directory you're running your sites under, needs to be readable (and writeable in some cases) by the Apache user.

This will allow you to install plugins inside Wordpress - as it (ie Apache) will have write access to the directories it needs. Your FTP user will be set correctly, as nobody is the use rapache runs as on some distros.

Now, to make things slightly easier for yourself, add your user to the wheel group so you can su, perform a load of commands, then logout back to your normal user.

share|improve this answer
    
Hmm. So I should assign the ownership of all the files in the XAMPP directory to "nobody"? –  Jono Jan 23 '10 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.