Page: 1, 2, 3  Next

Need simple tut for Virtual Hosts, sites enabled, etc.
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
I have read through this forum more than once and found some really good info.
However, I still need some simple instructions on how to set up the LAMP server for local development.
I installed the LAMP stack via smxi and everything is working.
Until now I have created folders inside my www to access the downloaded CMS and it worked.
For example, to work on Drupal I would do localhost/drupaltest/ and continue from there.
Now I need to take my development one step further, because I need to enable debugging, so I need to call my local sites by simply typing drupaltest.
I also need to enter a path to PHP for error reporting to work.
I know this can be done by creating a virtual host for each one and making some entries in sites-available and sites-enabled.
I have not found simple step-by step instructions for this, so please provide, or if you know of some good tut, that would be welcome too.
By the way, I am using Wheezy so the LAMP stack is Debian, if you need more info on my setup, just ask.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
I'm unclear on these questions. To access your site by typing in drupaltest (but why so verbose, I like initials, like: dp)

You set the name of the site in the sites_available part, and in /etc/hosts, you create the entry:

127.0.0.1 dp

you can have lots of entries on that line, I tend to stick to about 10 per line, like so:

127.0.0.1 localhost xy dp xrx abc

save it, and that's that.

You enable php error reporting globally in php.ini

/etc/php5/php.ini

error_reporting = E_ALL & ~E_NOTICE

display_errors = On

and so on, you can log errors etc.

It's very wise to get familiar with php.ini so you know what all the defaults are and what needs to be changed.

You can usually change these on a per script basis within php, or with htaccess in some cases, but generally it's best to set them in php.ini for global stuff.

In general, things like register_globals = On are ok locally as long as you turn them off in a per site basis, to make sure your software stuff works with globals off. Globals on is a huge security hole for live sites, and some software won't even let you install it if it detected globals are on.

It seems to me that you are approaching this stuff backwards, learning later what you should be learning first. I suggest a quality print book like Programming PHP by Rasmus Lerdorf, the php main author.

:: Code ::
## drupal test: db ##
<VirtualHost 127.0.0.1:80>
   ServerName dp
   ServerAdmin webmaster@dummy-host.example.com
   DocumentRoot "/var/www/dp/site"
   <Directory "/var/www/dp/site">
      AllowOverride None
   </Directory>
   php_value include_path ".:/var/www/dp/includes"
   DirectoryIndex index.php index.html index.htm
</VirtualHost>


Note here, I'm making a container for the site and the includes directories, that way the includes go under document root, ie, they are not web accessible. Basic security, one less thing that is directly exposed to hackers.

Also note this: php_value include_path

that sets a parameter per site that is set in php.ini, but since each site should have different things, we use the syntax for php_value setting in the apache2 config file instead.

in /etc/apache2/ports.conf

If you don't have apache2 listening to ports, it won't respond. This lets you do local testing, and lan testing.

:: Code ::
NameVirtualHost 127.0.0.1:80
Listen 80

# sample for external access over LAN to test real web serving
NameVirtualHost 192.168.10.35:7599
Listen 7599

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>


Because debugging apache is hard, do not change many things then restart it, change one thing, restart, test, then change the next.

Same for creating htaccess / apache conf mod writes and ssl things.
Back to top
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
Thanks techadmin for answer.
I try not to be a pest, I had set that value in php.ini but no errors were displaying in browser so I was wondering what the heck was going on.
Those values are still there, and yes I have read that file several times, lots of comments and very explicit.
Regarding Rasmus, just for lolz:
forum.zenmagick.org/viewtopic.php?f=18&t=174
I haven't been active with ZenMagick for a very long time, no issues with the developer, a great guy.
I take Rasmus' advice seriously: you learn by doing, and yes will get to the book when I have time, but have some urgent matters to publish online.
Regarding the security issue with the includes path, I was aware of that too, it is in another post in this same forum.
Have several questions:
1) what about the a2ensite command? I think that is used to enable a site, I don't know how to use the sites-enabled directory, so far we have dealt with sites-available.
2) you created a document root "/var/www/dp/site"
Does this mean that to access the index page I have to type something like localhost/dp/site/?
I assume that typing localhost/dp/ would not be enough, but that is what I was doing so far, and it worked.
Not that I want to continue on that path, just getting this clear before I test.
Please understand that I come from XAMP, still a newbie in the real server world.
Will ask more questions, please bear with me.
PS. Working on those Drupal ready-made solutions, but I still have to know LAMP thoroughly, there is no magic solution.
Back to top
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
www.debian-administration.org/articles/207
This article is very good for this topic.
One question, author states for sites-available:
A list of configuration files - one per site. A blank install will contain the file default.
This seems to run contrary to putting several sites on same line.
Will work the same, right?
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
You're confusing things, when I said different sites on one line, I was referring to /etc/hosts

