0

I would like to know how to start up k=10 Apache2 server processes upon Ubuntu 16.04 alpha release reboot. Yesterday, I read this URL, [https://rudd-o.com/linux-and-free-software/tuning-an-apache-server-in-5-minutes], which says to use Apache2 with the prefork.c module and set StartServers equal to 10

<IfModule prefork.c>
StartServers       4
MinSpareServers    3
MaxSpareServers   10
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  10000
</IfModule>

Unfortunately , my apache2 only has the event.c module. I tried upgrading apache2 to the prefork.c module with sudo apt-get install apache-mtm-prefork and the install error said no such package available because it may be outdated or obsolete. Then I tried sudo apt-get update and I received the same error message.

My next step was to try to configure the apache2 event module with StartServers = 5 by changing /etc/httpd.conf and then restarting my systemd apache.service file and my ps -ef | grep -in "apache2" shows only 2 www-data apache2 processes and ps-ef | grep -in "mod" shows no mod-mono-server4 process.

Furthermore, upon running apache2 at the bash shell command prompt it said syntax error APACHE2_LOCK_FILE environment variable missing. I discovered that APACHE2_LOCK_FILE is defined in my /etc/apache2/envvars file.

The Ubuntu 16.04 apache2 man page says, "In general, apache2 should not be invoked directly, but rather should be invoked via /etc/init.d/apache2 or apache2ctl. The default Debian configuration requires environment variables that are defined in /etc/apache2/envvars and are not available if apache2 is started directly. However, apache2ctl can be used to pass arbitrary arguments to apache2."

So I could use /etc/apache2/envars , I edited my systemd apache.service file to use ExecStart = /etc/init.d/apache2 start and rebooted my Lenovo ThinkStation Ubuntu 16.04 desktop and to no avail, I still got only 2 www-data apache2 processes and ps-ef | grep -in "mod" shows no mod-mono-server4 process when I ran ps -ef | grep -in "apache2".

May I ask what I did wrong and how to fix it? Please suggest tests I can do.

I know that many Ubuntu 16.04 alpha release users will soon complain about the same problem I experienced.

  • By "k=10 servers" are you just asking about starting "10 servers"? I'm not sure what make of mentioning a "k" variable, if only the single value of 10 matters for the question. – Mark Stosberg Jun 23 '16 at 20:16
  • Why are your running the alpha release of 16.04 when 16.04 has been officially release? – Mark Stosberg Jun 23 '16 at 20:16
  • @Mark Stosberg, Thank you for your insightful comments. I will answer your 2 questions in detail in 10 minutes. We need to get this working by 8:00 A.M tomorrow. – Frank Jun 23 '16 at 21:06
  • @Mark Stosberg, I goofed writing alpha release of 16.04 . I intended to say alpha release of Mono. May I ask how to launch /etc/apache2/envvars followed by /usr/sbin/apache2 using a single systemd apache.service ExecStart command so that a Apache Lock File is created? What is the utility of preceding ExecStart with sudo password? How may I invoke k mod-mono-server4 processes on Ubuntu 16.04? If you have time, I look forward to your answer. Thank you – Frank Jun 23 '16 at 21:14
  • @Mark Stosberg, k = 10 servers refers to starting 10 apache2 servers such as with StartServers. Thank you. – Frank Jun 23 '16 at 21:47
1

First you can confirm that you already have the mpm_prefork module by seeing that's shipped in the apache2 package in 16.04. You'll see a couple results for it if you do this:

 dpkg -L apache2 | grep fork

 /etc/apache2/mods-available/mpm_prefork.conf
 /etc/apache2/mods-available/mpm_prefork.load

Now check which MPM module is enabled, and you'lll see that the Event MPM module is enabled while the Prefork module is not:

  ls /etc/apache2/mods-enabled/mpm*

It sounds like you want to disable the Event MPM module and enable the Prefork MPM module, which you can do with symlinks, and then restart Apache:

sudo rm /etc/apache2/mods-enabled/mpm*
sudo ln -s /etc/apache2/mods-available/*fork* /etc/apache2/mods-enabled/

Perhaps then your "StartServer" directive will work as desired. The Event MPM server runs an event loop in a single process, so it doesn't all the extra processes.

You also mentioned starting Apache and systemd. I recommend NOT starting Apache's http directly or with apache2ctl. ONLY control it through systemd for consistency.

Here are some related systemd control commands, as examples:

 sudo systemctl start   apache2
 sudo systemctl stop    apache2
 sudo systemctl restart apache2

You had more questions in your comments about setting up Mono, ASPX and multiple apps. You should ask those questions separately and be clear whether you intend to serve multiple apps on a single domain, or multiple apps on multiple domains.

To make the Apache2 service starts at boot, run:

sudo systemctl enable apache2
  • Thank you for your excellent answer. May I ask what the fork in lin soft link , sudo ln -s /etc/apache2/mods-avalable/*fork* /etc/apache2/mods-enabled/, means? Furthermore, how might I restart upon reboot the apache.service and /etc/apache2/envvars in one fell swoop with ExecStart? Why does my Event MPM Server with mod-mono-server4 not start up as a single process running an event loop? – Frank Jun 23 '16 at 23:14
  • I appreciate your assistance. I am confused about how to do this automatically: sudo systemctl start apache2 sudo systemctl stop apache2 sudo systemctl restart apache2 How do I ask with separate questions about how I intend to serve multiple apps on a single domain, or multiple apps on multiple domains where 127.0.0.1 is a single domain? – Frank Jun 23 '16 at 23:18
  • See updated answer re: systemctl syntax and starting at boot. I'm not sure Event MPM has 2 processes. Maybe one runs as root and one does not? my "fork" wildcard matched the prefork files. You could check that with ls. – Mark Stosberg Jun 23 '16 at 23:37
  • Just start a new question with your question about multiple apps. – Mark Stosberg Jun 23 '16 at 23:37
  • Thank you for your elegant answer. With StartServers = 4 and MTM-prefork.c enabled , I observed 4 /etc/sbin/apache2 www-data server processes. But I saw only 2 /usr/lib/mono/4.5/mod-mono-server4.exe www-data processes. Most likely this state occured because I forgot to mention an ApacheLockFile need to be created using /etc/apache2/envvars in concert with mod-mono-server4 in apache.service ExecStart. How could one do that? – Frank Jun 24 '16 at 1:26
0

There are 3 more steps in setting up Ubuntu 16.04 to serve aspx content residing in different root directories.

  1. Put this at the end of apache2.coonf

    Alias /test "/usr/share/doc/xsp/test" Alias /personal "/home/user/mypages" AddMonoApplications default "/test:/usr/share/doc/xsp/test,/personal:/home/user/mypages" SetHandler mono SetHandler mono

    1. source /etc/apache2/envvars after modifying it as follows:

      envvars - default environment variables for apache2ctl

      this won't be correct after changing uid

      unset HOME

      for supporting multiple apache2 instances

      if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}" else SUFFIX= fi

      Since there is no sane way to get the parsed apache2 config in scripts, some

      settings are defined via environment variables and then used in apache2ctl,

      /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.

      export APACHE_RUN_USER=venkat export APACHE_RUN_GROUP=venkat

      temporary state file location. This might be changed to /run in Wheezy+1

      export APACHE_PID_FILE=/var/run/apache2/apache2.pid export APACHE_RUN_DIR=/var/run/apache2 export APACHE_LOCK_DIR=/var/lock/apache2

      Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.

      export APACHE_LOG_DIR=/var/log/apache2

      The locale used by some modules like mod_dav

      export LANG=C

      Uncomment the following line to use the system default locale instead:

      . /etc/default/locale

      export LANG

      The command to get the status for 'apache2ctl status'.

      Some packages providing 'www-browser' need '--dump' instead of '-dump'.

      export APACHE_LYNX='www-browser -dump'

      If you need a higher file descriptor limit, uncomment and adjust the

      following line (default is 8192):

      APACHE_ULIMIT_MAX_FILES='ulimit -n 65536'

      If you would like to pass arguments to the web server, add them below

      to the APACHE_ARGUMENTS environment.

      export APACHE_ARGUMENTS=''

      Enable the debug mode for maintainer scripts.

      This will produce a verbose output on package installations of web server modules and web application

      installations which interact with Apache

      export APACHE2_MAINTSCRIPT_DEBUG=1

      1. At the top of apache2.conf , place the line: LoadModule mono_module /usr/lib/apache2/modules/mod_mono.so.

      2. To test this, put http://127.0.0.1/test/Default.cs and put http://127.0.0.1/personal/Default.cs in the Firefox web browser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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