[SOLVED] Hosting multiple development domains locally?

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

[SOLVED] Hosting multiple development domains locally?

Postby mzurhorst » Dec 21st, '14, 02:10

Hi there,

A while ago, I started to publish a website with WordPress.
And recently, I made the natural next step and tried to tweak modules/plugins and play with MySQL/PHP etc.

I had a hard time setting up a local webserver for the development. Whilst the service was running, it is a nightmare with the permissions on the file system level.
(files owned by root, by apache or by my local user; simple errors lead to PHP misbehavior)

What I like to achieve is this:
1) define 2-3 different artificial domains (like mzurhorst-devel1.de, mzurhorst-devel2.de), which shall be delivered from the local apache
(I want to simulate the external webserver and I want to get rid of the "localhost" in the URL because I also plan to work with the rewrite rules etc)
2) I like to have for each of these artificial domains a local directory which is owned by my regular user and where I can edit the files without a hassle


Can you please point me to the right key words that I need to implement?
-- For the domain name part, I assume that I need to add these ones to /etc/hosts and point them to 127.0.0.1.
Is the reminder "only" Apache2 configuration, or is there even another service required?


What is the recommended strategy for the file/folder permissions? -- It seems that Apache does not like to process files that are owned by my local user.
I am used to run chown over the entire folder structure, but this is for sure not the smartest approach?
I also tried to add my user to the group of apache and added the apache user to my own group, but this was not sufficient.

In case this is a security mechanism, is there a possiblity to turn this off for development on the localhost?


Thanks a lot in advance!

Kind regards,
Marcus
Last edited by mzurhorst on Dec 24th, '14, 14:48, edited 1 time in total.
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: Hosting multiple development domains locally?

Postby Symbioxy » Dec 21st, '14, 14:54

Hi,

As I did not find a wiki page with information on how to get started with Web development with Mageia, I initiated this page, trying to give you a "simple" answer on how to set up local development hosts.
https://wiki.mageia.org/en/How_to_develop_a_Website

I have tested all this with a VM, starting from a fresh installation.

Please note that although this is working, it has not been reviewed yet, and I am pretty sure this is not the best way to achieve this (security).
Also, this current method assumes you are only using the web server for local hosts only and not for web sites to be accessed from outside.
So by changing the document root path to your home as indicated, you may break things... but you may find some clues on how to set up both local and external sites this way.

I'll keep trying to document how to best include your external sites in this home folder. I guess it would be much better to set up the right groups and users to manage this.

Looking forward for your feedback ;)
Symbioxy
 
Posts: 26
Joined: May 21st, '12, 17:41
Location: Grenoble, France

Re: Hosting multiple development domains locally?

Postby doktor5000 » Dec 21st, '14, 15:00

Symbioxy wrote:As I did not find a wiki page with information on how to get started with Web development with Mageia, I initiated this page, trying to give you a "simple" answer on how to set up local development hosts.
https://wiki.mageia.org/en/How_to_develop_a_Website.

That is nice to have and I appreciate your efforts, but not all such topics are specific to Mageia. There are _lots_ of pages that explain how to set up lamp / apache and how to have multiple virtual domains.
Does it really make sense to duplicate all those efforts and write one specifically for Mageia?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18020
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Hosting multiple development domains locally?

Postby Symbioxy » Dec 21st, '14, 15:31

Hi doktor5000,
I actually wondered about the same thing while typing. Indeed, I don't intend to duplicate all information.

But there are many things in Mageia to help users getting started rapidly with a web server: meta-package, MCC to create hosts, MCC to start/stop the server, etc.
So I think we share that the propose of such a page is to guide any user to get started and highlight what Mageia brings.
Then we could complete the page with links to other documentation as you suggest for what is too detailed or not specific to any distribution.

There is also value in this for QA or ideas for new features: I tried first this procedure on a fresh and updated Cauldron VM but got 2 to 3 bugs on my way and I actually did not manage to get this to work (I need to report them). I did not meet the same problems with a Mageia 4 VM which worked fine on the first try.
Symbioxy
 
Posts: 26
Joined: May 21st, '12, 17:41
Location: Grenoble, France

Re: Hosting multiple development domains locally?

Postby filip » Dec 21st, '14, 21:58

Symbioxy wrote:As I did not find a wiki page with information on how to get started with Web development with Mageia, I initiated this page, trying to give you a "simple" answer on how to set up local development hosts.
https://wiki.mageia.org/en/How_to_develop_a_Website
Impressive!

