One place for hosting & domains


      How To Install WordPress with OpenLiteSpeed on Ubuntu 18.04


      WordPress is an open-source content management system (CMS). The most popular CMS in the world, WordPress allows you to set up blogs and websites on top of a MySQL database backend, using PHP to execute scripts and process dynamic content.

      OpenLiteSpeed is an optimized open-source web server that you can use to manage and serve websites. OpenLiteSpeed has some useful features that make it a solid choice for many installations: Apache-compatible rewrite rules, a built-in web-based administration interface, and customized PHP processing optimized for the server.

      This guide will walk through the process of installing and setting up a WordPress instance on Ubuntu 18.04 using the OpenLiteSpeed web server. Because both WordPress and OpenLiteSpeed can be administered through a web browser, this configuration is ideal for those who do not have regular access to an SSH session or those who may not feel comfortable managing a web server via the command line.


      Before you begin this guide, you will need the following:

      Step 1 — Creating a Database and Database User for WordPress

      WordPress uses MySQL to manage and store site and user information. You already have MySQL installed, but as a preparatory step you need to make a database and a user for WordPress to use.

      To get started, connect to your server using SSH:

      Then log in to the root MySQL account:

      Note: If you completed Step 3 in the prerequisite MySQL tutorial and configured your root MySQL user to authenticate with the mysql_native_password plugin, you’ll need to log in with the following command:

      Then enter your root user’s password when prompted.

      From the MySQL prompt, create a database with the following command. Here, we will name this database wordpress to keep things simple, but you can name it whatever you’d like:

      • CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

      Then, create a user and grant it privileges over the database you just created. Again, you can give this user any name, but for simplicity we will name it wordpressuser. Also, be sure to change password to a strong password of your own choosing:

      • GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

      Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes into effect:

      Following that, you can close the MySQL prompt:

      You’re done setting up your MySQL installation to work with WordPress. Next, we will install a few PHP extensions.

      Step 2 — Installing Additional PHP Extensions

      In the prerequisite OpenLiteSpeed tutorial, you installed the lsphp73 package. This is a compilation of PHP optimized for OpenLiteSpeed which uses the LiteSpeed SAPI to communicate with external applications. Depending on your needs, WordPress may require other certain PHP extensions in order to function as desired.

      To install some PHP extensions commonly used with WordPress, run the following command:

      • sudo apt install lsphp73-common lsphp73-curl lsphp73-imagick lsphp73-imap lsphp73-json lsphp73-memcached lsphp73-mysql lsphp73-opcache lsphp73-redis

      Note: The packages in this command may not cover every use case. For a full list of the PHP 7.3 extensions available from the LiteSpeed repository you added to your server in the prerequisite tutorial, see the LiteSpeed Wiki.

      Following this, you can move on to downloading and setting up WordPress on your server.

      Step 3 — Downloading WordPress

      Now that your server software is configured, you can install and set up WordPress. For security reasons in particular, it is always recommended that you get the latest version of WordPress directly from their site.

      Change into a writable directory and then download the compressed release by typing:

      • cd /tmp
      • curl -O

      Extract the compressed file to create the WordPress directory structure:

      We will move these files into our document root momentarily, but first we will create a few files and directories that the WordPress installation will depend on.

      OpenLiteSpeed supports .htaccess files. This is important for our purposes, since WordPress uses .htaccess files to create and manage permalinks.

      Add a dummy .htaccess file so that it will be available for WordPress to use later:

      • touch /tmp/wordpress/.htaccess

      Next, copy over the sample configuration file to the filename that WordPress actually reads:

      • cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

      Additionally, create the upgrade directory so that WordPress won’t run into permissions issues when trying to do this on its own following an update to its software:

      • mkdir /tmp/wordpress/wp-content/upgrade

      Then, copy the entire contents of the directory into your document root. OpenLiteSpeed comes with a default virtual host named Example located in the /usr/local/lsws/ directory. The document root for the Example virtual host is the html subdirectory:

      • sudo cp -a /tmp/wordpress/. /usr/local/lsws/Example/html/wordpress

      Notice that this command includes a dot at the end of the source directory to indicate that everything within the directory should be copied, including hidden files (like the .htaccess file you created):

      With that, you’ve successfully installed WordPress onto your web server and performed some of the initial configuration steps. Next, we’ll go through some further configuration changes that will give WordPress the privileges it needs to function securely and access the MySQL database and user account you created previously.

      Step 4 — Configuring the WordPress Directory

      Before we can go through the web-based setup process for WordPress, we need to adjust some items in our WordPress directory.

      Start by giving ownership of all the files in the directory to the nobody user and the nogroup group, which the OpenLiteSpeed web server runs as by default. The following chown command will grant OpenLiteSpeed the ability to read and write files in the wordpress directory, allowing it to serve the website and perform automatic updates:

      • sudo chown -R nobody:nogroup /usr/local/lsws/Example/html/wordpress

      Next run two find commands to set the correct permissions on the WordPress directories and files:

      • sudo find /usr/local/lsws/Example/html/wordpress/ -type d -exec chmod 750 {} ;
      • sudo find /usr/local/lsws/Example/html/wordpress/ -type f -exec chmod 640 {} ;

      These should be a reasonable permissions set to start with, although some plugins and procedures might require additional tweaks.

      Following this, you will need to make some changes to the main WordPress configuration file.

      When you open the file, your first objective will be to adjust some secret keys to provide some security for your installation. WordPress provides a secure generator for these values so that you do not have to try to come up with good values on your own. These are only used internally, so it doesn’t hurt usability to have complex, secure values here.

      To grab secure values from the WordPress secret key generator, type:

      • curl -s

      You will get back unique values that look something like this:

      Warning! It is important that you request unique values each time. Do NOT copy the values shown below!


      define('AUTH_KEY', '1jl/vqfs<XhdXoAPz9 DO NOT COPY THESE VALUES c_j{iwqD^<+c9.k<J@4H'); define('SECURE_AUTH_KEY', 'E2N-h2]Dcvp+aS/p7X DO NOT COPY THESE VALUES {Ka(f;rv?Pxf})CgLi-3'); define('LOGGED_IN_KEY', 'W(50,{W^,OPB%PB<JF DO NOT COPY THESE VALUES 2;y&,2m%3]R6DUth[;88'); define('NONCE_KEY', 'll,4UC)7ua+8<!4VM+ DO NOT COPY THESE VALUES #`DXF+[$atzM7 o^-C7g'); define('AUTH_SALT', 'koMrurzOA+|L_lG}kf DO NOT COPY THESE VALUES 07VC*Lj*lD&?3w!BT#-'); define('SECURE_AUTH_SALT', 'p32*p,]z%LZ+pAu:VY DO NOT COPY THESE VALUES C-?y+K0DK_+F|0h{!_xY'); define('LOGGED_IN_SALT', 'i^/G2W7!-1H2OQ+t$3 DO NOT COPY THESE VALUES t6**bRVFSD[Hi])-qS`|'); define('NONCE_SALT', 'Q6]U:K?j4L%Z]}h^q7 DO NOT COPY THESE VALUES 1% ^qUswWgn+6&xqHN&%');

      These are configuration lines that you will paste directly into your configuration file to set secure keys. Copy the output you received to your clipboard, and then open the WordPress configuration file located in your document root:

      • sudo nano /usr/local/lsws/Example/html/wordpress/wp-config.php

      Find the section that contains the dummy values for those settings. It will look something like this:


      . . .
      define('AUTH_KEY',         'put your unique phrase here');
      define('SECURE_AUTH_KEY',  'put your unique phrase here');
      define('LOGGED_IN_KEY',    'put your unique phrase here');
      define('NONCE_KEY',        'put your unique phrase here');
      define('AUTH_SALT',        'put your unique phrase here');
      define('SECURE_AUTH_SALT', 'put your unique phrase here');
      define('LOGGED_IN_SALT',   'put your unique phrase here');
      define('NONCE_SALT',       'put your unique phrase here');
      . . .

      Delete these lines and paste in the values you copied from the command line:


      . . .
      . . .

      Next, modify the database connection settings at the top of the file. You need to adjust the database name, database user, and the associated password that you configured within MySQL.

      The other change you must make is to set the method that WordPress should use to write to the filesystem. Since we’ve given the web server permission to write where it needs to, we can explicitly set the filesystem method to direct. Failure to set this with our current settings would result in WordPress prompting for FTP credentials when you perform certain actions.

      This setting can be added below the database connection settings, or anywhere else in the file:


      . . .
      define('DB_NAME', 'wordpress');
      /** MySQL database username */
      define('DB_USER', 'wordpressuser');
      /** MySQL database password */
      define('DB_PASSWORD', 'password');
      . . .
      define('FS_METHOD', 'direct');

      Save and close the file when you are finished.

      At this point, WordPress is not quite fully configured on your system, as you still need to apply a few finishing touches before you can start publishing content. In order to do that, though, you’ll first need to make a few configuration changes to your OpenLiteSpeed installation.

      Step 6 — Configuring OpenLiteSpeed

      Currently, you have WordPress installed on your Ubuntu server, but your OpenLiteSpeed installation hasn’t yet been configured to serve it. In this step, we’ll access the OpenLiteSpeed administrative interface and make a few changes to your server’s configuration.

      In your preferred web browser, navigate to the OpenLiteSpeed administrative interface. You can find this by entering your server’s public IP address or the domain name associated with it, followed by :7080, in your browser’s address bar:


      There, you will be presented with a login screen. Enter the username and password you defined in the prerequisite OpenLiteSpeed installation tutorial:

      OpenLiteSpeed login screen

      From the OpenLiteSpeed console, find and click on Server Configuration in the left-hand sidebar menu. Then navigate to the External App tab, find the row of the LiteSpeed SAPI App, and click on its Edit button:

      Server Configuration page

      Recall that in the prerequisite OpenLiteSpeed tutorial, you installed the lsphp73 package, a compilation of PHP optimized to work with OpenLiteSpeed through the LiteSpeed SAPI. However, the default settings in the External App page point to lsphp rather than lsphp73. Because of this, your OpenLiteSpeed installation won’t be able to correctly execute PHP scripts.

      To correct this, change the Name field to lsphp73, change the Address field to uds://tmp/lshttpd/lsphp73.sock, and change the Command field to read $SERVER_ROOT/lsphp73/bin/lsphp:

      External App changes

      After making those changes, click on the Save icon in the upper right-hand corner of the LiteSpeed SAPI App box.

      Next, click on Virtual Hosts in the left-hand menu. On the Virtual Hosts page, find the virtual host you plan to use and click on its View icon. Here, we’ll use the default Example virtual host:

      Virtual Hosts page

      Navigate to the virtual host’s General tab. There, find the General section, and click on its Edit button:

      Virtual Hosts General tab

      OpenLiteSpeed looks at the contents of the Document Root field for content to serve. Because all of your WordPress content and files are stored in the wordpress directory you created earlier, update the Document Root field to point to that directory. To do this, all you need to do is append wordpress/ to the end of the default value:

      Virtual Hosts General changes

      Click the Save icon to save this change.

      Next, you need to enable index.php files so that they can be used to process requests that aren’t handled by static files. This will allow the main logic of WordPress to function correctly.

      While still in the General tab, scroll down to find the Index Files section and click on its Edit icon:

      Virtual hosts Index Files page

      In the Index Files field, precede index.html with index.php,. By putting index.php before index.html, you’re allowing PHP index files to take precedence. After updating this field, it will look like this:

      Virtual Hosts index files changes

      Be sure to click the Save icon before continuing.

      Next, navigate to the virtual host’s Rewrite tab. Find the Rewrite Control section and press the Edit button:

      Virtual Hosts Rewrite page

      Set both the Enable Rewrite and Auto Load from .htaccess options to Yes by clicking the respective radial buttons. Configuring rewrite instructions in this fashion will allow you to use permalinks within your WordPress installation:

      Virtual Hosts rewrite changes

      Click the Save icon after making those changes.

      The default virtual host that is included with the OpenLiteSpeed installation includes some password protected areas to showcase OpenLiteSpeed’s user authentication features. WordPress includes its own authentication mechanisms and we will not be using the file-based authentication included in OpenLiteSpeed. We should get rid of these in order to minimize the stray configuration fragments active on our WordPress installation.

      First, click on the Security tab, and then click the Delete button next to SampleProtectedArea within the Realms List table:

      OpenLiteSpeed security realm list

      You will be asked to confirm the deletion. Click Delete to proceed.

      Next, click on the Context tab. In the Context List, delete the /protected/ context that was associated with the security realm you just deleted:

      OpenLiteSpeed delete protected context

      Again, you will have to confirm the deletion by clicking Delete.

      You can safely delete any or all of the other contexts as well using the same technique, as we will not be needing them. We specifically deleted the /protected/ context because otherwise an error would be produced due to the deletion of its associated security realm (which we just removed in the Security tab).

      Following that, press the green Graceful Restart icon in the upper-right corner of the OpenLiteSpeed console. This will restart the OpenLiteSpeed server, causing the changes you’ve made to go into effect:

      Graceful Restart icon location

      With that, your OpenLiteSpeed server is fully configured. You’re ready to finish setting up WordPress in your browser.

      Step 7 — Completing the Installation through the WordPress Interface

      Now that the server configuration is complete, we can complete the installation through the web interface.

      In your web browser, navigate to your server’s domain name or public IP address:


      Select the language you would like to use:

      WordPress language selection

      Next, you will come to the main setup page. Select a name for your WordPress site and choose a username (it is recommended not to choose something like “admin” for security purposes). A strong password is generated automatically. Save this password or select an alternative strong password.

      Enter your email address and select whether you want to discourage search engines from indexing your site:

      WordPress setup installation

      When ready, click the Install WordPress button. You’ll be taken to a page that prompts you to log in:

      WordPress login prompt

      Once you log in, you will be taken to the WordPress administration dashboard:

      WordPress login prompt

      From the dashboard, you can begin making changes to your site’s theme and publishing content.


      By completing this guide, you installed and configured a WordPress instance on Ubuntu 18.04 server running OpenLiteSpeed. Some common next steps are to choose the permalinks setting for your posts (which can be found in Settings > Permalinks) or to select a new theme (in Appearance > Themes). If this is your first time using WordPress, explore the interface a bit to get acquainted with your new CMS.

      To enhance your new WordPress site’s security, we recommend that you configure it to function with SSL so it can serve content over HTTPS. Check out this tutorial from the OpenLiteSpeed documentation to install LetsEncrypt and set this up.

      Source link

      How To Install the OpenLiteSpeed Web Server on Ubuntu 18.04


      OpenLiteSpeed is an optimized open source web server that can be used to manage and serve sites. OpenLiteSpeed has some useful features that make it a solid choice for many installations: it features Apache-compatible rewrite rules, a built-in web-based administration interface, and customized PHP processing optimized for the server.

      In this guide, we’ll demonstrate how to install and configure OpenLiteSpeed on an Ubuntu 18.04 server.


      To complete this tutorial you will need an Ubuntu 18.04 server with a sudo-enabled, non-root user and the ufw firewall enabled.

      Please refer to our Initial Server Setup with Ubuntu 18.04 tutorial for instructions on fulfilling these requirements.

      Step 1 – Installing OpenLiteSpeed

      OpenLiteSpeed provides a software repository we can use to download and install the server with Ubuntu’s standard apt command.

      To enable this repository for your Ubuntu system, first download and add the developer’s software signing key:

      • wget -qO - | sudo apt-key add -

      This key is used to cryptographically verify that nobody has tampered with the software we’re about to download.

      Next, we add the repository information to our system:

      • sudo add-apt-repository 'deb bionic main'

      After the repository has been added, the add-apt-repository command will refresh our package cache and the new software will be available to install.

      Install the OpenLiteSpeed server and its PHP processor using apt install:

      • sudo apt install openlitespeed lsphp73

      Finally, create a soft link to the PHP processor we just installed. This directs the OpenLiteSpeed server to use the correct version:

      • sudo ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5

      Now that the OpenLiteSpeed server is installed, we’ll secure it by updating the default admin account.

      Step 2 – Setting the Administrative Password

      Before we test the server, we should set a new administrative password for OpenLiteSpeed. By default, the password is set to 123456, so we should change this immediately. We can do this by running a script provided by OpenLiteSpeed:

      • sudo /usr/local/lsws/admin/misc/

      You will be asked to provide a username for the administrative user. If you press ENTER without choosing a new username, the default of admin will be used. Then, you will be prompted to create and confirm a new password for the account. Do so, then hit ENTER one last time. The script will confirm a successful update:


      Administrator's username/password is updated successfully!

      Now that we’ve secured the admin account, let’s test out the server and make sure it’s running properly.

      Step 3 – Starting and Connecting to the Server

      OpenLiteSpeed should have started automatically after it was installed. We can verify this using the lswsctrl command:

      • sudo /usr/local/lsws/bin/lswsctrl status


      litespeed is running with PID 990.

      If you don’t see a similar message, you can start the server using lswsctrl:

      • sudo /usr/local/lsws/bin/lswsctrl start


      [OK] litespeed: pid=5137.

      The server should now be running. Before we can visit it in our browser, we need to open up some ports on our firewall. We’ll do this with the ufw command:

      • sudo ufw allow 8088
      • sudo ufw allow 7080

      The first port, 8088, is the default port for OpenLiteSpeed’s example site. It should now be accessible to the public. In your web browser, navigate to your server’s domain name or IP address, followed by :8088 to specify the port:


      Your browser should load the default OpenLiteSpeed web page, which looks like this:

      screenshot of the default OpenLiteSpeed demo page

      The links towards the bottom of the page are designed to demonstrate various features of the server. If you click through them you will notice that these features are already installed and properly configured. For instance, an example CGI script is available, a customized PHP instance is up and running, and custom error pages and authentication gates are configured. Click around to explore a little.

      When you are satisfied with the default site, you can move on to the administrative interface. In your web browser, using HTTPS, navigate to your server’s domain name or IP address followed by :7080 to specify the port:


      You will likely see a page warning you that the SSL certificate from the server cannot be validated. Since this is a self-signed certificate, this is expected. Click through the available options to proceed to the site. In Chrome, you must click “Advanced” and then “Proceed to…”.

      You will be prompted to enter the administrative username and password that you selected with the script in the previous step:

      screenshot of the OpenLiteSpeed admin login page

      Once you correctly authenticate, you will be presented with the OpenLiteSpeed administration interface:

      screenshot of the OpenLiteSpeed admin dashboard

      This is where the majority of your configuration for the web server will take place.

      Next, we’ll explore this interface by walking through a common configuration task: updating the port used by the default page.

      Step 4 – Changing the Port for the Default Page

      To demonstrate how to configure options through the web interface, we will change the port that the default site uses from 8088 to the conventional HTTP port 80.

      To accomplish this, first click Listeners in the list of options on the left side of the interface. A list of all available listeners will load.

      In the list of listeners, click the “View/Edit” button for the Default listener:

      screenshot of OpenLiteSpeed's listeners summary page

      This will load a page with more details about the Default listener. Click the edit button in the top-right corner of the “Address Settings” table to modify its values:

      screenshot of OpenLiteSpeed's listener detail page

      On the next screen, change port 8088 to port 80, then click the floppy disk icon, Save:

      screenshot of OpenLiteSpeed's listener update interface

      After the modification, you will need to restart the server. Click the “reload” arrow icon to restart OpenLiteSpeed:

      graceful restart button

      Additionally, you’ll need to now open up port 80 on your firewall:

      The default web page should now be accessible in your browser on port 80 instead of port 8088. Visiting your server’s domain name or IP address without providing any port number will now display the site.


      OpenLiteSpeed is a fully-featured web server that is primarily managed through the administrative web interface. A full run through of how to configure your site through this interface is outside of the scope of this guide.

      However, to get you started, we’ll touch on a few important points below:

      • Everything associated with OpenLiteSpeed will be found under the /usr/local/lsws directory.
      • The document root (where your files will be served from) for the default virtual host is located at /usr/local/lsws/DEFAULT/html. The configuration and logs for this virtual host can be found under the /usr/local/lsws/DEFAULT directory.
      • You can create new virtual hosts for different sites using the admin interface. However, all of the directories that you will reference when setting up your configuration must be created ahead of time on your server. OpenLiteSpeed is not able to create the directories
      • You can set up virtual host templates for virtual hosts that share the same general format.
      • Often, it is easiest to copy the default virtual host’s directory structure and configuration to use as a starting point for new configurations.
      • The admin interface has a built-in tooltip help system for almost all fields. There is also a Help menu option in the left-hand menu that links to the server documentation. Consult these sources of information during configuration if you need more help.
      • To secure your OpenLiteSpeed installation with HTTPS, see the officall documentation’s section on SSL Setup

      At this point, you should have OpenLiteSpeed and PHP installed and running on an Ubuntu 18.04 server. OpenLiteSpeed offers great performance, a web-based configuration interface, and pre-configured options for script handling.

      Source link