windows7 环境安装PHP Apache MySQL

转自:https://docs.moodle.org/28/en/Manual_install_on_Windows_7_with_Apache_and_MySQL#Step_1:_Install_MySQL


These are instructions for installing on Windows 7 desktop (they may also be useful for a server install with some thought to security) using individual components rather than a one click installer. This is intended only as a testing/evaluation install via 'localhost'. Proper server configuration and security is not considered.

NOTE: This assumes that you are comfortable with administering a Windows system and can use the command line. I never use Windows and I managed, but this may not be the quickest or most efficient way to do things. Make sure your Windows installation is in good shape, you clear out all the junk and stuff making it run slower (because installing all this server software certainly isn't going to make it run faster!) and that you have installed any outstanding updates.

ANOTHER NOTE: Watch out for the irritating "Do you want this program to get control of your computer" window that comes up at various stages. Sometimes it didn't appear but you do see a shield dimly flashing in the task bar. Click and say yes.

Step 1: Install MySQL

  • Install the MySQL database server on your PC. We will do this using the 'MSI' one-click installer for Windows. Go to http://dev.mysql.com/downloads/ and download the 'MySQL Installer for Windows'. At the time of writing this was from a very obvious graphic at the top of the screen (which I missed the first time).
  • Run the installation. Click...
    • Install MySQL products
    • Accept the license
    • Allow the version check (optional)
    • At 'Choose a Setup Type' accept the "Developer Default" and click Next
    • A number of downloads of required software may be identified. Click Execute and follow onscreen instructions to install them.
    • At 'Installation progress' screen, hit Execute - the MySQL software will be installed
    • At 'Configuration overview' hit Next to go to the basic configuration screen.
    • Accept all the defaults on the 'MySQL Server Configuration' and hit Next.
    • On the password screen, supply a password for the 'root' (main administrator) user. Make sure it's one you won't forget. You can also create a 'User' account just for Moodle with more restricted access if you like. This would be good practice on a public server but just using the 'root' user will suffice for testing.
    • On the Service details page, accept the defaults and hit Next and then Next a couple more times for the configuration progress.
    • Click Finish. Job done.
  • MySQL Workbench will open. Under Server Administration (right hand column, double click 'Local MySQL56' (or whatever you called it). A box should pop up asking for the root password. Enter the password you supplied
  • The server management screen should appear. You don't have to worry too much about this. It just shows the install is working.

Step 2: Install Apache

  • Install the Apache web server on your PC. Go to http://www.apachelounge.com/download/. Scroll down the page until you find the download for the 'Apache 2.4 win32 binaries' and download. You need to be careful that the module dll in PHP matches the version of Apache you install. Apache won't load otherwise.
  • Unzip the file into C:\. You should end up with a directory 'Apache24' (or whatever the latest version is).
  • Find Start > All programs > Accessories > Command Prompt...... BUT, right click, and select 'Run as administrator'.
  • Enter the following commands
   cd \Apache24\bin
   httpd -k install
   httpd -k start

...you may well get a warning about the server name. Don't worry about it. Don't close this window, you will need it again in a minute.

  • To test it worked type 'http://localhost' into your browser. You should get a screen up to the effect that Apache is installed and working.

Step 3: Install PHP

  • Now install the PHP scripting language on your PC. Go to http://www.php.net/download. In the current stable release section click on link for Windows 5.x.x binaries and source. Scroll down to the newest 'Zip' for VC11 x86 Thread Safe (non thread safe doesn't have the Apache dll) PHP (again, the newest versions of PHP didn't have this but it shouldn't matter) and download. *Don't* be tempted to use the Microsoft Installer version; it won't work.
  • Open the zip file and extract to C:\PHP\

Step 4: Configure Apache and PHP

You now need to edit Apache's httpd.conf file. In the file explorer navigate to C:\Apache24\conf\httpd.conf. Open it in Notepad . At the end of this file (or wherever you like if you want to be more organised) add the following lines:

   LoadModule php5_module "C:/PHP/php5apache2_4.dll"
   AddHandler application/x-httpd-php .php
   PHPIniDir C:/PHP

The version of the module file matters (2_4 in this case). It MUST match the Apache version installed.

In the same file. Search for the line starting DirectoryIndex. Change it as follows

   DirectoryIndex index.php index.html

Now, navigate to C:\PHP, and copy php.ini-development to php.ini. Edit this file, find the following lines and modify them as follows (all should exist already):

   memory_limit = 256M
   post_max_size = 128M
   upload_max_filesize = 128M

You need to specify the extensions required for Moodle. Find the 'Dynamic Extensions' section and change the following lines (uncomment and add the correct path):

   extension=c:/php/ext/php_curl.dll
   extension=c:/php/ext/php_gd2.dll
   extension=c:/php/ext/php_intl.dll
   extension=c:/php/ext/php_mbstring.dll
   extension=c:/php/ext/php_mysqli.dll
   extension=c:/php/ext/php_openssl.dll
   extension=c:/php/ext/php_soap.dll
   extension=c:/php/ext/php_xmlrpc.dll

(these are a minimum. You may need others - e.g. LDAP - for specific functions) ...and save.

Back in the 'cmd' window for Apache, you need to restart it to load your changes...

   httpd -k restart

Step 5: Test your install

Navigate to C:\Apache24\htdocs and create a file called 'test.php'. I had to change a file explorer setting to create .php files - Organise > Folder and search options > View and then untick 'Hide extensions for known file types'.

In this file enter the single line...

   <?php phpinfo();

And then, in your browser, navigate to http://localhost/test.php. You should see a screen with masses of information and the PHP logo at the top. Check a few lines down for 'Loaded Configuration File' and make sure it says c:\php\php.ini.

That's PHP and Apache all working :)

Step 6: Install Git

We will use the Git version control system for loading and updating the Moodle software. If you really don't want to do this you can just download the latest Moodle zip file and unzip it in c:\Apache24\htdocs but Git makes updates MUCH easier. We need to install Git first...

  • Go to http://msysgit.github.com. Navigate to 'Downloads' and download/run the latest installer.
  • Accept defaults until you get to 'Adjusting your PATH environment'. Select 'Run Git from the Windows Command Prompt' at this point.
  • Accept remaining defaults and install
  • If you right click on folders in the file explorer you should now see additional Git commands.

Step 7: Install Moodle

  • In the file explorer navigate to C:\Apache24\htdocs.
  • Inside the folder, right click and select Git GUI
  • Select 'Clone existing repository'
  • Use the following settings for the clone...
   Source location: https://github.com/moodle/moodle.git
   Target directory: C:/Apache24/htdocs/moodle

(You can also try git://git.moodle.org/moodle.git. Depending on your firewall situation one may work and the other not. The code is the same.)

  • Click 'Clone'. Depending on your network speed, this may well take a while as the whole Moodle history is being downloaded.
  • You should now have a 'moodle' directory inside 'htdocs. Right click and select 'Git GUI' again - a more complex screen should now appear
  • Click on the 'Branch' command and then 'Checkout...'.
  • Select the version of Moodle you want from the list, probably origin/MOODLE_24_STABLE. Make sure 'Tracking branch' is selected and click Checkout.
  • Create a data directory for Moodle. It can be anywhere you like but I used C:\moodledata. Just create an empty folder
  • Go to http://localhost/moodle. The language select page should come up and you are away. The installation is not covered in detail here but...
    • Data directory is C:\moodledata (or whatever you created)
    • Database user is 'root' (unless you created a more restricted user)
    • Database password is whatever you set installing MySQL

That should be it! Time for a cup of tea.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来表示数据库表,使用类的实例表示表中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 表达式语言: SQLAlchemy 提供了一个丰富的 SQL 表达式语言,允许开发者以 Python 表达式的方式编写复杂的 SQL 查询。 表达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值