import{r as o,p as c,q as l,w as n,z as e,t as d,R as t}from"./vendor.8ed37afc.js";var h="assets/plesk-screenshot.9485a115.png";const u={class:"markdown-body"},p=e("p",null,[t("On many shared hosts you are not allowed to directly invoke node commands but you have to use the Plesk configuration panel instead. Unfortunately, Plesk does not allow the interactive execution of node scripts. Therefore we can\u2019t use Directus\u2019 "),e("code",null,"init"),t(" script and have to set up the project by our own.")],-1),_=e("div",{class:"tip hint"},[e("div",{class:"hint-title"},"Successful tests"),e("p",null,"This approach has successfully been tested with a webhosting offer from netcup.")],-1),f=e("h2",{id:"setup-database"},[t("Setup database "),e("a",{class:"header-anchor",href:"#setup-database"},"#")],-1),g=e("p",null,"First, make sure that you\u2019ve already created a database and a user for it. We will use MySQL in this guide. When you plan to use SQLite you can ignore this.",-1),m=e("h2",{id:"setup-a-project-folder"},[t("Setup a project folder "),e("a",{class:"header-anchor",href:"#setup-a-project-folder"},"#")],-1),y=e("p",null,"On the server, create a project folder with 4 files in it.",-1),b=e("h3",{id:"1.-add-.env-file"},[t("1. Add .env file "),e("a",{class:"header-anchor",href:"#1.-add-.env-file"},"#")],-1),j=t("This file is used to configure Directus. Normally, the "),w=e("code",null,"init",-1),v=t(" script would create it for us. So now we have to do it manually. You can just copy it from another Directus installation or use the "),k=e("a",{href:"https://github.com/directus/directus/blob/main/api/example.env",target:"_blank",rel:"noopener noreferrer"},"example file",-1),D=t(" of Directus and then modify it (see "),x=t("Environment Variables"),A=t("). You likely have to adjust the database information."),P=e("p",null,"If you have not already a user in the database make sure to add a first user by adding the following two lines so that you can later login to Directus.",-1),S=e("pre",null,[e("code",null,`ADMIN_EMAIL="admin@example.com"
ADMIN_PASSWORD="password"
`)],-1),N=e("div",{class:"tip hint"},[e("div",{class:"hint-title"},"Choosing a Port"),e("p",null,[t("Since Plesk uses the "),e("a",{href:"https://www.phusionpassenger.com/",target:"_blank",rel:"noopener noreferrer"},"Phusion Passenger"),t(" application server to serve Node.js apps you do not need to worry about choosing a specific port. Just use an arbitrary number. To quote the Passenger docs:")]),e("blockquote",null,[e("p",null,"When run in Passenger, the port number that you pass to listen() is irrelevant and has no effect. Passenger always makes the app listen on a random Unix domain socket.")])],-1),T=e("h3",{id:"2.-add-package.json"},[t("2. Add package.json "),e("a",{class:"header-anchor",href:"#2.-add-package.json"},"#")],-1),I=e("p",null,[t("Add Directus and your database connector as a dependency. To execute Directus\u2019 "),e("code",null,"bootstrap"),t(" command you also have to add a script entry for it.")],-1),W=e("pre",null,[e("code",{class:"language-json"},[t(`{
	`),e("span",{class:"hljs-attr"},'"scripts"'),t(`: {
		`),e("span",{class:"hljs-attr"},'"bootstrap"'),t(": "),e("span",{class:"hljs-string"},'"directus bootstrap"'),t(`
	},
	`),e("span",{class:"hljs-attr"},'"dependencies"'),t(`: {
		`),e("span",{class:"hljs-attr"},'"directus"'),t(": "),e("span",{class:"hljs-string"},'"*"'),t(`,
		`),e("span",{class:"hljs-attr"},'"mysql"'),t(": "),e("span",{class:"hljs-string"},'"^2.18.1"'),t(`
	}
}
`)])],-1),Y=e("h3",{id:"3.-add-application-startup-file-index.js"},[t("3. Add application startup file index.js "),e("a",{class:"header-anchor",href:"#3.-add-application-startup-file-index.js"},"#")],-1),q=e("p",null,[t("Instead of a start command, Plesk wants a startup file. So create a "),e("code",null,"index.js"),t(" with the following content:")],-1),M=e("pre",null,[e("code",{class:"language-js"},[e("span",{class:"hljs-keyword"},"var"),t(" { startServer } = "),e("span",{class:"hljs-built_in"},"require"),t("("),e("span",{class:"hljs-string"},"'directus/server'"),t(`);

startServer();
`)])],-1),B=e("h3",{id:"4.-add-.npmrc"},[t("4. Add .npmrc "),e("a",{class:"header-anchor",href:"#4.-add-.npmrc"},"#")],-1),C=e("p",null,[t("Lastly, we need to make a small configuration for npm by creating a "),e("code",null,".npmrc"),t(" file with the following content:")],-1),E=e("pre",null,[e("code",null,`scripts-prepend-node-path=true
`)],-1),L=e("h2",{id:"activate-and-configure-node.js"},[t("Activate and configure node.js "),e("a",{class:"header-anchor",href:"#activate-and-configure-node.js"},"#")],-1),V=e("p",null,"In Plesk, choose your website and click \u201CNode.js\u201D. You should then see a button \u201CEnable Node.js\u201D and click on it.",-1),O=e("p",null,[t("Now, change the \u201CDocument root\u201D and \u201CApplication root\u201D to the location of your project folder. \u201CApplication startup file\u201D must point to the "),e("code",null,"index.js"),t(" file from the former step. The screen should now look like this:")],-1),R=e("p",null,[e("img",{src:h,alt:"Plesk Screenshot"})],-1),Q=e("p",null,"You can now install the dependencies by clicking on the button \u201CNPM install\u201D.",-1),U=e("h2",{id:"bootstrap-directus"},[t("Bootstrap Directus "),e("a",{class:"header-anchor",href:"#bootstrap-directus"},"#")],-1),z=e("p",null,[t("To set up the database tables (and the first user) for Directus, click on the button \u201CRun script\u201D and input "),e("code",null,"bootstrap"),t(". You get the console output after the script has run through.")],-1),F=e("div",{class:"tip hint"},[e("div",{class:"hint-title"},"Current Issue of Argon2"),e("p",null,"You may run into an error of argon2 telling you that glibc is missing. If that\u2019s the case try adding and running this script entry to your package.json:"),e("pre",null,[e("code",{class:"language-json"},`    "scripts" {
        "argon2-rebuild": "npm rebuild argon2 --build-from-source",
        <...>
    }

`)]),e("p",null,[t("Afterwards try "),e("code",null,"bootstrap"),t(" again.")])],-1),H=e("h2",{id:"test-directus-access"},[t("Test Directus Access "),e("a",{class:"header-anchor",href:"#test-directus-access"},"#")],-1),J=e("p",null,"The Directus app should now work under your configured url. If not, try changing the development mode and wait a couple of seconds.",-1),$={setup(G,{expose:a}){const s={title:"Shared Hosting with Plesk",modularExtension:!1};return a({frontmatter:s}),(K,X)=>{const r=o("router-link"),i=o("DocsWrapper");return c(),l(i,{frontmatter:s},{default:n(()=>[e("div",u,[p,_,f,g,m,y,b,e("p",null,[j,w,v,k,D,d(r,{to:"/docs/configuration/config-options/#general"},{default:n(()=>[x]),_:1}),A]),P,S,N,T,I,W,Y,q,M,B,C,E,L,V,O,R,Q,U,z,F,H,J])]),_:1})}}};export{$ as default};
