Objective:
- Can have a test server, not all of the special network services can be found free!
Why isApache
- The most widely used WEB server,
IIS (Microsoft Intenet infomation 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
FinderCreate 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
cdSwitch directories
pwdConfirm current Directory
lsList 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里面只能用键盘,不能用鼠标# 用vim编辑httpd.conf$ sudo vim httpd.conf# 查找`DocumentRoot`* /DocumentRoot# 进入编辑模式* i# 修改`两处`引号中的路径# 继续向下找到Options FollowSymLinks Multiviews# 加一个单词 `Indexes`,修改后的结果如下:Options Indexes FollowSymLinks Multiviews# 返回命令模式* ESC# 查找php* /php# 将光标移动到首行* 0# 删除行首注释 #* x# 保存并退出* :wq# 不保存退出!!!!!!!!!* :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!
Tip: Don't take a minute to learn vim at the moment.
- 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 *.*
How to configure the Apache server