Apache server configuration under Mac

Source: Internet
Author: User

Apache server configuration under Mac
I. Apache server

1. The most widely used Web Server

2. The Mac comes with only a few modifications. It is simple and quick.

3. Some special server functions can be well supported by Apache

Objective: To have an exclusive test environment

2. Preparations

1. Set the User Password

2. MAC 10.10 and above

3. Configure the server (the vim command is used in this process. We recommend that you first understand it)

1. Common commands

Sudo apachectl-v // In general, Mac systems always have their own Apache environment. This command is used to view the Apache version of the current system.

  
In this process, the user is required to enter the password, which is hidden. after entering the password, press Enter.

Sudo apachectl-k start // start Apache

After this step, you can check whether Apche has been started. In the safari Address Bar, enter "http: // localhost" or "127.0.0.1". If "ItWork" is displayed on the webpage! "Indicates that it has been started.
Sudo apachectl-k stop // stop Apache

Sudo apachectl-k restart // restart Apache

2. Configure the server

1> Create a "Sites" folder in the Finder and directly create it in the/Users/apple (current user name) directory.

   

2> modify the "two paths" in the configuration file to point to the folder you just created (follow the steps in step 4)

3> copy an object (follow the 4. Procedure command steps)

3. server configuration considerations

1> disable the Chinese Input Method

2> A space is required between commands and parameters"

3> remember to modify the system file "sudo". Otherwise, you will not have the permission.

4> directory in/Users/*** (current user name): drag and drop the folder Sites you created to the terminal to view the path of the Apache server folder you created.

4. Configure the server process (run the following command Terminal)

// Switch the working directory
Cd/etc/apache2 // *** backup file to prevent unexpected events. You only need to execute it once (you can run the ls command to check whether httpd is added. conf. bak file) sudo cp httpd. conf httpd. conf. bak // prompt: if an error occurs in subsequent operations! You can use the following command to restore the backed up httpd. conf file (this step does not need to be executed) sudo cp httpd. conf. bak httpd. conf // use vim to edit httpd. conf (only the keyboard is used in vim, And the mouse is not supported) sudo vim httpd. conf // find DocumentRoot (the page will appear after the search)/DocumentRoot

"Keyboard direction key control, move the cursor to the first line"
"Modifying the path in quotation marks"
// Modify two lib/WebSer/Docume to our own server folder path (/Users/*** username ***/Sites)
"Press I to enter the editing mode" (the character at the bottom of the terminal indicates that the editing mode has been entered)
// Exit edit mode and enter command mode ESC
"Move the cursor to the first line ")
0 this is zero, not the letter o
"Save and exit": wq

"Continue to edit"
Sudo vim httpd. conf

"At this time, if you want to see if the change is successful, you can continue to execute the above/DocumentRoot to check whether the two paths have been changed"

"Find"
/Options

"Press the downward arrow to go down"

// Find
Options FollowSymLinks Multiviews

"Press I in edit mode"

// Add a word
Options Indexes FollowSymLinks Multiviews

// Search for php
/Php
"Move the cursor to the first line"
0
Delete the comment at the beginning of a row # (for example, press I to enter the editing mode. Press Esc to exit the editing mode after deletion)

// Save and exit: wq
// Exit without saving !!!!!!!!! (This step does not need to be executed. If you have entered an incorrect input, it will be executed.): q!
// Switch the working directory cd/etc
// Copy the php. ini file sudo cp php. ini. default php. ini
// Restart the apache server sudo apachectl-k restart (a warning is displayed indicating that it is normal). Test the Apache server by entering 127.0.0.1 in the address bar of the browser. At this time, you will find that it Work is still pitfall!

So please clear your safari --> "clear historical records and website data"

Enter "127.0.0.1" again.

If you want more content in your Apache, try the following steps.

Create a folder with the extension of. json or any other type. Put a piece of json text in it and put it in the Sites folder.



Enter 127.0.0.1/demo. json.

 

Apache is a server. To ensure user security, Apache will not be automatically started every time it is restarted.

Enter the terminal and start it once manually

4. Pay attention to the usage of common IOS exercises

In addition, if you use Xcode7, that is, IOS9, the output log is generated and data is not empty.

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

You need to configure info. plist as follows:

<key>NSAppTransportSecurity</key><dict>    <key>NSAllowsArbitraryLoads</key>    <true/></dict>
NSURL * url = [NSURL URLWithString: @ "http: // 127.0.0.1/demo. json "]; NSURLRequest * request = [NSURLRequest requestWithURL: url]; [NSURLConnection failed: request queue: [NSOperationQueue mainQueue] completionHandler: ^ (NSURLResponse * _ Nullable response, NSData * _ Nullable data, NSError * _ Nullable connectionError) {NSLog (@ "content: % @", [[NSString alloc] initWithData: data encoding: NSUTF8S TringEncoding]);}]; // output log 22:30:44. 662 Apache test [4382: 261834] content: {"messageId": "1", "message": "What is this ??? "}

 

 

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.