Warning the selected directory is not a valid tomcat home
Problem:
This happens because intellijIDEA doesn't have enough permission to read and write on the tomcat home folder, this happens on linux machines.
Solution
let your tomcat root folder = "/opt/tomcat" then this command which will set the right privilege level for intellijIDEA.
$ sudo chmod 755 -R /opt/tomcat
If you are using IDEA on Linux platform, use the command:
chmod 755 -R apache-tomcat-<<Your-tomcat-version>>
Then try to restart your service again.
Try selecting the libexec
subdirectory in IntelliJ - i.e. /usr/local/Cellar/tomcat/8.5.9/libexec