Check the CentOS version.
cat /etc/centos-release
# CentOS Linux release 7.5.1804 (Core)
Create a new non-root user account with sudo
access and switch to it.
useradd -c "John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoe
NOTE: Replace johndoe
with your username.
Set up the timezone.
timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'
Ensure that your system is up to date.
sudo yum update -y
Install necessary packages.
sudo yum install -y wget curl vim git
For simplicity, disable SELinux and Firewall.
sudo setenforce 0
sudo systemctl stop firewalld
sudo systemctl disable firewalld
Setup the Webtatic YUM repo.
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Install PHP and required PHP extensions.
sudo yum install -y php70w php70w-cli php70w-fpm php70w-common php70w-xml php70w-gd php70w-zip php70w-mbstring php70w-mysql php70w-pgsql php70w-sqlite3 php70w-mcrypt php70w-apc
Check the version.
php --version
# PHP 7.0.30 (cli) (built: Apr 28 2018 08:14:08) ( NTS )
Start and enable PHP-FPM.
sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service
Setup the MariDB repo. Run sudo vi /etc/yum.repos.d/MariaDB.repo
and populate it with the following.
[mariadb]
name = MariaDB
baseurl = https://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Install MariaDB database server.
sudo yum install -y MariaDB-server MariaDB-client
Check the version.
mysql --version
# mysql Ver 15.1 Distrib 10.2.16-MariaDB, for Linux (x86_64) using readline 5.1
Start and enable MariaDB.
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Run mysql_secure_installation
to improve security and set the password for the MariaDB root
user.
sudo mysql_secure_installation
Connect to the MariaDB shell as the root
user.
mysql -u root -p
# Enter password:
Create an empty MariaDB database and user for Cachet, and remember the credentials.
CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT
Install Nginx.
sudo yum install -y nginx
Check the version.
nginx -v
# nginx version: nginx/1.12.2
Start and enable Nginx.
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
Configure Nginx. Run sudo vim /etc/nginx/conf.d/cachet.conf
and populate the file with the following configuration.
server {
listen 80;
listen [::]:80;
server_name status.example.com; # Check this
root /var/www/cachet/public; # Check this
index index.php;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000; # Check this
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_keep_conn on;
}
}
Test the configuration.
sudo nginx -t
Reload Nginx.
sudo systemctl reload nginx.service
Install Composer globally.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
Check the version.
composer --version
# Composer version 1.6.5 2018-05-04 11:44:59
Create a document root directory.
sudo mkdir -p /var/www/cachet
Change ownership of the /var/www/cachet
directory to johndoe
.
sudo chown -R johndoe:johndoe /var/www/cachet
Download the Cachet source code with Git and checkout the latest tagged release.
cd /var/www/cachet
git clone https://github.com/cachethq/Cachet.git .
git tag -l
git checkout v2.3.15
Copy .env.example
to .env
file and configure the database and APP_URL
settings in .env
.
cp .env.example .env
vim .env
Install dependencies with composer.
composer install --no-dev -o
Set the application key.
php artisan key:generate
Install Cachet.
php artisan app:install
Change ownership of the /var/www/cachet
directory to nginx
.
sudo chown -R nginx:nginx /var/www/cachet
Run sudo vim /etc/php-fpm.d/www.conf
and set the user and group to nginx
. Initially, it will be set to apache
.
sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx
Restart PHP-FPM.
sudo systemctl restart php-fpm.service
Open your site in a web browser and follow the instructions on the screen to finish Cachet installation. To access the Cachet dashboard append /dashboard
to your website URL.
Before you can install PyroCMS on a server, there are a few requirements that need to be met.
Check the CentOS version.
cat /etc/centos-release
# CentOS Linux release 7.4.1708 (Core)
Create a new non-root
user account with sudo
access and switch to it.
useradd -c "John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoe
NOTE: Replace johndoe
with your username.
Set up the timezone.
timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'
Ensure that your system is up to date.
sudo yum update -y
Install required and useful packages.
sudo yum install -y wget vim unzip bash-completion
Disable SELinux.
sudo setenforce 0
CentOS does not provide the latest PHP version in its default software repositories. We’ll need to add a Webtatic YUM repo.
Download and install PHP 7.2 and required PHP extensions.
sudo yum install -y php72w php72w-cli php72w-fpm php72w-mysql php72w-curl php72w-sqlite3 php72w-mbstring php72w-gd php72w-dom
Check PHP version.
php --version
PHP 7.2.2 (cli) (built: Feb 4 2018 10:14:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Download and install MariaDB.
sudo vim /etc/yum.repos.d/MariaDB.repo
# Copy/paste this to the /etc/yum.repos.d/MariaDB.repo file
[mariadb]
name = MariaDB baseurl = https://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 sudo yum install -y MariaDB-server MariaDB-client
Check the MariaDB version.
mysql --version
# mysql Ver 15.1 Distrib 10.2.13-MariaDB, for Linux (x86_64) using readline 5.1
Start and enable MariaDB.
sudo systemctl enable mariadb.service
sudo systemctl start mariadb.service
Run the mysql_secure_installation
script to improve the security of your MariaDB installation.
sudo mysql_secure_installation
Log into MariaDB as the root user.
mysql -u root -p
# Enter password:
Create a new MariaDB database and user, and remember the credentials.
create database dbname;
grant all on dbname.* to 'username' identified by 'password';
Exit MySQL.
exit
Install NGINX.
sudo vim /etc/yum.repos.d/nginx_mainline.repo
# Copy/paste this to the /etc/yum.repos.d/nginx_mainline.repo file
[nginx]
name=nginx repo baseurl=https://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=1 enabled=1 wget https://nginx.org/keys/nginx_signing.key sudo rpm –import nginx_signing.key rm nginx_signing.key sudo yum install -y nginx
Check the NGINX version.
nginx -v
Start and enable NGINX.
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
Configure NGINX as a FastCGI proxy. Run sudo vim /etc/nginx/conf.d/pyro.conf
and populate it with the following text.
server {
listen 80;
server_name example.com; # Check this
root /var/www/pyro/public; # Check this
index index.php index.html;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000; # Check this
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
NOTE: Make sure to point the web root to Pyro’s public
directory.
Test the NGINX configuration.
sudo nginx -t
Reload NGINX.
sudo systemctl reload nginx.service
Download the Composer dependencies.
sudo yum install -y curl git unzip
Download and install Composer, the dependency manager for PHP.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
Check the Composer version.
composer --version
# Composer version 1.6.3 2018-01-31 16:28:17
Create a document root directory.
sudo mkdir -p /var/www/pyro
Change the ownership of the /var/www/pyro
directory to johndoe
.
sudo chown -R johndoe:johndoe /var/www/pyro
Download the latest stable release of PyroCMS from the command line.
cd /var/www/pyro
composer create-project pyrocms/pyrocms .
NOTE: You may run out of memory when installing Pyro via Composer. It may be wise to stop Nginx, PHP-FPM and MySQL servers with sudo systemctl stop nginx.service php-fpm.service mysql.service
to save on memory usage and start them again after this step.
Change the ownership of the /var/www/pyro
directory to nginx
.
sudo chown -R nginx:nginx /var/www/pyro
Run sudo vim /etc/php-fpm.d/www.conf
and set the user and group to nginx
.
sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx
Restart the php-fpm.service
.
sudo systemctl restart php-fpm.service
Using your preferred web browser, open your site and follow the PyroCMS installer. After following the installer you will have PyroCMS up and running. To access the PyroCMS admin area, append /admin
to your site URL.
For the sake of this tutorial, we will write a simple application that reads a list of cities from a database and displays it on a web page, this way we will demonstrate a basic, but working, PHP application.
This guide assumes that you have Docker-CE already installed and at least a minimal working knowledge of docker. For that matter you may review the following tutorials:
A real life docker-based application will typically be composed of several containers. Managing these manually can easily become quite messy and cumbersome. That’s where docker-compose comes into play. It helps you to manage a number of containers through a simple yaml
configuration file.
Install docker-compose.
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Create a folder to hold all the necessary files of this example and then cd
into it. From now on, this is our working directory and every command will be executed inside this folder and every path will be referenced relative to it. This folder may be referenced later as WORKING_DIR
.
mkdir ~/docker
cd ~/docker
Now create three more folders.
mkdir php nginx app
The php
folder is where we will build our custom PHP image, the nginx
folder will hold the necessary files for our custom nginx image and the app
folder is where we will be putting the source code and configuration of our sample application.
In this example, we are going to use php-fpm
to connect to the Nginx webserver. We will be using the official PHP base image. However, we also need to install and enable some extensions so that we may access the database. Inside the php
folder create a file named Dockerfile
and put the following contents into it.
FROM php:7.1-fpm-alpine3.4
RUN apk update --no-cache \
&& apk add --no-cache $PHPIZE_DEPS \
&& apk add --no-cache mysql-dev \
&& docker-php-ext-install pdo pdo_mysql
Note that we are using the Alpine version of the official PHP image. Alpine is a very tiny distribution targeted towards containers by providing much smaller footprints. Also, note the use of the command docker-php-ext-install
, the official PHP image provides this command to ease the process of installing and configuring PHP extensions.
Now, let’s build this Docker image by issuing the following (inside our WORKING_DIR
):
docker build -t aklwebhost-php php/
docker-compose.yml
fileAs already mentioned, docker-compose
allows you to manage a number of containers through a simple configuration file. This configuration file is typically named docker-compose.yml
. Create this file inside the app
folder.
touch app/docker-compose.yml
Now put the following contents into this file.
version: '2'
services:
php:
image: aklwebhost-php
volumes:
- ./:/app
working_dir: /app
We will explain this syntax. First, note the first line.
version: '2'
This specifies the version of the docker-compose.yml
configuration file used. The next line specifies the services, or in other words, the containers to be provisioned.
services:
php:
image: aklwebhost-php
volumes:
- ./:/app
working_dir: /app
Note that every service has a specific key inside the services
block. The name specified here will be used to reference this specific container later. Also note that inside the php
configuration, we define the image used to run the container (this is the image we built previously). We also define a volume mapping.
volumes:
- ./:/app
This tells docker-compose
to map the current directory (./
) to the /app
directory inside the container. The last line sets the /app
folder inside the container as the working directory, which means that this is the folder where all future commands inside a container are by default executed from.
We can now orchestrate our containers.
cd ~/docker/app
docker-compose up -d
You can run the following command to make sure that the PHP container was executed:
docker ps
Still inside the app
folder, we can run any command inside a defined service container with the help of the docker-compose
command.
docker-compose exec [service] [command]
The [service]
placeholder refers to the service key. In our case, this was php
. Let’s run a command inside the container to check our PHP version.
docker-compose exec php php -v
You will see the following output.
PHP 7.1.14 (cli) (built: Feb 7 2018 00:40:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
Just like the PHP container, we need to create a custom image for the webserver. But in this case, we just need to provide a configuration for our virtual host
. Make sure you are inside our WORKING_DIR
and create a Dockerfile
inside the nginx
folder:
cd ~/docker
touch nginx/Dockerfile
Now put the following contents into this Dockerfile
:
FROM nginx:1.13.8-alpine
COPY ./default.conf /etc/nginx/conf.d/default.conf
We are using the default Nginx image based on Alpine. On this Docker file we simply copy a configuration file into our application setup. Before building this image, create a configuration file.
touch nginx/default.conf
Now populate it with this content.
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /app;
index index.php;
#server_name server_domain_or_IP;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Note that at the fastcgi_pass php:9000
line we are referencing the PHP container by it’s name inside the service
block of the docker-compose.yml
configuration file. Internally docker-compose
creates a network and assigns the service name as the host name to each of the services defined. We can now build the Nginx image.
docker build -t aklwebhost-nginx nginx/
docker-compose.yml
Now update the app/docker-compose.yml
file.
version: '2'
services:
php:
image: aklwebhost-php
volumes:
- ./:/app
working_dir: /app
web:
image: aklwebhost-nginx
volumes:
- ./:/app
depends_on:
- php
ports:
- 80:80
We have only added a new service. The configuration is nearly the same, except for the following.
depends_on:
- php
ports:
- 80:80
Once the Nginx container needs the PHP service to be fully initialized, we force this requirement in the depends_on
option. The ports
configuration key maps a host port to a container port, here we map the port 80
in the host to the port 80
in the container.
Now create a file called index.php
inside the app
folder and put the following in it.
<?php phpinfo();
Make sure the port 80
is accessible through your firewall and execute the following.
cd ~/docker/app
docker-compose up -d
Once again, double check that the service is up.
docker ps
Open a browser and access [aklwebhost-instance-ip]
. You may find out your AKLWEB HOST instance IP address by running the following.
hostname -I
You will see the PHP info page.
The official MySQL image allows you to configure the container through simple environment variables. This can be done with an environment
option inside the service block definition. Update the ~/docker/app/docker-compose.yml
file to the following.
version: '2'
services:
php:
image: aklwebhost-php
volumes:
- ./:/app
working_dir: /app
web:
image: aklwebhost-nginx
volumes:
- ./:/app
depends_on:
- php
ports:
- 80:80
mysql:
image: mysql:5.7.21
volumes:
- ./:/app
- dbdata:/var/lib/mysql
environment:
- MYSQL_DATABASE=world
- MYSQL_ROOT_PASSWORD=root
working_dir: /app
volumes:
dbdata:
Now we’ve defined a new service for the database. Notice the line dbdata:/var/lib/mysql
. This mounts the path on the container /var/lib/mysql
to a persistent volume managed by Docker, this way the database data persists after the container is removed. This volume needs to be defined in a top-level block as you can see in the end of the file.
Before orchestrating our new configuration, let’s download a sample MySQL database. The official MySQL documentation provides some sample databases. We will be using the well-known world database. This database provides a listing of countries and cities. To download this sample, execute the following inside our app folder.
curl -L http://downloads.mysql.com/docs/world.sql.gz -o world.sql.gz
gunzip world.sql.gz
Now lets orchestrate our containers.
docker-compose up -d
As you may have already noticed, the docker-compose up
command starts only the containers that are not already started. It checks for the differences between your docker-compose.yml
file and the current configuration of running containers.
One more time, check that the MySQL container was started.
docker ps
Now populate the world database.
docker-compose exec -T mysql mysql -uroot -proot world < world.sql
You can verify that the database was populated by selecting data directly from the database. First access the MySQL prompt inside the container.
docker-compose exec mysql mysql -uroot -proot world
In the MySQL prompt, run the following.
select * from city limit 10;
You will see a list of cities. Now quit the MySQL prompt.
mysql> exit
Now that all of the necessary containers are up and running, we can focus on our sample application. Update the app/index.php
file to the following.
<?php
$pdo = new PDO('mysql:host=mysql;dbname=world;charset=utf8', 'root', 'root');
$stmt = $pdo->prepare("
select city.Name, city.District, country.Name as Country, city.Population
from city
left join country on city.CountryCode = country.Code
order by Population desc
limit 10
");
$stmt->execute();
$cities = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>AKLWEB HOST Rocks!</title>
</head>
<body>
<h2>Most Populous Cities In The World</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Country</th>
<th>District</th>
<th>Population</th>
</tr>
</thead>
<tbody>
<?php foreach($cities as $city): ?>
<tr>
<td><?=$city['Name']?></td>
<td><?=$city['Country']?></td>
<td><?=$city['District']?></td>
<td><?=number_format($city['Population'], 0)?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</body>
</html>
If you access [aklwebhost-instance-ip]
in a web browser, you will see a list of the most populous cities in the world. Congratulations, you have deployed a fully working PHP application using docker.
In this tutorial, I have demonstrated step by step how to configuring a fully working PHP application. We built custom images for PHP and Nginx, and configured docker-compose to orchestrate our containers. Despite being very basic and simple, this setup reflects a real life scenario.
In this guide, we have built and tagged our images locally. For a more flexible setup, you can push these images to a docker registry. You may push to the official docker registry or even setup your own docker registry. In any case, this will allow you to build your images on one host and use them on another.
For a more detailed usage of docker-compose
, you should refer to the official documentation.
Depending on your application requirements and the PHP framework you use, you may want to add more extensions. This can easily be done by modifying the Dockerfile
used to build our custom PHP image. However, some extensions need extra dependencies to be installed in the container. You should refer to the list of extensions in the PHP official documentation to review the basic requirements of each extension.
This guide was written for Vanilla Forums 2.3, but may also work on newer releases.
For this tutorial, we will use forum.example.com
as the domain name pointed towards the AKLWEB HOST instance. Please make sure to replace all occurrences of the example domain name with the actual one.
Install Apache.
sudo yum -y install httpd
Start Apache and enable it to automatically run at boot time.
sudo systemctl start httpd
sudo systemctl enable httpd
We will use PHP 7.1 to obtain maximum security and stability. First, add and enable the Remi repository.
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php71
Install the latest version of PHP along with the modules required by Vanilla Forum.
sudo yum -y install php php-gd php-mysqli php-mbstring php-curl php-cli php-pear php-devel php-openssl
MariaDB is a fork of MySQL. Add the MariaDB repository into your system. The default YUM
repository contains an older version of MariaDB, which is unsupported by Vanilla.
echo "[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1" | sudo tee /etc/yum.repos.d/mariadb.repo
Install MariaDB.
sudo yum -y install mariadb mariadb-server
Start MariaDB and enable it to automatically start at boot time.
sudo systemctl start mariadb
sudo systemctl enable mariadb
Before configuring the database, you will need to secure MariaDB first.
sudo mysql_secure_installation
You will be asked for the current MariaDB root password. By default, there is no root password in a fresh MariaDB installation. Press the “Enter
” key to proceed. Set a strong password for the root
user of your MariaDB server and answer “Y
” to all of the other questions that are asked. The questions asked are self-explanatory.
Log into the MySQL shell as root.
mysql -u root -p
Provide the password for the MariaDB root user to log in.
Run the following queries to create a database and a database user for the Vanilla installation.
CREATE DATABASE vanilla_data CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'vanilla_user'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON vanilla_data.* TO 'vanilla_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
You can replace the database name vanilla_data
and username vanilla_user
according to your choice. Please make sure to change StrongPassword
to a very strong password.
Download the Vanilla forum zip archive.
wget https://open.vanillaforums.com/get/vanilla-core.zip
Install unzip.
sudo yum -y install unzip
Extract the archive.
sudo unzip vanilla-core.zip -d /var/www/vanilla
Provide the appropriate ownership.
sudo chown -R apache:apache /var/www/vanilla
Allow HTTP
traffic on port 80
through the firewall.
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
Create a virtual host for your Vanilla forum site.
sudo nano /etc/httpd/conf.d/forum.example.com.conf
Populate the file.
<VirtualHost *:80>
ServerName forum.example.com
DocumentRoot /var/www/vanilla
<Directory /var/www/vanilla>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Restart Apache.
sudo systemctl restart httpd
Now that you have successfully installed and configured Vanilla forum, you can access the application on http://forum.example.com
. Provide the database and administrator details. Once you have provided the required database and admin details, the setup will write into the database and you will be taken to the administration interface. You can now configure the forum according to your needs.
Congratulations, you have successfully installed Vanilla forum in CentOS 7 server.
]]>In this tutorial, we will use crm.example.com
as the domain name pointed to the server. Replace all occurrences of crm.example.com
with your actual domain name.
OroCRM can be installed on any production web server supporting PHP. OroCRM supports all versions of PHP greater than 7.0. In this tutorial, we will use Nginx with PHP-FPM and PHP 7.1.
Install Nginx.
sudo yum -y install nginx
Start Nginx and enable it to automatically start at boot.
sudo systemctl start nginx
sudo systemctl enable nginx
PHP 7 is not available in the default YUM repository, but we can use the Remi repository to obtain and install the latest builds of PHP 7. First, add and enable the Remi repository.
sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php71
Install the latest version of PHP 7 along with the PHP modules required by OroCRM.
sudo yum -y install php php-fpm php-ctype php-curl php-fileinfo php-gd php-intl php-json php-mbstring php-mcrypt php-mysql php-pcre php-simplexml php-tokenizer php-xml php-zip php-tidy php-soap php-opcache php-posix
Edit the default PHP configuration file.
sudo nano /etc/php.ini
Find the following lines. Uncomment and make changes as shown.
date.timezone = Asia/Kolkata
;Replace "Asia/Kolkata" with your appropriate timezone
memory_limit = 512M
cgi.fix_pathinfo=0
Edit the PHP-FPM configuration file.
sudo nano /etc/php-fpm.d/www.conf
By default, PHP-FPM is configured to run with Apache and to listen to the port 9000
. We will need to change the user and group, as well as the Unix socket file on which it will run. Find the following lines and make necessary changes as shown.
user = nginx
group = nginx
;listen = 127.0.0.1:9000
;Comment out or remove the above line and add the following line.
listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nobody
listen.group = nobody
Start PHP-FPM and enable it to start at boot.
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
Provide ownership of PHP-FPM socket file to Nginx user.
sudo chown nginx:nginx /var/run/php-fpm/php-fpm.sock
MariaDB is an open source fork of MySQL. Install MariaDB.
sudo yum -y install mariadb mariadb-server
Start MariaDB and enable it to automatically start at boot.
sudo systemctl start mariadb
sudo systemctl enable mariadb
The default installation of MariaDB comes with a few test databases and anonymous users. Before configuring the database, you will need to secure the MariaDB server first. You can secure it by running the mysql_secure_installation
script.
sudo mysql_secure_installation
You will be asked for the current MariaDB root password. By default, there is no root password in a fresh MariaDB installation. Press the Enter
key to proceed. Set a strong password for the root user of your MariaDB server and answer Y
to all the other questions asked. The questions asked are self-explanatory.
Log in to the MySQL shell as the root user by running.
mysql -u root -p
Provide the password for the MariaDB root user to log in.
Run the following queries to create a database and a database user for OroCRM installation.
CREATE DATABASE oro_data;
CREATE USER 'oro_user'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON oro_data.* TO 'oro_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
You can replace the database name oro_data
and username oro_user
according to your choice. Be sure to change StrongPassword
to a very strong password.
OroCRM also requires Node.js JavaScript runtime. Node.js will be used by OroCRM to compile the JavaScript, which is used to build the user interface of the application. The default repository of CentOS contains an outdated version of Node.js, thus you will need to add the Nodesource repository to your system to obtain the latest version.
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
Install Node.js and Git.
sudo yum -y install nodejs git
Git will be used to clone the OroCRM repository from the internet. You will also need to install Composer. Composer is a dependency manager tool for PHP applications. Because OroCRM is written in Symfony framework, you will need Composer to install the dependencies and application.
Install Composer.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Move Composer to the /usr/bin
directory so that it can be executed from anywhere in the system.
sudo mv composer.phar /usr/bin/composer
Provide execution permission to the Composer.
sudo chmod +x /usr/bin/composer
There are many ways to download OroCRM on your server. The most appropriate way to get the most updated version is to clone the repository through Git.
Clone the OroCRM repository.
cd /usr/share/nginx/
sudo git clone -b 2.3 https://github.com/oroinc/crm-application.git orocrm
Copy the example parameters
file to the default parameters
file used by OroCRM.
cd orocrm
sudo cp app/config/parameters.yml.dist app/config/parameters.yml
Before you can proceed further, you will need to update the parameters.yml
file to provide database and email information.
sudo nano app/config/parameters.yml
Find the following lines.
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: oro_crm
database_user: root
database_password: ~
Update the above configuration according to the database you have created to store OroCRM data. In our case, it should look like this.
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
database_name: oro_data
database_user: oro_user
database_password: StrongPassword
If you have an SMTP server ready and you wish to use email sending features immediately, you can update the mailer settings as shown.
mailer_transport: smtp
mailer_host: mail.example.com
mailer_port: 456
mailer_encryption: ssl
mailer_user: mails@example.com
mailer_password: EMailPassword
If you do not have a mail server ready, you can skip it for now by leaving the existing values. You can always change email configuration through the dashboard.
Set a random string in secret
by replacing ThisTokenIsNotSoSecretChangeIt
. A random string is required to encode the session data. An example string will look like this.
secret: uxvpXHhDxCFc9yU1hV1fMwjSoyVUzGh4WBMBBBa3XEgrRUF5OuB2h8iNl9JRDqcd
You can generate a random string using the pwgen
utility. Install pwgen
utility by running sudo yum -y install pwgen
. To generate a random string, run pwgen -s 64 1
.
Save the file and exit from the editor. Install the required PHP dependencies through composer.
sudo composer install --prefer-dist --no-dev
Using --no-dev
will ensure that the Composer only installs the dependencies required to run the web server in production mode. The script will take a few minutes to download and install the required PHP dependencies.
Install the application.
sudo php app/console oro:install --env=prod
This will build the web cache and write the database. The --env=prod
parameter is provided to install the application in production mode. The installation will only proceed if all the required dependencies are installed and configured.
During the installation, you will be asked few questions for setting up the administrator account. The questions are as follows.
Administration setup.
Application URL (http://localhost): http://crm.example.com
Organization name (OroCRM): My Organization
Username (admin):
Email: mail@example.com
First name: John
Last name: Doe
Password:
Load sample data (y/n): y
Provide the information. Load the sample data to evaluate the product before using it for production.
Warm up the API documentation cache:
sudo php app/console oro:api:doc:cache:clear
Create an Nginx server block file to serve the application to the users.
sudo nano /etc/nginx/conf.d/orocrm.conf
Populate the file.
server {
server_name crm.example.com;
root /usr/share/nginx/orocrm/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|config|install)\.php(/|$) {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
# Enable Gzip compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_min_length 1000;
gzip_http_version 1.0;
gzip_proxied any;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css image/svg+xml;
gzip_vary on;
# Enable browser caching
# One week for javascript and css
location ~* \.(?:css|js) {
expires 1w;
access_log off;
add_header Cache-Control public;
}
# Three weeks for media: images, fonts, icons, video, audio etc.
location ~* \.(?:jpg|jpeg|gif|png|ico|tiff|woff|eot|ttf|svg|svgz|mp4|ogg|ogv|webm|swf|flv)$ {
expires 3w;
access_log off;
add_header Cache-Control public;
}
error_log /var/log/nginx/orocrm_error.log;
access_log /var/log/nginx/orocrm_access.log;
}
Make sure that you change the crm.example.com
with your actual domain name. The above configuration also includes the configuration required for GZip compression and browser caching. Gzip compression compresses the data before sending it to the browser. Enabling browser caching stores the static resources to the web cache of the client computer. The next time the user accesses the site, most of the static content is loaded from the user’s own web cache. These two methods increase the speed of the application dramatically.
Check the Nginx configuration file for any errors.
sudo nginx -t
The output should look like the following.
[user@aklwebhost ~]$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Provide the ownership of the OrOCRM files to the Nginx user.
sudo chown -R nginx:nginx /usr/share/nginx/orocrm
Restart Nginx to apply the new configuration.
sudo systemctl restart nginx
If you are running a firewall on your server, you will need to configure the firewall to set an exception for HTTP service. Allow Nginx to connect from outside the network.
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
You can now access the application at http://crm.example.com
. Log in using the administrator username and password you have set during installation.
To automatically run the scheduled tasks you can add a Cron job entry. Open crontab
.
sudo crontab -e
Add the following line to the file.
*/1 * * * * /usr/bin/php /usr/share/nginx/orocrm/app/console oro:cron --env=prod > /dev/null
This will run the cron job every minute so that the scheduled tasks such as email queues are processed earliest.
You will also need to setup Supervisor to run the Message Queue service. It is required that at least one process is running at all times for a consumer to process the messages. A consumer can normally interrupt the message process through many ways. To ensure that the service is running continuously, we will use the Supervisor service. We will configure Supervisor to run four processes in parallel. If any of the four processes is stopped for any reason, the Supervisor will try to start it again.
Install Supervisor.
sudo yum -y install supervisor
Edit the Supervisor configuration file.
sudo nano /etc/supervisord.conf
Add the following lines at the end of the file.
[program:oro_message_consumer]
command=/usr/bin/php /usr/share/nginx/orocrm/app/console --env=prod --no-debug oro:message-queue:consume
process_name=%(program_name)s_%(process_num)02d
numprocs=4
autostart=true
autorestart=true
startsecs=0
user=nginx
redirect_stderr=true
Start and enable Supervisor to automatically start at boot time.
sudo systemctl start supervisord
sudo systemctl enable supervisord
You can view the status of the processes by running the following.
sudo supervisorctl status
You should see that the processes are running.
[user@aklwebhost ~]$ sudo supervisorctl status
oro_message_consumer:oro_message_consumer_00 RUNNING pid 13596, uptime 0:02:13
oro_message_consumer:oro_message_consumer_01 RUNNING pid 13595, uptime 0:02:13
oro_message_consumer:oro_message_consumer_02 RUNNING pid 13594, uptime 0:02:13
oro_message_consumer:oro_message_consumer_03 RUNNING pid 13593, uptime 0:02:13
OroCRM is now installed on your server. You can now use the application to manage the routine tasks of your organization. To learn more about OroCRM, you can visit its official website.
]]>PHP-based Zikula is an open-source framework for online applications. With Zikula, you can create editable and interactive webpages. It is a cross-platform program that works with every widely used operating system. For database-related tasks, Zikula uses Microsoft SQL Server, Oracle, PostgreSQL, and MySQL on the back end.
We’ll talk about installing Zikula on a CentOS 7 server in this article.
First, update your system to the latest stable version by running the following command:
sudo yum update -y
sudo reboot
You will need to install Apache, MariaDB, PHP and other required PHP modules on your system. You can install all of these packages with the following command:
sudo yum install httpd mariadb mariadb-server php php-common php-mysql php-mcrypt php-gd php-xml php-mbstring php-xmlrpc unzip wget -y
Once the installation is complete, start both Apache and MariaDB services and enable them to start at boot with the following commands:
sudo systemctl start httpd
sudo systemctl start mariadb
sudo systemctl enable httpd
sudo systemctl enable mariadb
MariaDB installation is not hardened, so you will need to secure it first. You can secure it with the following script:
sudo mysql_secure_installation
Answer all of the questions as follows.
Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
Next, login to the MariaDB console.
mysql -u root -p
This will prompt you for a password, enter your MariaDB root password. After logging in, create a database for Zikula:
MariaDB [(none)]>CREATE DATABASE zikuladb;
MariaDB [(none)]>GRANT ALL PRIVILEGES on zikuladb.* to 'user'@'localhost' identified by 'password';
MariaDB [(none)]>FLUSH PRIVILEGES;
MariaDB [(none)]>exit
you will need to download the latest version of the Zikula CMS from GitHub. You can also download it using the wget
command.
wget https://github.com/zikula/core/releases/download/1.4.6/Zikula_Core-1.4.6.build119.zip
Extract the downloaded zip archive.
unzip Zikula_Core-1.4.6.build119.zip
Move the extracted directory into the Apache root directory.
sudo mv Zikula_Core-1.4.6 /var/www/html/zikula
Give necessary permission to zikula
directory.
sudo chown -R apache:apache /var/www/html/zikula
Before accessing Zikula, you will need to allow port 80
through firewalld. You can do this with the following command:
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --reload
Open your web browser and type the URL http://192.168.15.110/install.php
or http://your-domain.com/install.php
, then complete the required the steps to finish the installation.
Thats it. You have successfully installed Zikula on your CentOS 7 server.
]]>The officially recommended method to install Symfony is to use the Symfony installer.
Log in from an SSH terminal, input:
sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony
Now you can use the symfony
command from your shell.
Create a new application with Symfony:
symfony new my_project
This command will create a directory called my_project
in your home directory to host all of your application files.
If you want to specify the version of Symfony, append the version number to the command mentioned above, like:
symfony new my_project 2.6
symfony new my_project 2.6.5
symfony new my_project 2.7.0-RC1
symfony new my_project lts
Execute the following commands to start the Symfony application:
cd my_project/
php bin/console server:run
If the operation was successful, you will see the prompt [OK] Server running on http://127.0.0.1:8000
appear on your screen. You can verify the result by accessing the URL http://127.0.0.1:8000/
from a web browser.
Keep the command running in the current SSH terminal. Open another SSH terminal and download a text browser called Lynx:
sudo yum install -y lynx
Visit http://127.0.0.1:8000/
from Lynx:
lynx http://127.0.0.1:8000/
You will see the welcome page of Symfony: “Welcome to Symfony 3.0.0”. Then press Shift + Q to quit Lynx.
If by any chance you see a blank page or an error page instead of the welcome page, you can try to fix the problem by reconfiguring the permissions on the ~/my_project/var/cache
and ~/my_project/var/logs
directories. Visit the Symfony website for more details.
You can also use a server configuration tester to check if your environment is ready for using Symfony. Access the following URL while your Symfony application is running:
lynx http://localhost:8000/config.php
In the Vultr LNMP environment, the server configuration tester will recommend us to install and enable the intl extension (used for validators) for a better Symfony experience. Here is the solution:
php -v
yum list php*intl sudo yum install php55u-intl.x86_64
sudo reboot
Congratulations! You have setup a Symfony application.
]]>This guide explains how to add, grow, and shrink partitions of a AKLWEB HOST cloud server with GParted, a graphical partition editor. If you have upgraded your cloud server with a larger disk or need to expand a partition while preserving data, follow these steps. A cloud server instance is sometimes called a Virtual Private Server or VPS.
This guide temporarily boots your cloud server with the SystemRescue x64 ISO to run GParted, which works with a majority of operating systems.
âš NOTE: These operations make destructive changes to the cloud server’s file system. You can lose data if you make a mistake following these directions. Make a snapshot of the server before performing any of these steps. If your data is critical, please test the snapshot before proceeding. Deploy a new test instance with the snapshot, then verify the test instance boots and has the correct data.
startx
at the root prompt.Before making changes, check the partition for errors. Right-click on the partition and select Check, which adds the operation to the pending queue.
To run the check, click the Apply All Operations icon in the toolbar. Click Apply on the pop-up confirmation dialog.
Right-click on the partition you want to modify. Choose Resize/Move.
Adjust the partition by dragging the size handles, or adjust the size fields, then click Resize/Move, which adds the operation to the pending queue. Next, click the Apply All Operations icon to resize the partition.
Right-click an unallocated area and choose New.
Enter the partition information, then click Add to add the operation to the pending queue. Next, click the Apply All Operations icon to resize the partition.
When all operations are complete, detach the ISO and reboot the server. Navigate to the server information page and click Remove ISO.
If you added or removed partitions, you may need to adjust the mount points in /etc/fstab
. Refer to the fstab documentation or the documentation specific to your distribution.
NixOS (Nix Operating System) is a Linux distribution with a powerful configuration and package manager. It comprises the Nix package management utility that runs on top of the NixOS operating system.
The main command for installing and managing packages is nix-env
. It allows root and non-root users to install, upgrade and uninstall packages. It also allows users to view installed packages, roll back and switch between different generations.
Packages installed by root users are available to everyone. However, packages installed by non-root users are only available in their profiles and not accessible by others.
This article guides you on how to install, upgrade and remove packages. It also shows you how to switch between different configurations and how to delete unused packages and generations completely.
Log in to your computer as root. If using a virtual computer, connect with SSH as a root user.
To install a package, use the following syntax.
# nix-env -iA [package_location.package_name]
For example, to install the Hello package from the nixos
repository, run
# nix-env -iA nixos.hello
Adding the A
ensures that the nix-env
command evaluates only the attributes you enter, hence a faster and more resource-efficient execution. For most Nixos packages, the default package_location
is nixos
, but there are other locations, such as github
, and so on.
You can install multiple packages with one command using the syntax:
# nix-env -iA nixos.[package1] nixos.[package2] nixos.[package3] nixos.[package4]
For example, to install git, zip, file, and nodejs, run:
# nix-env -iA nixos.git nixos.python nixos.zip nixos.file nixos.nodejs
Syntax
# nix-env -iA nixos.[package_name&version]
For example, to install Python3, run;
# nix-env -iA nixos.python3
To view the list of all the installed packages and their versions, run:
# nix-env --query --installed or $ `nix-env --query "*"
For example,
# nix-env --query --installed
Output
file-5.41
git-2.36.0
hello-2.12
nodejs-16.16.0
python-2.7.18
python-3.9.13
zip-3.0
Update the NixOS channel first and then upgrade the installed packages.
# nix-channel --update
To upgrade the packages, run:
# nix-env --upgrade
Where applicable, the command upgrades all packages with the newest versions unless specified. To upgrade a specific package, use the syntax:
# nix-env --upgrade -A nixos.[package_name]
For example, to upgrade the python package only, run:
# nix-env --upgrade -A nixos.python
To remove a package, use the syntax:
# nix-env -e [package_name]
For example, to remove the zip package, run:
# nix-env -e zip
Output
uninstalling 'zip-3.0'
building '/nix/store/fac48nwh31h7lwnpw3xsb7ba7zmvb85h-user-environment.drv'...`
The above command removes the specified package. Similarly, you can uninstall a specific version of a package when you have multiple versions installed.
To find out if you have multiple versions of a particular package, run the query command.
# nix-env --query --installed
output
file-5.41
git-2.36.0
hello-2.12
nodejs-16.16.0
python-2.7.18
python3-3.8.13`
The output lists the packages and their versions. For example, the above list shows that the system has python versions 2 and 3. To remove version 3, run
# nix-env -e python3
If you want to remove multiple selected packages, use the syntax:
#nix-env -e [package1_name] [package2_name] [package3_name]
For example, run the following command to remove git, nodejs, and python.
# nix-env -e git nodejs python
You can also remove all the packages by using the wildcard.
#$ nix-env -e "*"
Upgrading a package to a newer version does not overwrite the files for the older version. The process retains the old files and makes them available in case there is a need for a rollback. If the upgrade does not work, you can revert to the older version using the rollback command. Similarly, if you delete a package, you can restore it using the rollback feature.
# nix-env --rollback
The rollback reverses the changes and switches the configuration to an earlier state, provided you have not performed the garbage collection.
For example, if you uninstall zip and install Python3, you can roll back and undo the changes. The following shows the installed packages.
# nix-env --query --installed
file-5.41
git-2.36.0
hello-2.12
nodejs-16.16.0
python-2.7.18
python-3.8.13
Rolling back the uninstall zip/install python3 operations requires two steps.
1st rollback
# nix-env --rollback
Output
switching profile from version 7 to 6
The rollback removes python3, which is the most recently installed package.
Listing the installed packages returns the output below.
# nix-env --query --installed
Output
file-5.41
git-2.36.0
hello-2.12
nodejs-16.16.0
python-2.7.18`
Please note that python3 is missing from the list.
2nd rollback
# nix-env --rollback
output
switching profile from version 6 to 5
The command restores the Zip package removed before installing Python3.
To confirm the restoration, list the installed packages again.
# nix-env --query --installed
Output
file-5.41
git-2.36.0
hello-2.12
nodejs-16.16.0
python-2.7.18
zip-3.0
While rollback allows you to change the configuration to older states, you can use the switch
command to move backward or forward to a specific generation. For example, the last rollback switched to generation 5. To move back to generation 8, the most recent, use the command.
You can find the available generations by running:
# nix-env --list-generations
Output
1 2022-08-30 13:29:14
2 2022-08-30 13:29:35
3 2022-08-30 13:32:07
4 2022-08-30 13:32:46
5 2022-08-30 13:35:20 (current)
6 2022-08-30 13:36:35
7 2022-08-30 13:44:12
8 2022-08-30 13:59:25
To switch to a different configuration, use the syntax:
# nix-env --switch-generation [generation_number]
For example, to switch to generation 8, run:
# nix-env --switch-generation 8
Uninstalling a package does not delete the files from storage. It retains the files for other user profiles or a rollback if the newer version malfunctions. The files can occupy a significant part of the storage device, and you may want to completely and safely remove them if you do not foresee the need for a rollback.
Run the garbage collector to completely remove all uninstalled packages, files, and generations not in use by any running application or user profile.
To safely remove the unused generations, packages, and files for all users, use the garbage collection command.
# nix-collect-garbage -d
You cannot roll back configurations or switch to another generation if you perform garbage collection.
NixOS is a lightweight package manager that allows users to install, uninstall and manage packages with and without root access. To learn more about its features and capabilities, check the NixOS online manual.
]]>Update the system.
sudo apt-get update
sudo apt-get dist-upgrade
Install proftpd
.
sudo apt-get install proftpd
During installation, you will be asked if you want to install in inetd
or standalone
mode. Choose the standalone
mode.
Open the Proftpd configuration file.
sudo nano /etc/proftpd/proftpd.conf
The file will resemble the following text.
#
# /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.
# To really apply changes, reload proftpd after modifications, if
# it runs in daemon mode. It is not required in inetd/xinetd mode.
#
# Includes DSO modules
Include /etc/proftpd/modules.conf
# Set off to disable IPv6 support which is annoying on IPv4 only boxes.
UseIPv6 on
# If set on you can experience a longer connection delay in many cases.
IdentLookups off
ServerName "Debian"
ServerType standalone
DeferWelcome off
MultilineRFC2228 on
DefaultServer on
ShowSymlinks on
TimeoutNoTransfer 600
TimeoutStalled 600
TimeoutIdle 1200
DisplayLogin welcome.msg
DisplayChdir .message true
ListOptions "-l"
DenyFilter \*.*/
# Use this to jail all users in their homes
# DefaultRoot ~
# Users require a valid shell listed in /etc/shells to login.
# Use this directive to release that constrain.
RequireValidShell off
# Port 21 is the standard FTP port.
Port 21
...
ServerName
: Specifies the name of the FTP server. This name will be displayed when clients connect to the server.TimeoutIdle
: The time, in seconds, after which a client is automatically disconnected if it is no longer active on the FTP server.DefaultRoot
: Controls the default root directory assigned to a user upon login.Port
: The connection port to the FTP server. Almost all of the time this port is 21
and you should not have to change it unless you are blocked by a firewall.PassivePorts
: Restricts the range of ports from which the server will select when sent the PASV
command from a client.MaxInstances
: The maximum number of simultaneous connections you want to allow on your FTP server.Now, we have to activate the DefaultRoot
option. to do this, find the DefaultRoot
commented line and uncomment it.
DefaultRoot ~
The value ~
means that the user will be limited to the personal folder (e.g /home/user12
).
Note: By default, someone who connects to the FTP server can access all of the server folders, so it’s recommended to enable the option DefaultRoot
.
Change the ServerName
.
ServerName : the name of your FTP server
Find and uncomment the following lines (removing the #
at the beginning of each line) to allow anonymous connections to your server.
# A basic anonymous configuration, no upload directories.
<Anonymous ~ftp>
User ftp
Group nogroup
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Cosmetic changes, all files belongs to ftp user
DirFakeUser on ftp
DirFakeGroup on ftp
RequireValidShell off
# Limit the maximum number of anonymous logins
MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayFirstChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Directory *>
<Limit WRITE>
DenyAll
</Limit>
</Directory>
</Anonymous>
Note: If you enable anonymous connections on your FTP server, any user can connect to it. They will have access to the /home/ftp
directory and will be able to read and download files, but not modify or add files.
You can forbid the root user from accessing FTP by adding the following line.
RootLogin off
After the configuration has been changed, restart the server.
sudo service proftpd restart
Note: If an error line is displayed as “unable to resolve host”, be aware that it does not matter and you can ignore it.
Add a user, for example, “myuser
“.
useradd --shell /bin/false myuser
Create the home directory of our user “myuser
“.
mkdir /home/myuser
Change the ownership of that directory to the user and group “myuser
“.
chown myuser:myuser /home/myuser/
Set a password for the user “myuser
“.
passwd myuser
]]>