Hack and / - Your Own Personal Server: Blog
Now that you are familiar with how Apache organizes files under Ubuntu, the next step is to configure a new virtual host. It turns out there are a number of different ways you can configure the WordPress virtual host under Apache, and included in the wordpress package are examples of the different methods under /usr/share/doc/wordpress/example/apache.conf. For this article, I'm choosing a configuration that makes it simple to manage multiple WordPress sites on the same host, so create a file called /etc/apache2/sites-available/wordpress that contains the following data:
NameVirtualHost *:80 <VirtualHost *:80> UseCanonicalName Off VirtualDocumentRoot /var/www/%0 Options All </VirtualHost>
Now, enable this new site and disable any default virtual hosts Apache may have included:
$ sudo a2ensite wordpress $ sudo a2dissite default
In my example, I have used the Apache option VirtualDocumentRoot, so I can more easily manage multiple WordPress sites. Unfortunately, the module to allow that feature isn't enabled by default, so I also need to enable the vhost_alias module so that feature works:
$ sudo a2enmod vhost_alias
The way I have set up WordPress, each WordPress site you host from this server will have its own document root under /var/www/<domainname>. When you add a new site, you need to create a symlink under /var/www/ named after your domain name that points to the installed WordPress software. In my case, I want to create a site called www.example.org, so I would type:
$ sudo ln -s /usr/share/wordpress /var/www/www.example.org
Instead of www.example.org, put the fully qualified domain name you are going to use for your site. While you're at it, if you haven't already set up an A record on your DNS server that points to your new site, now would be a good time. If you followed the steps in my previous column to set up a DNS server of your own, you already should have an entry in place for www. Simply change the IP address to point to the external, public IP address you will use for your Web server and reload the bind9 service.
After the symlink is created, I use the apache2ctl Apache management tool to reload Apache:
$ sudo apache2ctl graceful
Note: the apache2ctl program is the main command-line program you will use to manage the Apache service on your machine. In addition to the graceful argument, which tells Apache to reload any new configuration you have changed safely (such as when you add new sites), you also can use the following commands.
To restart Apache by forcibly stopping existing processes and starting them again:
$ sudo apache2ctl restart
To start Apache if it is completely stopped:
$ sudo apache2ctl start
To stop Apache hard (kill all of the current processes even if they are still processing a user request):
$ sudo apache2ctl stop
To stop Apache gracefully (it will kill processes only after they are finished with their current request):
$ sudo apache2ctl graceful-stop
Like with many dynamic sites these days, WordPress gets its data from a database back end: in this case, MySQL. The wordpress package includes a nice little shell script you can use to set up your MySQL database automatically for your site at /usr/share/doc/wordpress/examples/setup-mysql. All you have to do is pass it the -n option and tell it the name of the MySQL user you want to use and the name of the database. In my case, I use the user name “wordpress” and name the database after my site, www.example.org:
$ sudo bash /usr/share/doc/wordpress/examples/setup-mysql ↪-n wordpress www.example.org
Note: this command attempts to ping the domain name that you list, so if you haven't set up the domain in DNS yet, you will want to do it before you run the above command. Again, make sure your domain points to the public IP address you will use for your site.
Once you get to this point, your blog actually should be ready to use. All you need to do is visit http://www.example.org (in your case, you would visit the URL you set up for your blog), and you should be greeted with the initial WordPress configuration page as shown in Figure 1. From that point, all you have to do is enter the title for your blog and the contact e-mail you'd like to use. WordPress will present you with the admin user name and a temporary password. From there, you can log in and start tweaking, creating posts and changing your theme.
Kyle Rankin is a Systems Architect in the San Francisco Bay Area and the author of a number of books, including The Official Ubuntu Server Book, Knoppix Hacks and Ubuntu Hacks. He is currently the president of the North Bay Linux Users' Group.
Kyle Rankin is a VP of engineering operations at Final, Inc., the author of a number of books including DevOps Troubleshooting and The Official Ubuntu Server Book, and is a columnist for Linux Journal. Follow him @kylerankin.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
|Fancy Tricks for Changing Numeric Base||May 29, 2016|
|Working with Command Arguments||May 28, 2016|
|Secure Desktops with Qubes: Installation||May 28, 2016|
|CentOS 6.8 Released||May 27, 2016|
|Secure Desktops with Qubes: Introduction||May 27, 2016|
|Chris Birchall's Re-Engineering Legacy Software (Manning Publications)||May 26, 2016|
- Tips for Optimizing Linux Memory Usage
- Working with Command Arguments
- Secure Desktops with Qubes: Introduction
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Secure Desktops with Qubes: Installation
- Fancy Tricks for Changing Numeric Base
- CentOS 6.8 Released
- Linux Mint 18
- The Italian Army Switches to LibreOffice
- Chris Birchall's Re-Engineering Legacy Software (Manning Publications)
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide