Jekyll not serving site locally - ruby

Configuration: OSX 10.9.1, ruby 2.1.1 via RVM
I have created a new Jekyll site via the command jekyll new sitename.
I then enter that directory and issue the command jekyll serve.
I get the following notice:
Configuration file: /Users/George/sitename/_config.yml
Source: /Users/George/sitename
Destination: /Users/George/sitename/_site
Generating... done.
Server address: http://0.0.0.0:4000
Server running... press ctrl-c to stop.
However when attempting to visit http://localhost:4000/ or http://0.0.0.0:4000/ my browser endlessly attempts to load the page.
I have checked and the site was built correctly including an index.html in /Users/George/sitename/_site/.
The _config.yml looks like so:
name: sitename
markdown: maruku
pygments: true
Does anyone know why Jekyll could be failing to serve the site but not throwing any errors?
Edit: If I change the port to 6000 and attempt to serve it then my browser instantly gives a page not found so there must be something interfering with port 4000 however the issue still stands.

It's likely that something else is using port 4000 on your computer. You can find out by running the following command:
sudo lsof -i :4000
As you can run the server on another port, we'll move on to the next issue, setting the baseurl. In your _config.yml you can specify which baseurl to use, this will be the url from which all pages are served, so if you had baseurl: http://myawesomesite.com, Jekyll will expect them to be accessed from that url.
As you're working locally, you have two options:
Set the baseurl to / in your _config.yml:
baseurl: /
Launch Jekyll with the --baseurl flag:
$ jekyll serve -w --baseurl '/'
Additionally, you could specify the port as a flag:
$ jekyll server -w --baseurl '/' --port 4000
If you want further information about what's going on when you run jekyll, you can run the command with the --trace flag:
$ jekyll server -w --trace

Related

Change from Laravel LocalHost Server to APP_URL .test

So I use the command PHP artisan serve to run a server and I can view my Laravel site at http://127.0.0.1:8000/ but I want to run my website at the
APP_URL= 'http://projectName.test' how can I do this? I see a lot of videos online where it just spins up that way automatically.
MySQL
Win11
XAMP
You can set up a virtual host to run the project on the custom URL in localhost.
this link is an example of defining a virtual host.
Use this:
php artisan serve --host=projectName.test --port=80
Also this is serve manual:
Description:
Serve the application on the PHP development server
Usage:
serve [options]
Options:
--host[=HOST] The host address to serve the application on [default: "127.0.0.1"]
--port[=PORT] The port to serve the application on
--tries[=TRIES] The max number of ports to attempt to serve from [default: 10]
--no-reload Do not reload the development server on .env file changes
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
change host file parameter like:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 projectName.test
change directory to root project and run:
php artisan serve --host=projectName.test --port=80
Take a peek at Laragon. I think Laragon is a better choice than XAMPP. And in your case, using Laragon don't require you to run php artisan serve to run the app. Just turn on the Laragon, and your app will be able to be accessed from http://your-app.test (suffix can be changed). No additional configuration or changes needed.

How to deploy a Ruby Sinatra Web Server Docker Image on Heroku

So, I'm trying to build a simple web server for personal practice with Ruby without Rails, dockerize it and deploy it to Heroku. But problems always arouse when the docker image has been deployed on Heroku. I think it's because When deploying a container app on Heroku, they require that Dockerfiles are configured to intake the randomly assigned port on a dyno - exposed as the $PORT environmental variable. Even though Docker allows for the usage of EXPOSE to specify which port for an image to use, Heroku ignores those commands and goes by the port assigned to a dyno.
So How do I exactly do this?
Error Message shown on Heroku when I clicked open app after successfully deployed the docker image:
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
My Web server has two functions: respond with your current IP and current time (in HTML).
I will be using Sinatra. I have successfully created the .rb file :
require 'sinatra'
require 'socket'
#find final_ip
addr_infos = Socket.ip_address_list
final_ip = ''
addr_infos.each do |addr_info|
final_ip = final_ip + ' ' + addr_info.ip_address
end
#find current time
cur_time = Time.now.ctime
#print to html
get '/' do
'<h2> Current Time: </h2> <br>' + cur_time + '<br><br>' + '<h2> Current IP Address: </h2> <br>'+ final_ip
end
config.ru file:
# config.ru
require './test'
run Sinatra::Application
Gemfile:
# Gemfile
source 'https://rubygems.org'
gem 'sinatra'
gem 'thin'
gem 'puma'
gem 'reel'
gem 'http'
gem 'webrick'
It run perfectly fine on localhost:4567 when I executed the command bundle install and ruby test.rb on terminal.
The following is the Dockerfile:
# Dockerfile
FROM ruby:3.0.1
WORKDIR /code
COPY . /code
RUN bundle install
EXPOSE 4567
EXPOSE $PORT
CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "-p", "4567"]
There were no errors when building the docker image and deploying it on Heroku.
I am not sure how to solve this problem as I'm new to this Docker and Heroku world. Can somebody help me please? Thank you very much!

Jekyll Serve is not serving in localhost

I've been using jekyll for a month or so and had no problems until today. I went to run jekyll in the terminal and was prompted with this:
Configuration file: /Users/jamiefitzhenry/desktop/casa/_config.yml
jekyll 2.5.3 | Error: Address already in use - bind(2)
I seemed to fix this by finding the PID and killing it, however when I run jekyll again I get this:
Configuration file: /Users/jamiefitzhenry/desktop/casa/_config.yml
Server address: http://127.0.0.1:3000/
Server running... press ctrl-c to stop.
When I put http://127.0.0.1:3000/ into my browser I only get the html of the page however nothing else is updating. When I go into my text editor (Espresso) and save changes nothing happens. This is my config.yml
# Build settings
markdown: kramdown
permalink: pretty
port: 3000
sass:
sass_dir: assets/css
style: :nested
This usually happens whenever I start to run jekyll, however as soon as I save the index.html the whole site updates in the browser, which is not the case this time.
I'm still very new to running commands in the terminal, however any help would be much appreciated.

Jekyll baseurl and configuration for 'serve'

I succeeded in setting up a Jekyll site, but there is one thing I would like to optimize. In my config file I have the value http://mydomain.com/ as baseurl. Everything is working fine, except that every time I want to use the 'serve' command to have a local development server as a preview for a post that I am currently writing, I have to manually set the baseurl to '/' to make it work. Otherwise the server address would be http://0.0.0.0:4000http://mydomain.com/ and non-working.
Is there an easy workaround for this, or am I doing something wrong?
Thanks.
Just found out, that this command solves my problem.
jekyll serve --baseurl '/'
What do you mean by "manually" ?
jekyll serve --baseurl '/'
Should work (and your terminal will remember the command). Now, if you are using GitHub pages, you don't really need the baseurl anyway.
Base url is the path after the hosts part in the url.
So your local parameters must be :
host: http://mydomain.com/
baseurl: ""

Rails app only pointing to default rails index page

So I am new to deploying to an Ubuntu Server (12.04). I have nginx and unicorn installed. Everything seems to be working except for the fact that I don't know how to point it to my app. Currently I am pointing to 'home/administrator/apps/my_site/current/public' however all my files are in 'home/administrator/apps/my_site/app/views/'. I am currently only pointing to the static files like the error htmls and the default rails index.html. How do I get nginx to point to my views/app?
Thanks.
If you're using Nginx + Unicorn then you don't point Nginx at any path, you run up unicorn on the server and then have Nginx proxy all it's requests to the unicorn instance. I would recommend looking at using foreman and then it's foreman export upstart which exports ubuntu upstart scripts for controlling unicorn.
This link gives you details on how to config your nginx site.

Resources