I think that it is the mainstream to secure portability with Docker or virtual machines, but I think that "it works if you place it in an appropriate place without installing it" including me is still popular, so I summarized it in this article. I did.
/ Users / username
First, create a directory to place the set of resources. Here, create a directory called myserver
directly under the user's home directory and place all resources in it.
This section is the most confusing part of the procedure in this article. If you already have Java 8 installed, you can skip this step.
Download from the official Oracle website. The version in this article is Java 8 u161.
Extract the pkg file from the dmg file, place it anywhere, then open a terminal and navigate to the pkg location. Please refer to the following articles for the procedure from that point onward.
Try Java 9 without installing on Mac https://qiita.com/mather314/items/8d112569d7bb0805683e
Next is Tomcat, a web application server. You can find the procedure here and there, so it's just for your reference.
After downloading and unzipping the tar.gz from the official project site, rename it totomcat8 and place it in the myserver directory at the beginning.
https://tomcat.apache.org/download-80.cgi
Instead of setting it with environment variables, create a file named setenv.sh in tomcat8 / bin and set the Java location to be used. The app I wanted to run this time will cause OutOfmemory if I don't have about 1GB of memory, so I also set the startup option.
setenv.sh
JAVA_HOME=/Users/username/myserver/java
JAVA_OPTS="-Xms1024M -Xmx1024M"
Set the admin user and its password for Tomcat Manager.
Open tomcat8 / conf / tomcat-user.xml
and set as follows. Here, it is admin / pass.
tomcat-user.xml
<tomcat-users ... >
:
<user username="admin" password="pass" roles="manager-gui,admin-gui"/>
:
</tomcat-users>
After starting Tomcat by running tomcat8 / bin / startup.sh
, go to http: // localhost: 8080 / in your browser. If the Tomcat screen is displayed, it is successful.
Also, make sure you can also access http: // localhost: 8080 / manager / html to connect to Tomcat Manager with the user / password you set earlier.
Then install the database PostgreSQL. I can't find the procedure as much as Tomcat, but it is just for reference. (The entire article is a collection of references ...)
After downloading the binary from the official website and unzipping it, rename it to pgsql and place it in the myserver directory. I'm using version 9.6 here.
https://www.enterprisedb.com/download-postgresql-binaries
After opening a terminal and navigating to pgsql / bin
, first create a data directory. A set of data is stored here, so if you want to place it in a location other than PostgreSQL itself, change it to any location.
$ ./pg_ctl initdb -D /Users/username/myserver/pgsql/data
Start the database by specifying the data directory and log file you just created.
$ ./pg_ctl start -l /Users/username/myserver/pgsql/pgsql.log -D /Users/username/myserver/pgsql/data
Let's connect to the database when it starts successfully. postgres
is the name of the database created by default.
$ ./psql -d postgres
psql (9.6.6)
Type "help" for help.
postgres=#
First, create the database mydb
owned by you (username here username).
postgres=# CREATE DATABASE mydb OWNER username;
CREATE DATABASE
Once created, switch the operation target to the database you just created.
postgres=# \c mydb
You are now connected to database "mydb" as user "username".
Let's work on any schema and table creation with SQL.
mydb=# CREATE SCHEMA myschema;
CREATE SCHEMA
mydb=# CREATE TABLE myschema.mytable (name varchar(100), age int);
CREATE TABLE
Finally, deploy the JDBC driver so that Tomcat can connect to PostgreSQL. After downloading from the official PostgreSQL site, move the jar file to tomcat8 / lib
and you're done.
https://jdbc.postgresql.org/download.html
――This time, I decided to build the environment on Mac, but I feel that it can be the same for both Windows and Linux, so I will add it as soon as it becomes necessary. ――I haven't touched Java for nearly 10 years, and it may be that the procedure or setting is "I don't think so". I would appreciate it if you could point out. ――Also, this time I created this environment to introduce a certain framework, and I have not created a scratch application by myself. This kind of article can only be completed by running a simple operation verification app, but please forgive me.
Recommended Posts