To configure the Apache server for:
- Able to have a test server, Apache server is FREE!
Why is
Apache
- The most widely used WEB server
- Mac comes with, only need to modify a few configuration can be, simple, fast
- Some special server functions, Apache can be very good support for example: HTTP
PUT
/ DELETE
operation, knowledge supplement involved in the HTTPS
service
Preparatory work
Configuration
Configuring the server's work
Finder
Create a folder in Sites
, directly /Users/apple
under the (current user name) directory
- Modify the configuration file
两个路径
, point to the folder you just created
- Copy a file
Configuring Server Considerations
- Close Chinese Input Method
- There is a need between the command and the parameter
空格
- Modify system files Be sure
sudo
to remember otherwise there will be no permissions
- Directory to be in
/Users/apple
(current user name)
Configure the server
Tip: $ start, can be copied, but do not copy $
# 切换工作目录$ cd /etc/apache2
Common commands
cd
Switch directories
pwd
Confirm current Directory
ls
List shows the contents of the current directory
# *** 备份文件,以防不测,只需要执行一次就可以了# 格式 cp (copy 的缩写) httpd.conf (源文件) httpd.conf.bak (目标文件)$sudo cp httpd.conf httpd.conf.bak# 提示:如果后续操作出现错误!可以使用以下命令,恢复备份过的 httpd.conf 文件$ sudo cp httpd.conf.bak httpd.conf
# vim can only use the keyboard, can not use the mouse # Use Vim to edit httpd.conf$ sudo vim httpd.conf# find ' DocumentRoot ' */ Documentroot# into edit mode * I# Modify the path in ' two ' quotes DocumentRoot "/users/your username/sites" <directory "/users/your user name/sites" ># continues to find options followsymlinks multiviews# plus a word ' Indexes ', The modified results are as follows: Options Indexes followsymlinks multiviews# return to command mode * ESC # find php*/php# move cursor to First line * 0# Delete beginning comment #* x# Save and Exit *: Wq# do not save exit!!!!!!!!! *: q!
# 切换工作目录$ cd /etc# etc 目录有点类似于 windows/system32,存放配置文件的目录$ sudo cp php.ini.default php.ini# 重新启动apache服务器$ sudo apachectl -k restart
The following error is normal if prompted:
httpd: Could not reliably determine the server‘s fully qualified domain name, using teacher.local for ServerNamehttpd not running, trying to start
Problems:
- If you click on
info.php
a file, the download appears, or you just display a short paragraph of text
Workaround:
Enter the following two commands in the terminal:
# 关闭 apache 服务器$ sudo apachectl -k stop# 启动 apache 服务器$ sudo apachectl -k start
- Each time you start your computer,
Apache
the server will not start automatically by default!
After you can start the computer, open the terminal and enter the following command:
# 启动 apache$ sudo apachectl -k start# 查询历史输入的命令$ history
The swap file already exists, directly by the letter "D", you can delete the swap file!
- When executing the script, show no access Denied! We use
NTFS
the format of the U disk copy network material! You may be able to filter out the permissions of the file itself!
Here are the instructions to modify the file permissions in the terminal!
644 info.php(没有权限的文件名)$ chmod 644 *.*
Detailed steps for configuring the Apache server in iOS