{"id":279,"date":"2015-02-20T21:28:25","date_gmt":"2015-02-20T14:28:25","guid":{"rendered":"http:\/\/www.st.ac.th\/krubuncha\/?p=279"},"modified":"2016-11-21T09:07:21","modified_gmt":"2016-11-21T02:07:21","slug":"how-to-install-wordpress-with-apache-on-freebsd-10-1","status":"publish","type":"post","link":"https:\/\/www.st.ac.th\/krubuncha\/how-to-install-wordpress-with-apache-on-freebsd-10-1\/","title":{"rendered":"How To Install WordPress with Apache on FreeBSD 10.1"},"content":{"rendered":"<div class=\"container tutorial-header\" data-completed-tutorial-id=\"\" data-tutorial-id=\"1429\" data-js=\"tutorial\">\n<h1 class=\"content-title \">How To Install WordPress with Apache on FreeBSD 10.1<\/h1>\n<p><span class=\"meta-section timestamp\"><span class=\"tutorial-date-text\">Posted<\/span><span class=\"tutorial-date\">January 14, 2015<\/span><\/span> <span class=\"meta-section pageviews\"><span class=\"views-count v-mid\">24.4k<\/span><span class=\"sr-only\">views<\/span><\/span> <span class=\"meta-section tags\"><a class=\"tag\" href=\"https:\/\/www.digitalocean.com\/community\/tags\/wordpress?type=tutorials\">WORDPRESS<\/a> <a class=\"tag\" href=\"https:\/\/www.digitalocean.com\/community\/tags\/lamp-stack?type=tutorials\">LAMP STACK<\/a> <a class=\"tag\" href=\"https:\/\/www.digitalocean.com\/community\/tags\/freebsd?type=tutorials\">FREEBSD<\/a><\/span><\/div>\n<div class=\"container\"><\/div>\n<div class=\"content-body tutorial-content\" data-growable-markdown=\"\">\n<h3 id=\"introduction\">Introduction<\/h3>\n<p>WordPress is a popular open source content management system (CMS) that can be used to easily set up a blog. It is a very flexible system, through its plugin and template support, that allows users to extend its functionality to meet their specific needs; WordPress can be customized to support anything from a basic blog to a fully-featured eCommerce site.<\/p>\n<p>In this tutorial, we will show you how to set up WordPress with an Apache web server on FreeBSD 10.1.<\/p>\n<div data-unique=\"prerequisites\"><\/div>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<p>Before you begin this guide, you must have a FAMP (FreeBSD, Apache, MySQL, and PHP) stack server setup. This WordPress installation tutorial is based on this FAMP tutorial: <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-an-apache-mysql-and-php-famp-stack-on-freebsd-10-1\">How To Install an Apache, MySQL, and PHP (FAMP) Stack on FreeBSD 10.1<\/a>.<\/p>\n<p>This tutorial assumes that you want to serve WordPress from the root of your web site, e.g.<code>http:\/\/example.com\/<\/code>, and that your Apache document root is empty (aside from the default <code>index.html<\/code> file).<\/p>\n<p>If you do not already have a FAMP setup, follow the linked guide before continuing with this tutorial. Note that this tutorial, like the linked FAMP guide, uses PHP 5.6.<\/p>\n<div data-unique=\"step-one-\u2014-install-additional-php-modules\"><\/div>\n<h2 id=\"step-one-\u2014-install-additional-php-modules\">Step One \u2014 Install Additional PHP Modules<\/h2>\n<p>Although you already have PHP 5.6 installed, WordPress requires additional PHP modules in order to function properly. We will use <code>pkg<\/code> to install these required PHP modules.<\/p>\n<p>At the command prompt of your server, use this command to install all of the required PHP 5.6 modules:<\/p>\n<pre class=\"code-pre \"><code>sudo pkg install php56-mysql \\\r\n php56-xml \\\r\n php56-hash \\\r\n php56-gd \\\r\n php56-curl \\\r\n php56-tokenizer \\\r\n php56-zlib \\\r\n php56-zip\r\n<\/code><\/pre>\n<p>Each of these modules allows WordPress to use various functions in order to perform certain tasks. For example, <code>php56-gd<\/code> provides libraries for image handling, and <code>php56-curl<\/code> allows WordPress to download files from external servers for tasks such as plugin updates. Also note that if you followed the prerequisite FAMP tutorial, you should have already installed <code>php56-mysql<\/code>, which allows WordPress to interact with a MySQL database.<\/p>\n<div data-unique=\"step-two-\u2014-prepare-mysql-database\"><\/div>\n<h2 id=\"step-two-\u2014-prepare-mysql-database\">Step Two \u2014 Prepare MySQL Database<\/h2>\n<p>WordPress uses a relational database, such as MySQL, to manage and store site and user information. In this step, we will prepare a MySQL database and user for WordPress to use.<\/p>\n<p>Log into the MySQL administrative account, <code>root<\/code>, by issuing this command:<\/p>\n<pre class=\"code-pre \"><code>mysql -u root -p\r\n<\/code><\/pre>\n<p>You will be prompted for the password that you set for the MySQL root account when you first installed MySQL. After providing the password, you will enter the <strong>MySQL command prompt<\/strong>.<\/p>\n<p>We will now create the MySQL database that WordPress will use to store its data. You can call this whatever you like, but we will call ours <code>wordpress<\/code> for our example. At the MySQL prompt, enter this SQL statement to create the database:<\/p>\n<pre class=\"code-pre \"><code>CREATE DATABASE <span class=\"highlight\">wordpress<\/span>;\r\n<\/code><\/pre>\n<p>Note that every MySQL statement must end in a semi-colon (<code>;<\/code>) before it will execute.<\/p>\n<p>Next, we are going to create a MySQL user account that WordPress will use to interact with the database that we just created. For our example, we will call the new user <code>wordpressuser<\/code> with a password of<code>password<\/code>. You should definitely change the password to something more secure, and you can use a different user name if you wish. This SQL statement will create our example user:<\/p>\n<pre class=\"code-pre \"><code>CREATE USER <span class=\"highlight\">wordpressuser<\/span>@localhost IDENTIFIED BY '<span class=\"highlight\">password<\/span>';\r\n<\/code><\/pre>\n<p>At this point, you have the MySQL database and user that WordPress will use. However, we must grant the user access to the database. To do this, we will use this SQL statement:<\/p>\n<pre class=\"code-pre \"><code>GRANT ALL PRIVILEGES ON <span class=\"highlight\">wordpress<\/span>.* TO <span class=\"highlight\">wordpressuser<\/span>@localhost;\r\n<\/code><\/pre>\n<p>Before this change in privileges will go into effect, we must flush the privileges with this SQL statement:<\/p>\n<pre class=\"code-pre \"><code>FLUSH PRIVILEGES;\r\n<\/code><\/pre>\n<p>Now exit the MySQL prompt:<\/p>\n<pre class=\"code-pre \"><code>exit\r\n<\/code><\/pre>\n<p>The MySQL database and user are now ready for use with a new WordPress installation. Let&#8217;s download WordPress now.<\/p>\n<div data-unique=\"step-three-\u2014-download-wordpress\"><\/div>\n<h2 id=\"step-three-\u2014-download-wordpress\">Step Three \u2014 Download WordPress<\/h2>\n<p>Now we must download the WordPress files from the project&#8217;s website.<\/p>\n<p>The archive of the latest stable release of WordPress is always available from the same URL. Download it to your home directory with the following commands:<\/p>\n<pre class=\"code-pre \"><code>cd ~\r\nfetch http:\/\/wordpress.org\/latest.tar.gz\r\n<\/code><\/pre>\n<p>Now extract the archive with this command:<\/p>\n<pre class=\"code-pre \"><code>tar xvf latest.tar.gz\r\n<\/code><\/pre>\n<p>This extracts the contents of the archive to a directory called <code>wordpress<\/code>, in your home directory.<\/p>\n<p>If you wish, you may delete the WordPress archive now:<\/p>\n<pre class=\"code-pre \"><code>rm latest.tar.gz\r\n<\/code><\/pre>\n<div data-unique=\"step-four-\u2014-configure-wordpress\"><\/div>\n<h2 id=\"step-four-\u2014-configure-wordpress\">Step Four \u2014 Configure WordPress<\/h2>\n<p>Before making WordPress accessible via our web server, we must configure it so that it will able to connect to the database that we created earlier.<\/p>\n<p>First, change to the <code>wordpress<\/code> directory:<\/p>\n<pre class=\"code-pre \"><code>cd ~\/wordpress\r\n<\/code><\/pre>\n<p>To make the configuration simple, let&#8217;s base our WordPress configuration on the provided sample configuration, <code>wp-config-sample.php<\/code>. Copy the sample to <code>wp-config.php<\/code>, the default WordPress configuration file:<\/p>\n<pre class=\"code-pre \"><code>cp wp-config-sample.php wp-config.php\r\n<\/code><\/pre>\n<p>Now open the configuration file in an editor. We will use <code>vi<\/code> for this purpose, but feel free to use your editor of choice:<\/p>\n<pre class=\"code-pre \"><code>vi wp-config.php\r\n<\/code><\/pre>\n<p>The only modifications we need to make are to the MySQL settings. We must update the values of the following parameters:<\/p>\n<ul>\n<li><code>DB_NAME<\/code><\/li>\n<li><code>DB_USER<\/code><\/li>\n<li><code>DB_PASSWORD<\/code><\/li>\n<\/ul>\n<p>These correspond to the MySQL database and user that we prepared in an earlier step. Look for the following lines and update the highlighted parts with your database name, user, and password:<\/p>\n<pre class=\"code-pre \"><code>\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\r\n\/** The name of the database for WordPress *\/\r\ndefine('DB_NAME', '<span class=\"highlight\">wordpress<\/span>');\r\n\r\n\/** MySQL database username *\/\r\ndefine('DB_USER', '<span class=\"highlight\">wordpressuser<\/span>');\r\n\r\n\/** MySQL database password *\/\r\ndefine('DB_PASSWORD', '<span class=\"highlight\">password<\/span>');\r\n<\/code><\/pre>\n<p>Save and exit.<\/p>\n<div data-unique=\"step-five-\u2014-copy-files-to-apache-document-root\"><\/div>\n<h2 id=\"step-five-\u2014-copy-files-to-apache-document-root\">Step Five \u2014 Copy Files to Apache Document Root<\/h2>\n<p>Now that your WordPress application is configured to connect to your database, we must copy it to Apache&#8217;s <code>DocumentRoot<\/code> directory, where it can be served to your site&#8217;s visitors.<\/p>\n<p>If you followed the prerequisite FAMP tutorial, Apache&#8217;s document root will be located at<code>\/usr\/local\/www\/apache24\/data<\/code>\u2014if your document root is located somewhere else, be sure to update the highlighted path in the commands in this section.<\/p>\n<p>Let&#8217;s copy the WordPress files to Apache&#8217;s document root with the <code>cp<\/code> command:<\/p>\n<pre class=\"code-pre \"><code>sudo cp -rp ~\/wordpress\/* <span class=\"highlight\">\/usr\/local\/www\/apache24\/data<\/span>\/\r\n<\/code><\/pre>\n<p>Now change the ownership of the WordPress files to the <code>www<\/code> user and group, which is the name of the user that runs the Apache process, so Apache will have appropriate access:<\/p>\n<pre class=\"code-pre \"><code>sudo chown -R www:www <span class=\"highlight\">\/usr\/local\/www\/apache24\/data<\/span>\/*\r\n<\/code><\/pre>\n<p>Now that the WordPress files are being served by Apache, you are almost ready to start using WordPress.<\/p>\n<div data-unique=\"step-six-\u2014-run-wordpress-installation-script\"><\/div>\n<h2 id=\"step-six-\u2014-run-wordpress-installation-script\">Step Six \u2014 Run WordPress Installation Script<\/h2>\n<p>The next step is to run the WordPress installation script. The script will ask you a few questions about your WordPress site, then initialize the database.<\/p>\n<p>In your web browser, navigate to your server&#8217;s domain name or public IP address. For example, we will use &#8220;example.com&#8221; here:<\/p>\n<pre class=\"code-pre \"><code>http:\/\/<span class=\"highlight\">example.com<\/span>\r\n<\/code><\/pre>\n<p>The first time you visit your WordPress site, you will be prompted by a Language Select screen. Select your preferred language, and click the <strong>Continue<\/strong> button:<\/p>\n<\/div>\n<p><!--more--><\/p>\n<p>1<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>How To Install WordPress with Apache on FreeBSD 10.1 PostedJanuary 14, 2015 24.4kviews WORDPRESS LAMP STACK FREEBSD Introduction WordPress is a popular open source content <a class=\"mh-excerpt-more\" href=\"https:\/\/www.st.ac.th\/krubuncha\/how-to-install-wordpress-with-apache-on-freebsd-10-1\/\" title=\"How To Install WordPress with Apache on FreeBSD 10.1\">[\u0e2d\u0e48\u0e32\u0e19\u0e15\u0e48\u0e2d]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":339,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?fit=300%2C300&ssl=1","blog_post_layout_featured_media_urls":{"thumbnail":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=150%2C150&ssl=1",150,150,true],"full":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?fit=300%2C300&ssl=1",300,300,false]},"categories_names":{"1":{"name":"\u0e1a\u0e17\u0e04\u0e27\u0e32\u0e21\u0e04\u0e2d\u0e21\u0e1e\u0e34\u0e27\u0e40\u0e15\u0e2d\u0e2d\u0e23\u0e4c","link":"https:\/\/www.st.ac.th\/krubuncha\/category\/%e0%b8%9a%e0%b8%97%e0%b8%84%e0%b8%a7%e0%b8%b2%e0%b8%a1%e0%b8%84%e0%b8%ad%e0%b8%a1%e0%b8%9e%e0%b8%b4%e0%b8%a7%e0%b9%80%e0%b8%95%e0%b8%ad%e0%b8%ad%e0%b8%a3%e0%b9%8c\/"}},"tags_names":[],"comments_number":0,"wpmagazine_modules_lite_featured_media_urls":{"thumbnail":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=150%2C150&ssl=1",150,150,true],"cvmm-medium":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=300%2C300&ssl=1",300,300,true],"cvmm-medium-plus":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=300%2C207&ssl=1",300,207,true],"cvmm-portrait":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=300%2C300&ssl=1",300,300,true],"cvmm-medium-square":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=300%2C300&ssl=1",300,300,true],"cvmm-large":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=300%2C300&ssl=1",300,300,true],"cvmm-small":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?resize=130%2C95&ssl=1",130,95,true],"full":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/logo-dark.png?fit=300%2C300&ssl=1",300,300,false]},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Mvvj-4v","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":3,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"predecessor-version":[{"id":342,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts\/279\/revisions\/342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/media\/339"}],"wp:attachment":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}