Install OLS, Mysql, Phpmyadmin, SSL, and Wordpress on Ubuntu 16.04

#1
NoSo this was my first experience dealing with OLS and it was bit of a change of pace with a few things. So I figured I'd give you my best practices to get a fully functional Wordpress site running SSL and with full phpmyadmin.

Everything is done assuming you have a fresh install of Ubuntu 16.04 and SSH access with root.

Table of Contents

  1. Install MYSQL
  2. Install PHPMyAdmin
  3. Install OLS
  4. Install Wordpress
  5. Configure OLS
  6. Install and Configure SSL Certificates

1. Install MYSQL

  1. To ensure you are using the latest MYSQL go to their Downloads Page scroll to the bottom click the Download button. Scroll to the bottom again and right click "No thanks, just start my download." and copy link.
  2. Now we are going to move to a directory we can write in.
    Code:
    cd /tmp
  3. Using Curl lets download MYSQL to /tmp
    Code:
    $ curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
  4. Now use the following command just to verify the file was downloaded.
    Code:
    ls
  5. Lets go ahead and install.
    Code:
    sudo dpkg -i mysql-apt-config*
  6. After it installs we need to refresh our apt package cache.
    Code:
    sudo apt-get update
  7. Lets go ahead and remove the downloaded package since we don't need it anymore.
    Code:
    rm mysql-apt-config*
  8. Now we are going to install MYSQL. You will be asked to set a root password, make sure it is secure.
    Code:
    sudo apt-get install mysql-server
  9. With MYSQL installed lets verify it is running.
    Code:
    systemctl status mysql
    You should see and output similar to below..keep in mind we want to see Active: active (running) as long as you see that we are gtg.
    Code:
    ● mysql.service - MySQL Community Server
       Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
       Active: active (running) since Sat 2017-08-12 13:09:04 CEST; 4h 13min ago
      Process: 18892 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCC
      Process: 18882 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCES
     Main PID: 18891 (mysqld)
        Tasks: 34
       Memory: 379.2M
          CPU: 3min 38.199s
       CGroup: /system.slice/mysql.service
               └─18891 /usr/sbin/mysqld
  10. Now with MYSQL running we need to secure it run the following:
    Code:
    mysql_secure_installation
    This will ask you for the root password you setup during MYSQL installation. After you enter the password it is going to ask a series of yes or no questions. Aside from password strength everything else I answer yes.
  11. Lets test MYSQL one last time before we move to PHPMYADMIN. When prompted for password use your MYSQL root password.
    Code:
    mysqladmin -u root -p version

2. Install PHPMYADMIN

  1. We are going to refresh our apt package just out of habit and install phpmyadmin. Run each command sepearately.
    Code:
    sudo apt-get update
    sudo apt-get install phpmyadmin php-mbstring php-gettext
  2. When the first prompt appears Apache2 is highlighted but not selected so press the space bar to select it then hit ok. It will run through the process and once it prompts you again it will ask you if you want to use dbconfig-common we are going to select NO. Reason why is we already have a MYSQL database setup.
  3. One more thing before PHPMYADMIN is up and running. Lets php extentions to support it.
    Code:
    sudo phpenmod mcrypt
    sudo phpenmod mbstring
  4. Since we haven't installed OLS yet, lets restart apache and test that phpmyadmin loads.
    Code:
    sudo systemctl restart apache2
  5. Now visit your site http://yoursite.com/phpmyadmin you should see:

  6. Now lets make a quick database to use for Wordpress install. Click New on the left menu and for database name choose which you want, for this tutorial we are calling it testdatabase and for Collation lets select utf8_general_ci .
  7. Securing PHPMYADMIN is a work in progress for me as I am having issues getting OLS to read the .htaccess for it. Once I do I will update this.
3. Install OLS

*This will be pretty much copy/paste from OLS site.*

  1. We need to copy the OLS 1-click script to our server. Again lets move to a tmp space.
    Code:
    cd /tmp
  2. Now lets copy the script to your server using wget command.
    Code:
    wget https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh
  3. We are going to use chmod to make the script executable.
    Code:
    chmod +x ols1clk.sh
  4. For this guide we are going to assume you want to use PHP7 and install only OLS without Wordpress being installed (I prefer to install wordpress separately). So lets run the following command:
    Code:
    bash ols1clk.sh --lsphp 70
  5. You will see something similar to below, just confirm with a Y and let OLS install:

  6. Once OLS is installed lets go ahead and set up our own username and password. I know you can do it initially, but i have had inconsistencies when using it and this is just as easy.
    Code:
    cd /usr/local/lsws/admin/misc
    Now issue the following command. You will see [admin] just input the desired username and hit enter. Then enter your desired password and hit enter.
    Code:
    ./admpass.sh
  7. Let's verify OLS is up and running https://yoursite.com:7080 you can substitute yoursite.com with an ip address if needed. You should be able to log into OLS WebAdmin. Now lets get Wordpress installed and then we will configure OLS.
4. Install Wordpress
  1. Lets move to the DIRECTORY we want to download Wordpress too.
    Code:
    cd /usr/local/lsws/
  2. We are going to use the wget command again to pull the latest Wordpress zip to our current directory which is /usr/local/lsws/.
    Code:
    wget https://wordpress.org/latest.zip
  3. Now lets install zip package to unzip latest.zip
    Code:
    apt-get install zip
  4. Alright now lets unzip latest.zip it should create a directory for Wordpress so that it is situated as /usr/local/lsws/wordpress.
  5. Now lets go into the /wordpress directory.
    Code:
    cd wordpress
  6. We are going to configure Wordpress to work with our current database we setup earlier. First we will rename the wp-config-sample.php to wp-config.php using the following command.
    Code:
     mv wp-config-sample.php wp-config.php
  7. Now we need to install nano so we can edit this config.
    Code:
    apt-get install nano
  8. Now run the following command to edit our wp-config.php.
    Code:
    nano wp-config.php
  9. You should see something similar to below. Use up, down, left, right arrows to move the cursor to areas you need to make changes. We are going to make 3 changes:

    *Use your database name and password set up in MYSQL below. Leave root as username.**

    define('DB_NAME', 'testdatabase');
    define('DB_USER', 'root');
    define('DB_PASSWORD', 'enterpassword');


  10. Once you have made the changes hold ctrl and press X. Now type in Y to confirm the changes then hit enter.

  11. Now lets create a .htaccess file use the following command and once you are in nano like above hold ctrl and press X then type Y and confirm the change.
    Code:
    nano .htacces
  12. Now lets verify Wordpress folders are assigned to the appropriate user/group and files/folders have the correct permissions set. To do this type each command below in order.
    Code:
    cd /usr/local/lsws/wordpress/
    chown -R nobody:nogroup /usr/local/lsws/wordpress/*
    sudo find . -type f -exec chmod 644 {} +
    sudo find . -type d -exec chmod 755 {} +

  13. Lets do one more thing before we move onto Configuring OLS and it will make sense in a little bit. We are going to create a new folder in /usr/local/lsws/conf/vhosts called wordpress. To do so lets run the following commands in order.
    Code:
    cd /usr/local/lsws/conf/vhosts/
    mkdir wordpress
  14. One more thing to make sure OLS can create files in vhost folder. Lets run the following commands in order.
    Code:
    cd ..
    chown -R lsadm:lsadm /usr/local/lsws/conf/vhosts/*
  1. We have set up Wordpress to connect to your MYSQL Database. Don't worry it will not load in your browser for you just yet since we haven't configured OLS just yet.
5. Configure OLS
  1. Finally we get to configure OLS and get this show on the road! Before we do we need to go ahead and stop the Apache2 process and restart OLS. So log into your OLS WebAdmin panel https://yoursite.com:7080. Once you are logged in go back to your ssh screen and run the following.
    Code:
    service apache2 stop
  2. Now go back into OLS WebAdmin and click the green Graceful Restart icon like listed below. What we have done is stop Apache2 and restart OLS allowing it to run on a port that was occupied by Apache2.


  3. Now in OLS WebAdmin we are going to do the following.

    - Setup a Virtual Host and map it to our newly installed Wordpress directory.
    - Set appropriate Rewrite rules for Wordpress pretty links.
    - Set appropriate rules so we can access PHPMYADMIN again.
    - Configure listeners...lets get to it!

  4. Open up OLS WebAdmin on the left menu click Virtual Hosts. Once there we are going to create a new Virtual Host to do so click the Add button off to the far right. You should now see a screen like below. Only thing that needs to look different is the Virtual Host Name, put whatever you want there. Everything else mimic my options.


  5. Now click save in the top right menu. You will get a error below Config File input box. It says the file is not found and click here to create. Click to create the file and the screen will refresh and click save.

  6. Now click the General tab and make edits like below. The only changes we are adding are:

    Adding $VH_ROOT to Document Root
    Checking yes to Enable GZIP Compression
    Adding index.php to Index Files



  7. Now we are going to specify Rewrite and point to the .htaccess file we created in the Wordpress install. Just mimic the setup exactly as pictured.


  8. Now we need to tell OLS where phpmyadmin is we when we type in http://yoursite.com/phpmyadmin we can actually connect to it. Lets go ahead and click the Context tab. Go ahead and click add in the right portion of the screen. On the next screen just click the right arrow. On the next screen we are going to change these 3 lines.

    URI /phpmyadmin
    Location /usr/share/phpmyadmin
    Accessible Yes


  9. Click save do not restart just yet we have 1 more thing to add!

  10. Click Listeners on the left menu. Now click Add and fill in the blocks as listed in the picture. Also select No on Secure, forgot to picture it.


  11. Go ahead and click Save. Now you are back on the main listeners page. Click the view button, magnifying glass, for the new listener we just made. Now lets add a new Virtual Host Mapping by clicking the add button. In virtual host box click and select the virtual host we setup earlier and for domain place your website address in there. So yoursite.com . Now click save and then graceful restart the server.

  12. Now go ahead and type in your address http://yoursite.com and verify your Wordpress install is up and running! You can also verify PHPMYADMIN is back by going to http://yoursite.com/phpmyadmin
I am working on the SSL part of the tutorial now and it should be up within the hour :)

 
#3
Couldn't edit my post to add SSL so here it is.

[/LIST][/INDENT]
8. Install SSL and Configure with OLS
  1. This will be short and sweet, run the following commands to refresh apt, install any common files, add certbot repo and finally install certbot, will be used to issue the SSL certificates.
    Code:
    sudo apt-get update
    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:certbot/certbot
    sudo apt-get update
    sudo apt-get install certbot
  2. Now that we have certbot installed we are going to run it to install your certificates. So go ahead run the following command and change out the example.com with your domain. You will be asked to enter an email then two more prompts.
    Code:
    sudo certbot certonly --webroot -w /usr/local/lsws/wordpress -d example.com -d www.example.com
    You will know everything went sucessfully if you have an output similar to below:
    Obtaining a new certificate
    Performing the following challenges:
    http-01 challenge for example.com
    http-01 challenge for www.example.com
    Using the webroot path /usr/local/lsws/wordpress for all unmatched domains.
    Waiting for verification...
    Cleaning up challenges

    IMPORTANT NOTES:
    - Congratulations! Your certificate and chain have been saved at
    /etc/letsencrypt/live/example.com/fullchain.pem. Your cert
    will expire on 2017-11-10. To obtain a new or tweaked version of
    this certificate in the future, simply run certbot again. To
    non-interactively renew *all* of your certificates, run "certbot
    renew"
    - Your account credentials have been saved in your Certbot
    configuration directory at /etc/letsencrypt. You should make a
    secure backup of this folder now. This configuration directory will
    also contain certificates and private keys obtained by Certbot so
    making regular backups of this folder is ideal.
    - If you like Certbot, please consider supporting our work by:

    Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
    Donating to EFF: https://eff.org/donate-le


  3. Only thing we really need to take note of is where the certificates are located in this instance it is /etc/letsencrypt/live/example.com/ of course replace example.com with your domain.

  4. Now lets install these certificates in OLS WebAdmin. So open back up your OLS WebAdmin and on the left menu select Listeners. Now lets select add a new listener. I named mine TestSite SSL then port is 443 and set Secure to Yes and save.

  5. Click on the SSL tab and then click edit SSL Private Key & Certificate. Now we are going to add the directory for our private key and certificate. Here is what you should place in each and I have included a picture of how it should look.


  6. Repeat the same steps for your initial Listener we made for port 80, leaving the port alone but changing everything else.

  7. Now save these settings and go for a graceful restart.

  8. Go ahead and type in https://yourwebsite.com into the browser and you are running secure. One more thing to do is go into Wordpress and Settings then General and change the following to https instead of http:

    WordPress Address (URL)
    Site Address (URL)

That is it, hopefully my hours of tinkering and making this has helped you better understand LiteSpeed[/QUOTE]​
 
#5
need a little help here, i skipped the part where you install wordpress since i won't use it, i did every other step, when i came to the step where you said "context" in 5.8 part, i did exactly that but i can't seem to get example.net/phpmyadmin to work, i get this "Request Page Not Found", any help on this?
 
#8
btw how do i get upload_max_filesize changed on phpmyadmin? i tried changing /usr/local/lsws/lsphp70/etc/php.ini restarted, but it doesn't take effect
 
#9
what we can do for windcard ssl. or wpmu sites
i can add ssl formy root site but cant add my subsites. my subsites with subdomain (eng: sub.root.site) of others domains (eng: my-domains.com)
what can I do
 
#11
Hello

Sorry for point 10 "Click Listeners on the left menu. Now click Add and fill in the blocks as listed in the picture. Also select No on Secure, forgot to picture it " , i cant found the picture.
 
Top