diff --git a/source/clear-linux/tutorials/web-server-install/web-server-install.rst b/source/clear-linux/tutorials/web-server-install/web-server-install.rst index 87f48ea1..8799e206 100644 --- a/source/clear-linux/tutorials/web-server-install/web-server-install.rst +++ b/source/clear-linux/tutorials/web-server-install/web-server-install.rst @@ -1,41 +1,39 @@ .. _web-server-install: -Creating a Clear Linux based web server +Create a Clear Linux based web server ####################################### -Prerequisites -************* +This tutorial guides you through creating a LAMP server as part of setting up a Clear Linux-based web server. It details how to install and configure each LAMP server component and then create an initial WordPress MySQL database. -In order to create a web server using |CL| as the host OS your host -system must be running |CL|. Therefore, this tutorial assumes you have -already gone through the :ref:`bare metal installation` -instructions. +In order to create a web server using |CL| as the host OS, your host +system must be running |CL|. This tutorial assumes you have +successfully installed :ref:`Clear Linux on bare metal`. -Before installing any new packages, update the |CL| OS with the -console command: +Before you install new packages, update the |CL| OS with the following console command: -.. code-block:: console +.. code-block:: bash sudo swupd update -Creating a LAMP Server +Create a LAMP Server ********************** -A server with Linux\*, Apache\*, MySQL\*, and PHP\* installed is known as a -LAMP server, allows you to set up a fully functional web server, and enables -you to host your own website. This tutorial walks you through the process of -creating a LAMP server by installing and configuring each component. In place -of MySQL, we will be installing MariaDB which is a drop- in replacement for -MySQL. Once the LAMP server component installations are complete, we add -phpMyAdmin to manage your MariaDB databases. +A LAMP server uses Linux\*, Apache\*, MySQL\*, and PHP\* to set up a fully functional web server and host a website. Note that this tutorial installs MariaDB, which is a drop- in replacement for MySQL. -Installing Apache +This tutorial follows these steps: + +1. Install Apache. +2. Change the default configuration and data directory. +3. Install PHP. +4. Install MariaDB. +5. Install phpMyAdmin. +6. Set up a WordPress database. + +Install Apache ***************** -Apache is an open source HTTP web server application. It can run on several -operating systems, including |CL|. Alternatively, you could install -NGINX but this tutorial focuses on implementing an Apache server. -Go to https://httpd.apache.org/ to learn more about it. +Apache is an open source HTTP web server application that can run on several +operating systems, including |CL|. Go to https://httpd.apache.org/ for more information. Install the web-server-basic bundle =================================== @@ -45,47 +43,45 @@ Apache software bundle on |CL|. To install the bundle, enter the following command: -.. code-block:: console +.. code-block:: bash sudo swupd bundle-add web-server-basic To start the Apache service, enter the following commands: -.. code-block:: console +.. code-block:: bash sudo systemctl enable httpd.service sudo systemctl start httpd.service -To verify that the Apache server application is running, go to your web +To verify that the Apache server application is running, open a web browser and navigate to: http://localhost -If the service is running you will see the message "This web server is -operational from host." on your browser as shown in figure 1. +If the service is running, a confirmation message appears, as shown in figure 1. .. figure:: figures/web-server-install-1.png :alt: This web server is operational from host. :scale: 50% - Confirmation the Apache service is running. + Figure 1: Confirmation that the Apache service is running. -The :file:`index.html` file is located in the :file:`/var/www/html` +Note that the :file:`index.html` file is located in the :file:`/var/www/html` directory of your host system. We will copy this file into a new location -after we modify the configuration. +after we modify the configuration in the next step. Change the default configuration and data directory *************************************************** -|CL| is designed to be a stateless operating system which means that you will -need to create an optional configuration file to make changes over the default +|CL| is designed to be a stateless operating system which means that you must create an optional configuration file to make changes over the default values. The default location of the Apache configuration file, :file:`httpd.conf`, is located in the :file:`/usr/share/defaults/httpd` -directory. |CL| can overwritte this directory as part of the stateless +directory. |CL| can overwrite this directory as part of the stateless paradigm. This default :file:`.conf` file includes the following directives that allow for additional locations of configuration definitions: -.. code-block:: console +.. code-block:: bash # Virtual hosts IncludeOptional /usr/share/defaults/httpd/conf.d/*.conf @@ -93,14 +89,16 @@ that allow for additional locations of configuration definitions: IncludeOptional /etc/httpd/conf.d/*.conf IncludeOptional /etc/httpd/conf.modules.d/*.conf -For this tutorial, we will create the directory structure for :file:`/etc/httpd/conf.d` -and then create the :file:`httpd.conf` file within :file:`/etc/httpd/conf.d` directory and -include the variable ``DocumentRoot``. +For this tutorial, we will perform the following: -Using your favorite editor, copy the content listed below into the new file +1. Create the directory structure for :file:`/etc/httpd/conf.d` +2. Create the :file:`httpd.conf` file within :file:`/etc/httpd/conf.d` directory +3. Add the ``DocumentRoot`` variable to :file:`httpd.conf`. + +From a text editor, copy the content listed below into the new file :file:`/etc/httpd/conf.d/httpd.conf`. -.. code-block:: console +.. code-block:: bash # # Set a new location for DocumentRoot @@ -116,79 +114,76 @@ Using your favorite editor, copy the content listed below into the new file -Finally, let’s create the new ``DocumentRoot`` directory structure and copy the +Create a new ``DocumentRoot`` directory structure and copy the :file:`index.html` file from :file:`/var/www/html` directory to :file:`/var/www/tutorial`. -.. code-block:: console +.. code-block:: bash sudo mkdir –p /var/www/tutorial cd /var/www/tutorial sudo cp /var/www/html/index.html . -To make sure that we have everything set correctly, let’s edit the new -:file:`index.html` file with your editor and change the text from -"This web server is operational from host." to -"This web server is operational from its new location.". +To ensure a successful setup, edit the new +:file:`index.html` file. From a text editor, change the original text,"This web server is operational from host." to "This web server is operational from its new location." -With the new configuration files in place, you will need to stop and then -restart the ``httpd.service``. +Stop and then restart the ``httpd.service``. -.. code-block:: console +.. code-block:: bash sudo systemctl stop httpd.service sudo systemctl start httpd.service -Now when you go to http://localhost you should see your new screen. +Go to http://localhost to view the new screen. To continue, we must change the configuration back to the default :file:`/var/www/html` location. To do this, edit the :file:`/etc/httpd/conf.d/httpd.conf` file again and replace any instance of /var/www/tutorial with /var/www/html. -Then, stop and then restart the ``httpd.service``. +Stop and then restart ``httpd.service``. -.. code-block:: console +.. code-block:: bash sudo systemctl stop httpd.service sudo systemctl start httpd.service -On http://localhost, you should see the default screen again. +Go to http://localhost and verify that you can see the default screen again. -Optionally, remove the /var/www/tutorial directory previously created. +Optionally, remove the /var/www/tutorial directory you previously created. -.. code-block:: console +.. code-block:: bash sudo rm /var/www/tutorial/index.html sudo rmdir /var/www/tutorial -Installing PHP +Install PHP ************** -With Apache installed, you can display static web pages. However, enabling -PHP allows dynamic webpages to be generated and displayed. To add this -functionality to your web server we need to install PHP on your system. +An Apache installation allows you to display static web pages. Enabling +PHP allows you to generate and display dynamic web pages. To add this +functionality to your web server, install PHP on your system. To get the php components, enter the following command: -.. code-block:: console +.. code-block:: bash sudo swupd bundle-add php-basic To enable PHP, enter the following commands: -.. code-block:: console +.. code-block:: bash sudo systemctl enable php-fpm.service sudo systemctl start php-fpm.service sudo systemctl restart httpd.service -After restarting the Apache service, we can test our PHP installation. +After restarting the Apache service, test your PHP installation. 1. Create a file named :file:`phpinfo.php` in the - :file:`/var/www/html/` directory using your editor. + :file:`/var/www/html/` directory using a text editor. 2. Add the following line to the file: @@ -196,46 +191,43 @@ After restarting the Apache service, we can test our PHP installation. -3. Go to http://localhost/phpinfo.php using your browser. +3. Go to http://localhost/phpinfo.php. - The PHP information screen should appear, see figure 2: + Verify that the PHP information screen appears, as shown in figure 2: .. figure:: figures/web-server-install-2.png :alt: PHP information screen :width: 600 - The PHP information screen. + Figure 2: The PHP information screen. -If the PHP information screen is displayed, you have successfully installed -the PHP components and are now ready to add your database application to -complete your LAMP server implementation. +The PHP components are successfully installed. -Installing MariaDB +Install MariaDB ****************** -Most web applications require a database to store their content. Therefore, -we must install MariaDB to fulfill this need. MariaDB is a drop-in +Install Maria DB to store content. MariaDB is a drop-in replacement for MySQL and is available in the database-basic |CL| bundle. To install the database-basic bundle, enter the following command: -.. code-block:: console +.. code-block:: bash sudo swupd bundle-add database-basic -Once MariaDB is installed, we need to start the service and check its status. +Once MariaDB is installed, start the service and check its status. To start MariaDB, enter the following commands: -.. code-block:: console +.. code-block:: bash sudo systemctl enable mariadb sudo systemctl start mariadb To check the status of MariaDB, enter the following command: -.. code-block:: console +.. code-block:: bash sudo systemctl status mariadb @@ -245,21 +237,21 @@ hardening. To add a basic layer of security, enter the following command and answer the questions presented: -.. code-block:: console +.. code-block:: bash mysql_secure_installation .. note:: We have included the answers after each question. -.. code-block:: console +.. code-block:: bash Enter current password for root (enter for none): -In order to secure the MariaDB, we need the current password for the root +In order to secure MariaDB, we need the current password for the root user. For a newly installed MariaDB without a set root password, the -password is blank. Just press enter to continue. +password is blank. Thus, press enter to continue. -.. code-block:: console +.. code-block:: bash OK, successfully used password, moving on... @@ -267,24 +259,23 @@ password is blank. Just press enter to continue. .. _set-password: -Setting the root password ensures nobody can log into the MariaDB -as a root user without the proper authorization. +Set the root password to prevent unauthorized MariaDB root user logins. To set a root password, type 'y'. -.. code-block:: console +.. code-block:: bash New password: Type the desired password for the root user. -.. code-block:: console +.. code-block:: bash Re-enter new password: Re-type the desired password for the root user. -.. code-block:: console +.. code-block:: bash Password updated successfully! Reloading privilege tables.. @@ -292,34 +283,34 @@ Re-type the desired password for the root user. Remove anonymous users? [Y/n] -By default, a MariaDB installation has an anonymous user allowing anyone to +By default, a MariaDB installation includes an anonymous user that allows anyone to log into MariaDB without a user account. This anonymous user is intended only -for testing and for a smoother the installation. +for testing and for a smoother installation. To remove the anonymous user and make your database more secure, type 'y'. -.. code-block:: console +.. code-block:: bash ... Success! Disallow root login remotely? [Y/n] Normally, root should only be allowed to connect from the 'localhost'. -This ensures that someone cannot guess at the root password from the network. +This ensures that someone cannot guess the root password from the network. To block any remote root login, type 'y'. -.. code-block:: console +.. code-block:: bash ... Success! Remove test database and access to it? [Y/n] -By default, MariaDB comes with a database named 'test' which anyone can +By default, MariaDB includes a database named 'test' which anyone can access. This database is also intended only for testing and should be removed. To remove the test database, type 'y'. -.. code-block:: console +.. code-block:: bash - Dropping test database... ... Success! @@ -332,7 +323,7 @@ immediately. To reload the privilege tables, type 'y'. -.. code-block:: console +.. code-block:: bash ... Success! @@ -346,10 +337,10 @@ To reload the privilege tables, type 'y'. The MariaDB installation is complete and we can now install phpMyAdmin to manage the databases. -Installing phpMyAdmin +Install phpMyAdmin ********************* -The web-based tool phpMyAdmin is a straight-forward way to manage MySQL or +The web-based tool phpMyAdmin is a straightforward way to manage MySQL or MariaDB databases. Visit https://www.phpmyadmin.net for the complete discussion regarding phpMyAdmin, its documentation, the latest downloads, and other useful information. @@ -364,7 +355,7 @@ our |CL| host system. .. note:: This example downloads and uses version 4.6.4. 2. Once the file has been successfully downloaded and verified, uncompress - the file and directories into the apache web server document root + the file and directories into the Apache web server document root directory. Use the following commands: .. code-block:: console @@ -380,35 +371,32 @@ our |CL| host system. sudo mv phpMyAdmin-4.6.4-english phpMyAdmin -Using phpMyAdmin to Manage Databases +Use phpMyAdmin to Manage Databases ==================================== -If you have successfully installed all of the components for your LAMP -server, you should be able to point your browser to -http://localhost/phpMyAdmin and see the screen shown in figure 3 in your -browser window. +To verify a successful installation of all LAMP server components, go to +http://localhost/phpMyAdmin. Confirm that the phpMyAdmin welcome screen appears, as shown in figure 3. .. figure:: figures/web-server-install-3.png :alt: phpMyAdmin login page :width: 600 - The `phpMyAdmin` login page after successful installation. + Figure 3: The `phpMyAdmin` login page. Log in with your root userid and the password you set up when you ran the :ref:`mysql_secure_installation command `. Enter your credentials and select :guilabel:`Go` to log in: -Once logged in the main phpMyAdmin page is displayed as shown on figure 4: +Once logged in the main phpMyAdmin page displays, as shown in figure 4: .. figure:: figures/web-server-install-4.png :alt: phpMyAdmin dashboard :width: 600 - The `phpMyAdmin` dashboard after successful login. + Figure 4: The `phpMyAdmin` dashboard. -Our next step is to set up our first database. For example, we can call -our new database WordPress. +Set up your first database called WordPress. Follow these steps: 1. Select the :guilabel:`Databases` tab in the phpMyAdmin main screen to go to the Databases page. Figure 5 shows the databases tab. @@ -417,17 +405,17 @@ our new database WordPress. :alt: Databases tab :width: 600 - The `Databases` tab of `phpMyAdmin`. + Figure 5: The `Databases` tab of `phpMyAdmin`. -2. Enter 'WordPress'. in the text field below the :guilabel:`Create database` +2. Enter 'WordPress' in the text field below the :guilabel:`Create database` label. -3. Pick the :guilabel:`utf8_unicode_ci` option from the collation drop-down +3. Select the :guilabel:`utf8_unicode_ci` option from the Collation drop-down menu beside the text field. -4. Press the :guilabel:`Create` button. +4. Click :guilabel:`Create`. -Once the database is created, we need to set up the user permissions. +Once the database is created, set up the user permissions. 1. Select the WordPress database in the left panel. @@ -438,18 +426,17 @@ Once the database is created, we need to set up the user permissions. :alt: Privileges tab :width: 600 - The `Privileges` tab of `phpMyAdmin` + Figure 6: The `Privileges` tab of `phpMyAdmin` -3. Click on :guilabel:`Add user account` +3. Click :guilabel:`Add user account` as shown in figure 7. .. figure:: figures/web-server-install-7.png :alt: User accounts tab :width: 600 - The `User accounts` tab showing all the required information entered - in the next steps. + Figure 7: The `User accounts` tab. -4. Enter the following information in the corresponding fields: +4. Enter the following information in the corresponding fields that appear in Figure 7 above: User name: wordpressuser @@ -457,10 +444,9 @@ Once the database is created, we need to set up the user permissions. Re-type: wp-example -5. In the Database for user account section, select the option - :guilabel:`Grant all privileges on database “WordPress”.` +5. In the 'Database for user account' section, select :guilabel:`Grant all privileges on database “WordPress”.` -6. At the bottom of the page and select :guilabel:`Go`. +6. At the bottom of the page, click :guilabel:`Go`. If successful, you should see the screen shown in figure 8: @@ -468,12 +454,12 @@ If successful, you should see the screen shown in figure 8: :alt: User added successfully :width: 600 - The user **wordpressuser** was added successfully. + Figure 8: The user **wordpressuser** was added successfully. Congratulations! You have now created a fully functional LAMP server along with a WordPress- ready database using |CL|. -As a next step, you could :ref:`create a WordPress server ` -and present it to the world. +Go to :ref:`Create a Clear Linux WordPress server ` +to complete the setup.