Install Neos CMS on Ubuntu 20.04 HostnExtra
Tags: neoscms, ubuntu, hostnextra, linux
Published: 2021-06-06 16:51:18

In this article, we'll explain how to install Neos CMS on Ubuntu 20.04.

<a href="https://www.neos.io/" target="_blank" rel="noopener">Neos CMS</a> is free and open source software licensed under GPL v3 or later. Neos CMS has many valuable features that appeal to both content editors and developers, such as inline editing, full Unicode support, complete internationalization, and built-in SEO.
<h4>Prerequisites</h4>
<ul>
 	<li>An Ubuntu 20.04 installed <a href="https://www.hostnextra.com/dedicated-server.html" target="_blank" rel="noopener">dedicated server</a> or <a href="https://www.hostnextra.com/vps-hosting.html" target="_blank" rel="noopener">KVM VPS</a>.</li>
 	<li>A root user access or normal user with administrative privileges.</li>
 	<li>Add "A" record of you domain like example.com that point to the server.</li>
</ul>
<a href="https://www.hostnextra.com/kb/easy-to-install-neos-cms-on-ubuntu/">Install Neos CMS on Ubuntu 20.04</a>
<h4>1. Keep the server up to date</h4>
<blockquote># apt update -y &amp;&amp; apt upgrade -y</blockquote>
<h4>2. Install PHP</h4>
Install PHP-FPM and other required PHP extensions.
<blockquote># apt install php-fpm php-mbstring php-tokenizer php-xml php-mysql php-imagick php-zip -y</blockquote>
<h4>3. Install MySQL</h4>
Install MySQL server using following command.
<blockquote># apt install mysql-server -y</blockquote>
Let's secured the installation using the following command:
<blockquote># mysql_secure_installation</blockquote>
Once the script gets executed, it will ask multiple questions.

It will ask you to enter the current password for root (enter for none):

Then enter yes/y to the following security questions:
<blockquote>Set a root password? [Y/n]: y
Remove anonymous users? : y
Disallow root login remotely? : y
Remove test database and access to it? : y
Reload privilege tables now? : y</blockquote>
Login in to mysql
<blockquote># mysql -u root -p</blockquote>
Run the following queries to create a MySQL database and database user for Neos CMS.
<blockquote>mysql&gt; CREATE DATABASE neos;

mysql&gt; CREATE USER 'neos'@'localhost' IDENTIFIED BY 'password';
mysql&gt; GRANT ALL PRIVILEGES ON neos.* TO 'neos'@'localhost';
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; exit</blockquote>
<h4>4. Install Nginx</h4>
Install Nginx web server using following command.
<blockquote># apt install nginx -y</blockquote>
Disable the default configuration.
<blockquote># rm /etc/nginx/sites-enabled/default</blockquote>
Create a new configuration for Neos CMS.
<blockquote># nano /etc/nginx/sites-available/neos.conf</blockquote>
Paste the following contents:
<blockquote>
server {

listen 80 default_server;
listen [::]:80 default_server;


server_name example.com;

root /var/www/neos/Web;
index index.php;

location ~ /_Resources/ {
access_log off;
log_not_found off;
expires max;

if (!-f $request_filename) {
rewrite "/_Resources/Persistent/([a-z0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
rewrite "/_Resources/Persistent(?>/[a-z0-9]{5}){8}/([a-f0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
}
}

location / {
try_files $uri $uri/ /index.php?$args;
}

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param FLOW_REWRITEURLS 1;
fastcgi_param FLOW_CONTEXT Production;
fastcgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_param X-Forwarded-Port $proxy_port;
fastcgi_param SERVER_NAME $http_host;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
</blockquote>
Save the configuration file and exit. Then enable the new configuration.
<blockquote># ln -s /etc/nginx/sites-available/neos.conf /etc/nginx/sites-enabled/neos.conf</blockquote>
Check the new configuration.
<blockquote># nginx -t</blockquote>
Reload Nginx for the changes to take effect.
<blockquote># systemctl reload nginx.service</blockquote>
<h4>5. Install Neos CMS</h4>
Install Composer, the PHP dependency manager.
<blockquote># curl -sS https://getcomposer.org/installer | php</blockquote>
Make the composer command globally available.
<blockquote># mv composer.phar /usr/local/bin/composer</blockquote>
Create a folder to store the Neos CMS source code.
<blockquote># mkdir -p /var/www/neos</blockquote>
Set neos as the owner of the source code folder.
<blockquote># chown www-data:www-data /var/www/neos</blockquote>
Fetch the Neos CMS source code using Composer. Be patient because this process may take a while.
<blockquote># cd /var/www/neos &amp;&amp; composer create-project --no-dev neos/neos-base-distribution .</blockquote>
If you see the Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? message, press ENTER.

Generate all required libraries such as jQuery, Bootstrap, CKEditor.
<blockquote># ./flow resource:publish</blockquote>
Output similar like:
<blockquote>Publishing resources of collection "static"
Publishing resources of collection "persistent"</blockquote>
<h4>6. Secure Domain with HTTPS</h4>
Install certbot's nginx package
<blockquote># apt install certbot python3-certbot-nginx -y</blockquote>
Obtain a certificate using certbot command. The Nginx plugin will take care of reconfiguring Nginx and reloading the config.
<blockquote># certbot --nginx -d example.com -d www.example.com</blockquote>
Follow the wizard and deploy the SSL. It will add HTTPS redirection code in <em>neos.conf</em> configuration file.
<h4>7. Configure Neos CMS</h4>
Open the http://example.com/setup link in your browser. Wait a while for Neos CMS to initialize the setup tool. Then you will see the login screen.

<img class="alignnone size-full wp-image-2274" src="https://www.hostnextra.com/kb/wp-content/uploads/2021/06/install-neos-cms.png" alt="Install Neos CMS" width="970" height="665" />

To get the setup password, run following command to display the password.
<blockquote># cat /var/www/neos/Data/SetupPassword.txt</blockquote>
It will display the password. Once you get the password, login in the Neos CMS to follow the setup wizard.

In the Configure database screen:
<ul>
 	<li>Select the MySQL/MariaDB via PDO option for DB Driver.</li>
 	<li>Enter neos for DB Username.</li>
 	<li>Enter the database password you created in step 2 for DB Password</li>
 	<li>Enter 127.0.0.1 for DB Host.</li>
 	<li>Select the neos option for DB Name.</li>
</ul>
Follow the rest setup process and add the one admin user to login and build the website.

Once you complete with the setup wizard, login into the dashboard using this link: <em>http://example.com/neos</em>. You can use server IP to visit the dashboard.

That's it. The installation processor has been completed successfully.

In this article, we have seen how to install Neos CMS on Ubuntu 20.04.