Setting up a local development plattform on windows using xampp

You can download a copy of xampp here: http://www.apachefriends.org/en/xampp-windows.html.

Klick on download xampp to get your copy. (XAMPP stands for X = cross-platform, Apache, MySQL, PHP and Perl)

Xampp is very popular and the best is its opensource and free. In the xampp package there is also a copy of phpmyadmin which is very usefull to administer your database. In the xampp package there are also other interesting tools like xdebug, apc and lots more...

You can also use another package like wamp (server) or mamp if you want to develop on a mac.

Click on the downloaded xampp.exe to install the package on your computer. Follow the steps of the setup wizard. After the installation finished, you will get asked if xampp should locate the pathes, press "Y" to accept or enter "N" to deny and press "ENTER" (i recommend you press "Y"). Then confirm by pressing "Y" again.

Then xampp asks you if you want xampp to be installed as portable version, this is nice because you can put xampp on your usb stick and use it on different computers, the disadvantage you won't be able to start xampp as a service, i only have one computer and don't like to start my xampp every time i restart my computer. Therefore i have choosed to enter "N".

The last step helps you configure several components. Press ENTER (RETURN) to accept the default php timezone. You will be able to change this later. Now you get asked what next step should be, press "1" to launch the xampp control panel. Installation is now finished, you can close the window. I recommend that you don't use the control panel just yet. Press the exit button, before launching apache and mysql we will change some options in the configuration files first.

Now we should create a virtual host. This is important because later we will have several websites and its easier to manage them if each one has its own domain. For our app we will create a domain www.myapp.dev.

To create a new virtual host you first must open the PATH_TO_XAMPP/xampp/apache/conf/extra/httpd-vhost.conf file. Your file content should look like this (for example for me "PATH_TO_XAMPP" is "C:"):

1
2
3
4
5
6
7
8
9
10
11
12
NameVirtualHost *:80
  
<VirtualHost *:80>
     ServerName myapp.dev
     DocumentRoot PATH_TO_XAMPP/xampp/htdocs/myapp/public
     <Directory PATH_TO_XAMPP/xampp/htdocs/myapp>
         DirectoryIndex index.html index.php
         AllowOverride All
         Order allow,deny
         Allow from all
     </Directory>
</VirtualHost>



The DirectoryIndex directive sets the list of resources to look for, when the client requests an index.

You must have "AllowOverride All" in effect if you to allow that your htaccess can override all the directives declared previously. We will use the htaccess to set most of our directives because its a little bit more flexible then the apache conf. The advantage is that you don't have to reload / restart apache after changing a directive in your htaccess. If you change a directive in the conf file you must reload / restart apache to activate the directive.

Order allow,deny means that first, all "allow" directives are evaluated, at least one must match, or the request is rejected. Next, all "deny" directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allow or a Deny directive are denied by default.

(You could for example use Allow from "your own IP" to only allow yourself to access the website until you finished testing it, or use Deny from "add an IP here that you want to block" to block an IP)

More about the directory directive: http://httpd.apache.org/docs/1.3/mod/core.html#directory

Now you must open your windows hosts file. Open your text editor but click on "run as administrator" or you wont be able to save the file. The hosts file can be found here: PATH_TO_WINDOWS/System32/drivers/etc/hosts (for example for me "PATH_TO_WINDOWS" is "C:/Windows"). If you can't find the folder it might be hidden. Open the windows directory, then press the "Alt-Key", now click on "Tools" and then "Folder Options". Finally choose on the "View" tab and then find the "Hidden files and folders" option, then click on the "Show hidden files, folders, and drives" radio button.

Add these two lines to it:

1
2
127.0.0.1       localhost
127.0.0.1       www.myapp.dev



Then save the file.

When you have finished configuring Apache you should open the xampp control panel, if awindows firewall popup comes up click on unblock to add a rule for xampp. To start Apache click in the control on start, then click on the Mysql start button. I recommend you start both as a service, if you check the service checkbox (Svc) before starting then you wont have to start them every time you restart your computer.

To open phpmyadmin use this path: http://localhost/phpmyadmin/

To see your website go to: http://www.myapp.dev

UPDATE 1: If xampp's apache doesn't start then try those two things:

1) Perhaps your port 80 is already being used by another program for example by skype. It's easy to check if the port 80 is available, open the xampp control panel an press the "port check" button on the right. If xampp tells you that the port is being used by another program, ou will have to change the port on which apache should listen. Open the httpd.conf located here: PATH_TO_XAMPP/xampp/apache/conf/httpd.conf. Find the line "Listen 80" and change it to use another port, for example "Listen 8080".

2) You perhaps have a conflict in your php.ini (php configuration file), your httpd.conf (apache configuration file) or the vhosts.conf (apache virtual hosts configuration file). To check if apache found an error, check your logs that are located here: PATH_TO_XAMPP/xampp/apache/logs/. If there is a conflict in one of your configuration files you should fine an error msg in the logs. Copy the error message and do a search in google.

UPDATE 2: Install, enable apc (Alternative PHP Cache / opcode cache)

In older version of xampp you had to install apc, but anymore, modern version of xampp have a preinstalled apc .dll but it's not enabled by default.

To enable apc, open your php.ini and find the following line: "extension=php_apc.dll", uncomment that line and save your php.ini (PATH_TO_XAMPP/xampp/php/php.ini). Your done, now you only need to restart apache.

If you want to check if apc got enabled, use the phpinfo function and check if you find a block called "apc". Put the following code in a file called info.php and copy the file to your root folder, then open it in your browser: "http://www.myapp.dev/info.php".

1
phpinfo();



原文地址:http://www.chris.lu/en/news/show/4d40937fafbbe/


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值