Placing the app on the server for the first time.
I am still using the environment created up to Building Java execution environment on Sakura VPS.
--Sakura VPS
You need to restart if you change anything. I was quite worried without knowing the rudimentary thing.
Prepare a WAR file. The figure below is exported in Eclipse.
Official sample file. If you can't prepare an affordable war, you can't check the operation of the database, but for the time being, it may be good to put this and check it.
It is easiest to deploy with the GUI (Tomcat Web Application Manager) that was set last time, but since it became unusable after that, deploy it manually. I will move it later, so wherever I upload it. For the time being, upload the test folder under the WWW where the FTP authority was set with WinCSP.
/var/www/html/test
Example: Move the war file temporarily placed under html under webapps
# mv /var/www/html/test/sample.war /usr/local/apache-tomcat-8.5.34/webapps/
After a while, it will be automatically expanded, and if the project does not use the database, it can be accessed from the browser up to this point.
Example:
https://IP address of VPS/sample/
Subsequent steps are required for projects using databases.
The figure below is MySQL Workbench.
It's easy to understand visually, so deploy it using phpMyAdmin. https://VPSのIPアドレス/phpMyAdmin(URL変更推奨)/
Create a new database on the Database tab. Match the collation to the same as the database in the development environment.
Import the SQL file you just exported
Describe the settings of the following 2 file servers
There is a file with the same name in Eclipse, so copy and paste the relevant part from there. Change the database name and password accordingly.
The figure below shows the location of the file in Eclipse.
Describe Resources in Global Naming Resources
/usr/local/tomcat/conf/server.xml
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource driverClassName="com.mysql.jdbc.Driver" initialSize="1" maxIdle="3" maxTotal="5" maxWaitMillis="5000" name="jdbc/[DB name]" password="【password】" type="javax.sql.DataSource" url="jdbc:mysql://127.0.0.1:3306/[DB name]?useUnicode=true&characterEncoding=utf8" username="root" validationQuery="SELECT 1"/>
/usr/local/tomcat/conf/context.xml
<ResourceLink name="jdbc/[DB name]"
global="jdbc/[DB name]"
type="javax.sql.DataSource" />
Reboot and check.
Recommended Posts