Build a Moodle Platform Based on Windows + Apache + PHP + MySQL
Speaking of Moodle, I believe that students studying educational technology should be familiar with each other. In the network and distance education courses of the University, I had the honor to meet the legendary Moodle, however, I will never tell you that I haven't found a proper time with this Ms until I graduated. moodle knows each other, even though I know she has a crush on me! Why? Why? For ...... What about it? Okay, I admit, the reason why I didn't have a good understanding of Moodle is nothing more than the feeling that Moodle has always given me: the configuration is very complicated, not only the installation steps are too many, there are a lot of software to be installed, and errors will occur if you don't pay attention to it. It doesn't matter if you make an error. What's important is that it takes more than half a day to study a sesame mistake. In a word: once installed, once submitted. In the past few days, if I had to install a Moodle on the Windows Server 2008 R2 development is Server, I had no idea when I would try again to study Moodle with awe and embarrassment. Although it was also a few days after the battle, it was still a success, so I wrote this article about how to build Moodle with no other ideas with the treasure of my ears, we hope to help you build your own Moodle platform better and faster.
Now, let's start building our Moodle journey. Are you ready? Let's go !!!
First, let's briefly introduce the software used to install Moodle this time:
④ Moodle3.0.2 +.
Because the server is a 64-bit operating system, considering performance issues, Apache, PHP, and MySQL use a 64-bit installation package.
Download from the FTP server No. 1 of the customer's home
------------------------------------------ Split line ------------------------------------------
FTP address: ftp://ftp1.bkjia.com
In June 2016, LinuxIDC.com \ June, we established a Windows + Apache + PHP + MySQL-based Moodle platform \
For the download method, see
------------------------------------------ Split line ------------------------------------------
Please download it by yourself.
Here, some friends may ask, "Isn't there a lot of Integrated Installation packages for Moodle? Download a one-click installation package in minutes !". Indeed, using the one-click installation package can save us a lot of steps, and there will be almost no installation errors, but what I want to say is, the current one-click installation package is nothing more than integrating and encapsulating Apache, PHP, MySQL, Moodle and other software. It is a closed PHP Environment + Moodle platform, as the saying goes, "There are advantages and disadvantages in everything", although the one-click installation package is simple, it is not flexible enough, and the concurrency performance is poor. The Moodle built with the one-click installation package may not meet our performance requirements, it is also important to use the one-click installation package to help us understand the technical architecture of Moodle, because we do not know how to associate Apache, PHP, MySQL, and Moodle, if one day we want to develop a Moodle plug-in by ourselves, or a flash of brain, we want to develop a platform similar to Moodle, we must have a clearer understanding of the Moodle framework and the PHP development environment on which it depends. That is to say, in addition to understanding the basic operations and usage of Moodle, we must also have some knowledge about PHP. The more we know, the more we know, we have a deeper understanding of Moodle. So here I come to the conclusion that the first step to conquer Moodle is to learn how to build a PHP environment honestly.
First, install Apache as follows:
1. Click the apache_2.2.21-x64-openssl-1.0.0e.msi installation package, the following appears:
2. click Next.
3. Select I accenpt the terms int the license agreement and click Next.
4. click Next.
5. In this step, you must enter some information about the Apache service. We recommend that you enter the information in the format in brackets.
A) Network Domain is the Apache Network Domain name. If you want to publish your Web server so that other people can access it, enter the official Domain name you have applied, otherwise, we recommend that you enter the specified format as needed.
B) Server Name refers to the Name of the Apache service. Similarly, if there is a formal service Name, enter the formal service Name. If not, enter the service Name in the specified format;
C) Administrator's Email Address is the Apache Administrator's Email Address. You can also enter it in the specified format.
D) In the following single region, select the default Recommended items, that is, for all users, on port 80, as a service -- Recommended, to open the Apache service for all users, by default, 80 is used as the Apache service port number.
6. Typical is a Typical installation mode and Custom is a Custom installation mode. select Custom mode and click Next.
7. Here you can select the items to be installed and the installation path. We choose to install all items, that is, select Apache HTTP Server 2.2.21. The installation path I selected is the directory under the e disk. You can select a proper path on your own. Click Next.
8. Click install to start installation.
9. Click Finish to complete the installation.
10. Next, we can enter http: // localhost in the browser to verify whether Apache is successfully installed. If the browser outputs "It Works", It indicates that Apache is successfully installed,
Why does "It Works!" appear when you enter http: // localhost !", The reason is that the Apache service is started after Apache is installed successfully. If you access localhost in a browser, the network request will be sent to the Apache server, after receiving the request, the Apache service searches for the corresponding site file in the default site root directory for access. The default Apache site root directory is located in the htdocs folder after the installation is complete, the path on my computer is E: \ Program Files \ Apache Software Foundation \ Apache2.2 \ htdocs. in the htdocsfolder, an index.html file is saved and index.html is opened. We will find a simple html code in it, A line of text is displayed in the html body section, that is, "It Works!"
Now, we can start to think about it. How can we access the homepage of Moodle installation when we install Moodle later? Let's think about it first. I will explain it in detail later when we install Moodle.
After installing Apache, I need to briefly describe how to start and disable Apache.
First, find the Apache console. In the Apache installation directory of the Start menu, there is a Monitor Apache Plugin file. Click it to open the Apache console,
After the console is opened, the console icon appears in the lower right corner of the Computer (the console icon is displayed in the Blue Circle ):
Double-click the console icon to go to the console interface:
The Service Status box on the left lists all Apache servers on the current computer. We are now starting the installed Apache2.2. There is a row of buttons on the right. By clicking these buttons, we can select the Apache service to be started and start, close, and restart it. When installing and accessing Moodle, we must ensure that the Apache service is enabled properly.
The installation of Apache is only part of the complete configuration. Further configuration is required to build the entire PHP environment.
Next, we will explain the PHP configuration.
First, extract the PHP compressed package php-5.4.8-win32-vc9-x64.zip to the directory where you want to install PHP (I directly decompress the package to the Program Files folder on the E drive). To avoid the folder name being too long, rename the decompressed folder to php54, folders can be named at will, as long as they comply with the specifications, OK,
There are several key points in the decompressed folder.
1. there are many files in the ext folder. dll file (. dll files are dynamic library files. These files are PHP extension files. The extension files are used to expand functions and performance of existing PHP versions, to make PHP functions and performance more effective, we need to open some extensions in the PHP configuration file when installing Moodle later, for example, php_curl extension, php_gd2 extension, php_mbstring extension, php_mysql extension, and php_mysqli extension;
2. Rename the php. ini-production file under php54 to php. ini,
Php. ini will be used as the PHP configuration file. We mainly configure PHP in php. ini. We will describe how to configure php. ini after installing and configuring MySQL.
3. rename php. after ini, we need to return to the Apache configuration file httpd. conf to associate PHP with Apache. Only after PHP and Apache are associated can the PHP file or PHP project run properly on Apache. The changes we want to make in httpd. conf are as follows:
A) add support for php dynamic shared libraries, that is, load the dynamic link library in php through LoadModule. Under the php54 directory, there is a php dynamic link library php5apache2_2.dll. We need to load it in httpd. conf. How to load it? In fact, we only need to add a line of code: LoadModule php5_module "E:/Program Files/php54/php5apache2_2.dll". Note, you need to specify the corresponding path on your computer after LoadModule php5_module. The path on my computer is E:/Program Files/php54/php5apache2_2.dll.
B) add support for php parsing. We need to enable apache to suffix. file in php format is parsed, so you need to add a pair under the node. php files correspond to MIME-type support. Here you only need to add a line of code: AddType application/x-httpd-php. php. By the way, we will add the php. ini path here.
In addition, I will explain several key parts in httpd. conf.
1. DocumentRoot and Directory permission folders.
A) DocumentRoot. In httpd. one line of code in conf specifies the site root directory, that is, DocumentRoot "E:/Program Files/Apache Software Foundation/Apache2.2/htdocs", indicating that the root directory of my current site is located in E: /Program Files/Apache Software Foundation/Apache2.2/htdocs. Without considering the multi-site configuration, we access the site represented by this directory by default. Because you do not need to configure multiple sites when installing Moodle, we will not detail the configuration of multiple sites. I will explain the configuration of multiple sites in another blog.
B) Directory permission folder. The node specifies the access permissions for all sites.
Directory "E:/Program Files/Apache Software Foundation/Apache2.2/htdocs" indicates that all sites are under E:/Program Files/Apache Software Foundation/Apache2.2/htdocs. If there are other sites in the Directory that need to be accessed, we must change the path specified by Directory to ensure that the site Directory to be accessed is included in the path specified by Directory.
In addition, we need to set Allow from all here to accept access from other hosts. Only by configuring Director's access permission to Allow from all can we use other hosts to access sites on the Apache server.
2. Configure the file index in the node.
After directoryindex, we add indexes in the .html. htm. php file format. In this way, the files in these formats can be automatically searched when accessing the website.
3. Use pseudo-static configuration to configure multiple sites.
We can modify the configuration here to implement multi-site configuration through pseudo-static mode. Of course, this is not the focus of our explanation, so I will not explain it much at the moment.
4. Configure the VM.
5. after configuring Apache, we need to test Apache's local access and LAN access. At this time, there may be no problems during local access, but Apache cannot be accessed through the lan. Why? In most cases, because of Windows Firewall, we need to add the Apache service to the trusted program list in Windows Firewall.
After all the above ups and downs, our Apache and php will be associated. Next we will be in the site root directory (My is E:/Program Files/Apache Software Foundation/Apache2.2/htdocs) write a test. php file to output php information, test. the php code is as follows:
Echo phpinfo ();
We use http: // localhost/test. php to access the server. If no problem occurs, the relevant php information will be displayed,
For more details, please continue to read the highlights on the next page: