Apache server and webDav server can be configured quickly .,
When you need to send a request by typing code at home, you can configure the local apache and Mac server. This is easier to use than the local server on windows. The following describes the fastest configuration scheme.
0. You need to set the boot password for your computer before starting. It is necessary to open a local server.
I. Local apache Server 1. First, create a sites folder under the folder named by your computer
If you did not see this article in the blog garden, click to view the original article
Put some background fake data. For example, in the/Users/dsx directory
2. Find the configuration file and back up the original file.
Next, enter the following command in the terminal (the code after $ can be copied directly)
// Switch the working directory
$ Cd/etc/apache2
// Back up the file to prevent unexpected events. You only need to execute it once.
$ Sudo cp httpd. conf httpd. conf. bak
// Prompt:Do not enter the following line of code. If an error occurs in subsequent operations! To use the following command:, Restore the backed up httpd. conf file (Dong baoran blog Park)
$ Sudo cp httpd. conf. bak httpd. conf
3. start modifying the configuration file
// Use vim to edit httpd. conf
$ Sudo vim httpd. conf
// Find DocumentRoot
/DocumentRoot
Press I to enter the editing mode
You can see that there are two paths to change them to the path of the Sites folder you just created.
Find the php
/Php
Move the cursor to the left and Press x to delete "#" to open the directory.
(For the 10.10 system, there is another step:You can also find the position in the graph and add a word between Options and Follow)
After the modification, Press esc to exit the editing mode, and then enter: wq to save and exit. If an error occurs and you do not want to save it, q!
4. Finishing and confirmation successful
// Copy the configuration file
$ Sudo cp php. ini. default php. ini
// The following statement is normal after the apache server is restarted
$ Sudo apachectl-k restart
The following is a normal sentence. Don't worry.
Then confirm whether it is successful. Enter localhost in the browser. If it can come to the following interface, it will be right.
5. Notes
Pay attention to the previous backup. Do not back up multiple times.
Make sure that all English characters and letters are used in vim.
The server switch command is
$ Sudo apachectl-k start
$ Sudo apachectl-k stop
When you try to use the server after the server is turned off, you need to re-open the command.
II. WebDav server
The next step is the WebDav server, which is based on apache, that is, you can enable the webDav server only after apache is started.
Of course, if apache has been fully configured, webDav will be well configured.
WebDav can be used as a file server shared by the network!
1. Continue Modification
$ Cd/etc/apache2
$ Sudo vim httpd. conf
// Find httpd-dav.conf
Httpd-dav.conf
You can also press I to edit it. After you locate this line, move the cursor to the leftmost and Press x to delete,
(If your computer is a 10.10 system, you also need to use the following underline :)
Search for the rows
LoadModule dav_module libexec/apache2/mod_dav.so
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
LoadModule auth_digest_module libexec/apache2/mod_auth_digest.so
And delete the # number at the beginning of their line (the reminder is that these presidents all look like they must see it clearly. Don't make a mistake)
Press esc to complete editing. Enter: wq to exit.
// Switch the Directory
$ Cd/etc/apache2/extra
// Back up the file (remember to back up the file once)
$ Sudo cp httpd-dav.conf httpd-dav.conf.bak
// Edit the file now
$ Sudo vim httpd-dav.conf.
// Check whether Digest changes the editing mode from Digest to Basic. After the modification, save and exit.
/Digest
2. Run the script file
Next, we need to use a script file
Baidu Network Disk: http://pan.baidu.com/s/1jG7ogdS password is: yj9t
// Switch the directory. You can drag the folder where the put script is located to the end of cd.
$ Cd: directory for saving the put script
// Run the put configuration script as an administrator
$ Sudo./put
Enter the password of your computer and set the password for the admin account, for example, 123456.
After the configuration is complete, a large string is displayed and the apache server is restarted.
3. verify whether the verification is successful
Check the IP address of your connected network in your network.
(Dong Boran blog Park)
Then open the Finder --> go to --> connect to the server --> and enter http: // 192.168.1.106/uploads (for example, enter your own IP address)
A dialog box will pop up. Select the registered user, account admin, and password such as 123456 to connect.
After the configuration is complete, you can write the url of the file in your server in the request url in the code. You can also download and upload files without connecting to the Internet.