{"id":71,"date":"2019-10-21T17:25:19","date_gmt":"2019-10-21T08:25:19","guid":{"rendered":"https:\/\/blog.wsd.sh\/?p=71"},"modified":"2019-10-22T11:33:03","modified_gmt":"2019-10-22T02:33:03","slug":"jaxer-working-with-vanilla-apache","status":"publish","type":"post","link":"https:\/\/blog.wsd.sh\/?p=71","title":{"rendered":"Jaxer working with Vanilla Apache"},"content":{"rendered":"\n<p>Getting Jaxer to work with vanilla Apache (as in installed from apt-get or yum) is something that I haven&#8217;t been able to get working, probably because I&#8217;m an idiot. After the failure of not being able to register our compiled version of Apache to Systemd, I figured I might as well try getting vanilla Apache to work with Jaxer, and if it doesn&#8217;t work I can always go cry in a corner.<\/p>\n\n\n\n<p>I guess the corner will have to wait for another opportunity, because Jaxer (quite unexpectedly) worked with vanilla Apache, and quite nicely at that. So what exactly is the problem before versus now? The main reason is likely going to be envvars, but I can&#8217;t say exactly, since I didn&#8217;t have the context of reverse engineering Apache when I edited the conf files praying that something would work.<\/p>\n\n\n\n<p>While I can&#8217;t describe the issue of what was wrong before, I can describe the process that it takes to get Jaxer working with vanilla Apache. So let&#8217;s be sure to record the steps here as to be able to take advantage of it later.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt-get update\n$ sudo apt-get install apache2 -y<\/code><\/pre>\n\n\n\n<p>Like any Apache install we update and then install Apache2. Note that we&#8217;re only interested in static file server, so we don&#8217;t need to grab php7 or MariaDB for a LAMP install at the moment. Assuming that port 80 isn&#8217;t in use, Apache should automatically start and be listening for requests. But we need to configure a few things first, so we&#8217;ll stop the file server with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl stop apache2<\/code><\/pre>\n\n\n\n<p>First we take our <a href=\"https:\/\/blog.wsd.sh\/wp-content\/uploads\/2019\/10\/jaxer.httpd_.txt\">jaxer.httpd.conf file<\/a> and copy it into <strong>\/etc\/apache2\/mods-available<\/strong>. Then we need to enable it with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo ln -s \/etc\/apache2\/mods-available\/jaxer.httpd.conf \/etc\/apache2\/mods-enabled\/<\/code><\/pre>\n\n\n\n<p>Next we need to edit the envvars file to include the variables that Jaxer defines (and probably needs to be able to run). So next we edit the file <strong>\/etc\/apache2\/envvars<\/strong> and add the following text to the end of the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if test \"x$LD_LIBRARY_PATH\" != \"x\" ; then\n  LD_LIBRARY_PATH=\"\/opt\/AptanaJaxer\/Apache22\/lib:$LD_LIBRARY_PATH\"\nelse\n  LD_LIBRARY_PATH=\"\/opt\/AptanaJaxer\/Apache22\/lib\"\nfi\nexport LD_LIBRARY_PATH\nexport JAXERBASE=\/opt\/AptanaJaxer\nexport ANCHOR=\/opt\/AptanaJaxer<\/code><\/pre>\n\n\n\n<p>Then we save the file and then update the variables with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ source \/etc\/apache2\/envvars<\/code><\/pre>\n\n\n\n<p>Though to be honest, I&#8217;m not sure if this step is actually needed or if the variables are automatically read with systemctl start or stop. Next we need to set the file root to <strong>\/opt\/ApatanaJaxer\/public<\/strong>. This is something that I would like to test to see if it can be changed, but for right now we&#8217;ll stick with what works. So to change the web root directory we&#8217;ll edit <strong>\/etc\/apache2\/sites-enabled\/000-default.conf<\/strong> to change the root directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80>\n        # The ServerName directive sets the request scheme, hostname and port that\n        # the server uses to identify itself. This is used when creating\n        # redirection URLs. In the context of virtual hosts, the ServerName\n        # specifies what hostname must appear in the request's Host: header to\n        # match this virtual host. For the default virtual host (this file) this\n        # value is not decisive as it is used as a last resort host regardless.\n        # However, you must set it for any further virtual host explicitly.\n        #ServerName www.example.com\n\n        ServerAdmin webmaster@localhost\n        DocumentRoot \/opt\/AptanaJaxer\/public\n\n        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n        # error, crit, alert, emerg.\n        # It is also possible to configure the loglevel for particular\n        # modules, e.g.\n        #LogLevel info ssl:warn\n\n        ErrorLog ${APACHE_LOG_DIR}\/error.log\n        CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n        # For most configuration files from conf-available\/, which are\n        # enabled or disabled at a global level, it is possible to\n        # include a line for only one particular virtual host. For example the\n        # following line enables the CGI configuration for this host only\n        # after it has been globally disabled with \"a2disconf\".\n        #Include conf-available\/serve-cgi-bin.conf\n\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p>Next for the purposes of debugging we&#8217;ll edit the Apache config file to serve directories, and we&#8217;ll also remove the deny from all cause on the root directory. To be honest I find it weird that the default <strong>\/var\/www\/html<\/strong> configuration works with this clause, but it seems like anytime I change something it can be fixed by removing that line. So while it might not be a good idea for production reasons, it works now so we&#8217;ll go with it. Edit <strong>\/etc\/apache2\/apache2.conf<\/strong> and change the root directory configuration to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \/>\n        Options Indexes FollowSymLinks\n        AllowOverride None\n        #Require all denied\n&lt;\/Directory><\/code><\/pre>\n\n\n\n<p>And then since Apache uses the user and group name of <em>www-data<\/em>, we need to change the owner of <strong>\/opt\/AptanaJAxer\/public<\/strong> to <em>www-data<\/em>, otherwise Apache won&#8217;t be able to read the files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo chown -R www-data:www-data \/opt\/AptanaJaxer\/public<\/code><\/pre>\n\n\n\n<p>And with that, we&#8217;re ready to start Apache again. Start the server with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl start apache2<\/code><\/pre>\n\n\n\n<p>And if everything works, then Jaxer should be working with vanilla Apache. In this case we tested the Todo List and it worked!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"717\" height=\"608\" src=\"https:\/\/blog.wsd.sh\/wp-content\/uploads\/2019\/10\/Screenshot_2019-10-21-Todo-List.png\" alt=\"\" class=\"wp-image-74\" srcset=\"https:\/\/blog.wsd.sh\/wp-content\/uploads\/2019\/10\/Screenshot_2019-10-21-Todo-List.png 717w, https:\/\/blog.wsd.sh\/wp-content\/uploads\/2019\/10\/Screenshot_2019-10-21-Todo-List-300x254.png 300w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/figure>\n\n\n\n<p>So there are a lot of things to be excited about with this development. It means that we can really get rid of the <strong>Apache22 <\/strong>and <strong>scripts <\/strong>file in the post install directory leaving just <strong>jaxer <\/strong>and <strong>public<\/strong>. And it also means that we don&#8217;t have to completely rely on our Nodejs emulation of apache that could run into issues for the non-implemented parts of the server emulation. I think this is the implemented we&#8217;ll be using in the install script going forward. And it means that the next thing we can test is to see if we can move the root directory from <strong>\/opt\/AptanaJaxer\/public<\/strong> to <strong>\/var\/www\/html<\/strong>. Which would only leave the <strong>jaxer <\/strong>folder left in the runtime enviornment.<\/p>\n\n\n\n<p><strong>Edit:<\/strong><br>I decided to push my luck to see if I could move the publuc folder from <strong>\/opt\/AptanaJaxer\/public<\/strong> to <strong>\/var\/www\/html<\/strong>. And on first glance it looks like it worked! We were able to get our Todo list application running from the standard Apache public directory. I think one more think we need to test to see if relative paths for server-side scripts work. As that&#8217;s something that Jaxer might get confused with loading.<\/p>\n\n\n\n<p><strong>Edit2:<\/strong><br>Changed the Todo sample application to use <strong>jaxer-include<\/strong> instead of inline scripts, and the application still works inside of the <strong>\/var\/www\/html<\/strong> folder. Which means the only folder left in the post install application is <strong>\/opt\/AptanaJaxer\/jaxer<\/strong>. Which means our next focus will be moving that directory to<strong> \/etc\/emrajs<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting Jaxer to work with vanilla Apache (as in installed from apt-get or yum) is something that I haven\u2019t been able to get working, probably because I\u2019m an idiot. After the failure of not being able to register our compiled version of Apache to Systemd, I figured I might as well try getting vanilla Apache to work with Jaxer, and if it doesn\u2019t work I can always go cry in a corner.<\/p>\n","protected":false},"author":1,"featured_media":72,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/71"}],"collection":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":5,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions\/79"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/media\/72"}],"wp:attachment":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}