From your suggestion for httpd.conf file I only use "Relax access" part and not the first line and those lines on the end:
Code: Select all
<Directory "/path/to/dev dir">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>


For several custom domain names I use apropriate ServerName in each VirtualHost section:
Code: Select all
<VirtualHost *:80>
    DocumentRoot "/path/to/dev dir for/site_one" # remember that all paths in apache config files are always without last slash
    ServerName site_one
</VirtualHost>


And in /etc/hosts I list those ServerName domains for easy access:
Code: Select all
#my local development websites
127.0.0.1 site_one
127.0.0.1 site_two
filip
 
Posts: 478
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

Re: Hosting multiple development domains locally?

Postby mzurhorst » Dec 22nd, '14, 15:20

Hi

thank you for the great advice. I made good progress and have now three artifical doimans locally which run different software stacks in parallel. Really great.
One more word regarding the permissions:
-- I think the "chmod -R 777" is not enough. When you e.g. download a plugin from within WordPress, its files are owned by the server again.
Consequently, have changed the httpd.conf such that User and Group are used for my local user "marcus".
(I know this is a security nightmare, but the development is a one-man-show locally on my laptop)

To recover a bit, I also changed the Listen directive such that it only accepts requests from the local machine: Listen 127.0.0.1:80
Having all that done, I think I am ready to go now.

Thanks a lot!

Regards,
Marcus
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: Hosting multiple development domains locally?

Postby filip » Dec 23rd, '14, 09:35

mzurhorst wrote:One more word regarding the permissions:
-- I think the "chmod -R 777" is not enough. When you e.g. download a plugin from within WordPress, its files are owned by the server again.
Consequently, have changed the httpd.conf such that User and Group are used for my local user "marcus".
I prefer adding myself to the group of the server. But I'm not exactly a security expert so please search more for good answer.

mzurhorst wrote:Having all that done, I think I am ready to go now.
Nice. You're welcome.

Can you prefix the topic with [SOLVED].
You can do so, by editing the subject in the first message in this topic.
Write [SOLVED] to the left of subject.
filip
 
Posts: 478
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

Re: Hosting multiple development domains locally?

Postby mzurhorst » Dec 24th, '14, 14:56

filip wrote:
mzurhorst wrote:One more word regarding the permissions:
-- I think the "chmod -R 777" is not enough. When you e.g. download a plugin from within WordPress, its files are owned by the server again.
Consequently, have changed the httpd.conf such that User and Group are used for my local user "marcus".
I prefer adding myself to the group of the server. But I'm not exactly a security expert so please search more for good answer.


Question: When I add myself to the group of the apache server, how do I now make sure that newly created files are automatically writable for the entire group?
I think this is not necessarily the case, which would once more force me to run the chmod command eventually.
(side note: this is maybe also an artificial limitation because I am not editing each and every file of my WP plugins...)


filip wrote:Can you prefix the topic with [SOLVED].
You can do so, by editing the subject in the first message in this topic.
Write [SOLVED] to the left of subject.

I flagged it solved, but I am still curious to get the question above answered.


Thanks to all of you.
Merry Christmas and a Happy New Year!

Marcus
mzurhorst
 
Posts: 21
Joined: Jun 3rd, '11, 20:25
Location: Germany

Re: [SOLVED] Hosting multiple development domains locally?

Postby madeye » Dec 24th, '14, 17:07

You could use ACLs to set the permissions on the folder you are using for the apache files. I am doing that on my LAN server, that I use for developement of web applications.
Code: Select all
setfacl -Rm u:USERNAME:rwX DIRNAME

would set the permissions for USERNAME to read, write, execute on the folder DIRNAME and subfolders (and files). The filesystem used must of course support ACL, else it will not work. For EXT4 it can be activated with the fstab mount option acl.

Code: Select all
getfacl DIRNAME

can be used to view the current permissions. Here is mine:
Code: Select all
[root@azura datafiles]# getfacl http/
# file: http/
# owner: http
# group: http
user::rwx
group::rwx
other::r-x
default:user::rwx
default:user:rene:rwx
default:group::rwx
default:mask::rwx
default:other::r-x

For more information on setfacl and getfacl check the man pages.
- Madeye

When I supply commands in an answer, please make sure you understand them before you run them! Use google or man to check!
User avatar
madeye
 
Posts: 110
Joined: Jul 23rd, '11, 12:36
Location: Aabenraa, Denmark


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest