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
2. Install PHPMYADMIN
3. Install OLS
*This will be pretty much copy/paste from OLS site.*
4. Install Wordpress
5. Configure OLS
I am working on the SSL part of the tutorial now and it should be up within the hour
Everything is done assuming you have a fresh install of Ubuntu 16.04 and SSH access with root.
Table of Contents
- Install MYSQL
- Install PHPMyAdmin
- Install OLS
- Install Wordpress
- Configure OLS
- Install and Configure SSL Certificates
1. Install MYSQL
- 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.
- Now we are going to move to a directory we can write in.
Code:
cd /tmp
- Using Curl lets download MYSQL to /tmp
Code:
$ curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
- Now use the following command just to verify the file was downloaded.
Code:ls
- Lets go ahead and install.
Code:sudo dpkg -i mysql-apt-config*
- After it installs we need to refresh our apt package cache.
Code:sudo apt-get update
- Lets go ahead and remove the downloaded package since we don't need it anymore.
Code:rm mysql-apt-config*
- 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
- With MYSQL installed lets verify it is running.
Code:systemctl status mysql
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
- Now with MYSQL running we need to secure it run the following:
Code:mysql_secure_installation
- 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
- 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
- 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.
- One more thing before PHPMYADMIN is up and running. Lets php extentions to support it.
Code:sudo phpenmod mcrypt sudo phpenmod mbstring
- Since we haven't installed OLS yet, lets restart apache and test that phpmyadmin loads.
Code:sudo systemctl restart apache2
- Now visit your site http://yoursite.com/phpmyadmin you should see:
- 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 .
- 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.
*This will be pretty much copy/paste from OLS site.*
- We need to copy the OLS 1-click script to our server. Again lets move to a tmp space.
Code:cd /tmp
- Now lets copy the script to your server using wget command.
Code:wget https://raw.githubusercontent.com/litespeedtech/ols1clk/master/ols1clk.sh
- We are going to use chmod to make the script executable.
Code:chmod +x ols1clk.sh
- 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
- You will see something similar to below, just confirm with a Y and let OLS install:
- 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
Code:./admpass.sh
- 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.
- Lets move to the DIRECTORY we want to download Wordpress too.
Code:cd /usr/local/lsws/
- 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
- Now lets install zip package to unzip latest.zip
Code:apt-get install zip
- Alright now lets unzip latest.zip it should create a directory for Wordpress so that it is situated as /usr/local/lsws/wordpress.
- Now lets go into the /wordpress directory.
Code:cd wordpress
- 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
- Now we need to install nano so we can edit this config.
Code:apt-get install nano
- Now run the following command to edit our wp-config.php.
Code:nano wp-config.php
- 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');
- Once you have made the changes hold ctrl and press X. Now type in Y to confirm the changes then hit enter.
- 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
- 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 {} +
- 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
- 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/*
- 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.
- 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
- 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.
- 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!
- 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.
- 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.
- 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
- 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.
- 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
- Click save do not restart just yet we have 1 more thing to add!
- 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.
- 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.
- 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