Mac under Apache server configuration

Source: Internet
Author: User

One, Apache server

1. The most widely used WEB server

2. mac comes with, only need to modify a few configuration can, simple, fast

3. some special server functions, Apache can be very good support

Purpose: To have a test environment of your own

Ii. preparatory work

1. Set User password

2.MAC 10.10 and above

Third, configure the server (this process will use the VIM command, it is recommended to understand first)

1. Common commands

sudo apachectl-v//In general the Mac system comes with an Apache environment, and this command is useful for viewing the Apache version of the current system

  
This process will require the user to enter a password, the input is hidden, the user input to complete the direct return.

sudo apachectl-k start //Start Apache

After this step, you can see if Apche is already started, enter "http://localhost" or "127.0.0.1" in the Safari address bar, if the page appears "itwork! "Indicates that it has been started.
sudo apachectl-k stop  //Stop Apache

sudo apachectl-k restart  //restart Apache

2. Configuring the server's work

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

   

2> Modify the "Two paths" in the configuration file, point to the folder you just created (Follow the process command step for 4.)

3> Copy a file (follow the 4. Process command Step)

3. Configuring Server Considerations

1> closing Chinese Input method

A "space" is required between the 2> command and the argument

3> Modifying system files Be sure to remember "sudo", otherwise there will be no permissions

4> directory to/users/*** (current user name): Drag and drop the folder you created sites directly into the terminal to view the Apache server folder path you created

4. Configure the server process (the following command terminal executes)

Switch working directory

"Keyboard direction key control, move the cursor to the first line"
"Modify the path in quotation marks"
Modify two Lib/webser/docume to our own server folder path (/users/*** user name ***/sites)
"Press I into edit mode" (the terminal appears at the bottom of the character indicates that it has entered edit mode)
Exit edit mode, enter Command mode ESC
"Move cursor to First line")
0 This is zero, not the letter O
"Save and Exit": Wq

"Continue into Edit"
sudo vim httpd.conf

"At this point, if you want to see if the change is successful, you can continue with the/documentroot above to see if the two paths have changed."


/options

"Press DOWN ARROW to go down"




"Enter edit mode Press I"





/php
"Move cursor to First line"
0
Delete line Comment # (such as position, press I to enter edit mode, delete and press ESC to exit edit mode)

Save and exit: Wq
Do not save exit!!!!!!!!! (This step does not need to execute, if you write the wrong input wrong, it is executed): q!
Switch working directory Cd/etc
Copy php.ini file sudo cp php.ini.default php.ini
Restart the Apache server sudo apachectl-k restart (after which the warning appears as normal)
Test the Apache server in the browser address bar by typing 127.0.0.1, and you'll find out if you're still a dad. It work!

So, please clear your safari-->. "Clear History and site data"

Try typing "127.0.0.1" again.

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

Simply create a folder with a. JSON suffix name or whatever, put a JSON text inside it, and put it in the Sites folder.



Then enter 127.0.0.1/demo.json and try it.

Apache is a server, in order to ensure user security, every time you restart the computer Apache will not automatically start

Need to enter terminal, manually start once

Iv. some usage notes on normal iOS exercises

In addition, if you are Xcode7, that is IOS9, you will have this output log, 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.

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 sendasynchronousrequest:request queue:[nsoperationqueue Mainqueue] completionHandler:^ ( Nsurlresponse * _nullable response, NSData * _nullable data, Nserror * _nullable connectionerror) {                NSLog (@ "content:%@ ", [[NSString alloc] Initwithdata:data encoding:nsutf8stringencoding]);            }];/ /output Log 2016-01-17 22:30:44.662 Apache test [4382:261834] content:{    "messageId": "1",    "message": "What is this??? ”}

 

Mac under Apache server configuration

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.