If you haven't gotten to that point yet you need to get that done, that was step 1.

You can make as many sites as you want in a single sites-available, when you symbolic link to it all will be enabled, which is generally what you want on a dev server.

I do them by client, or whatever, not by site, makes no difference to apache.

Debian has gotten somewhat obsessed with creating tiny subfiles instead of single larger files, I don't like that obsession myself, it's a pain, appropriate in rare places, but generally makes things harder to no actual benefit to you.

That's all you're doing by the way to enable it, creating a symbolic link to the enabled file in sites-enabled.
Back to top
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
Techadmin, thanks for detailed answer.
Since you adviced me to dump all derivatives and go straight Debian testing for a rolling distro, I love it so much I don't mind their tiny obsessions, I've seen worse, you know what I am talking about.
I'll give this topic a rest for a while, without calling it closed.
I'll do some testing and mainly check on Drupal's instructions (I have installed it before), since this is my main interest now.
I don't want to burden you with questions that are better dealt with elsewhere.
c u l8r
Back to top
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
:: Code ::
root@papimalo:/# service apache2 reload
[....] Reloading web server config: apache2[Tue Jun 12 10:29:18 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
. ok

This is what I am getting upon reload, however:
I did create a virtual host in sites-available, here is:
:: Code ::

#
# zctest (/etc/apache2/sites-available/zctest)
#

<VirtualHost *:80>
        ServerName zctest
   ServerAdmin webmaster@zctest
   ServerAlias zctest

   DocumentRoot /var/www/zctest
   <Directory />
      Options FollowSymLinks
      AllowOverride None
   </Directory>
   <Directory /var/www/zctest>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride all
      Order allow,deny
      allow from all
   </Directory>

   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
   <Directory "/usr/lib/cgi-bin">
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
   </Directory>

   ErrorLog ${APACHE_LOG_DIR}/error.log

   # Possible values include: debug, info, notice, warn, error, crit,
   # alert, emerg.
   LogLevel warn

   CustomLog ${APACHE_LOG_DIR}/access.log combined

   php_value include_path ".:/var/www/zctest/includes"
   DirectoryIndex index.php

</VirtualHost>


I did run the "a2ensite zctest" command and the symlink is in sites-enabled

There is a virtual.conf file in /etc/apache2.conf.d
Here is:
:: Code ::

#
#  We're running multiple virtual hosts.
#
NameVirtualHost *:80


Finally, this is my /etc/hosts:
:: Code ::

127.0.0.1   localhost
127.0.1.1   papimalo.POMPANO   papimalo
127.0.0.1   zctest

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


What am I missing?
Back to top
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
I am making some progress.
Deleted virtual.conf file.
apache2 reloads OK, no warnings.
Replaced zctest in sites-available with following, pretty much like your example:
:: Code ::

#
# zctest (/etc/apache2/sites-available/zctest)
#

<VirtualHost 127.0.0.1:80>
        ServerName zctest
   ServerAdmin webmaster@zctest
   ServerAlias zctest

   DocumentRoot /var/www/zctest
   <Directory "/var/www/zctest">
   AllowOverride None
   </Directory>

   php_value include_path ".:/var/www/zctest/includes"
   DirectoryIndex index.php

</VirtualHost>

Now website loads from the alias.
Problem is it does not load CSS, maybe script path is missing, but there is no cgi-bin dir in that website.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4128
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
if css is not loading it's because you failed to properly set css file paths.

All paths should be from root, that is.

/css/mycssfile.css

sample:
:: Code ::
<link type="text/css" rel="stylesheet" media="screen" href="/modules/node/node.css" />



I can always tell when someone tried working on a site without setting up the real server, because they use relative instead of absolute paths, and relative paths are prone to error because they are relative.

I always in all cases use absolute paths, that is, paths starting at document root.

I also, by the way, always put includes outside of document root, so they are not directly web accessible, only php can access them. That doesn't help with the generic stuff like zencart or wordpress etc that is so poorly done that you can't do that, or can't do it easily..
Back to top
ckosloff
Status: Contributor
Joined: 21 Dec 2011
Posts: 292
Location: South Florida
Reply Quote
@techadmin
Thanks for answer.
This thing does load on live server planetwigs.com.
I can easily bring customizations from previous site ladywig.com to that one, but I hate to develop live, this damn thing should load on my local server, but...Zen Cart has trouble with PHP 5.4+, webhost is on earlier version.
I am trying to analyze what I get in the browser with tools like Web Developer toolbar, but I cannot change many settings because this stupid thing will not let me into the backend.
I don't really have to set a path to the stylesheet like in HTML, it is in ZCcrap_whatever/includes/templates/active_template/mycss.css
More on that later, I think I will take the quick approach of developing live, and mull a completely different solution.
Back to top
Display posts from previous:   
Page: 1, 2, 3  Next
All times are GMT - 8 Hours