Search from the Internet casually, follow the steps to modify/etc/apache2/httpd.conf
On the internet for half a day, I was missing a sentence of this
#LoadModule userdir_module libexec/apache2/mod_userdir.so
It's mine, it's been changed.
Last Login:thu One +: to: -On Ttys003hanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/apache2/Httpd.confhanxueyingdemacbook-pro:~hanxueying$ sudo apachectl restarthanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/Apache2.httpd.confPassword:hanxueyingdeMacBook-pro:~ hanxueying$ sudo vi/etc/apache2/Httpd.confhanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/apache2/httpd-Userdir.confhanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/apache2/extra/httpd-Userdir.confhanxueyingdemacbook-pro:~hanxueying$ sudo apachectl restarthanxueyingdemacbook-pro:~ hanxueying$ vi/etc/apache2/users/Hanxueying.conf[no Write since last change]/bin/Bash:wq:command not Foundshell returned127Press ENTER or type command toContinue[No write since last change]/bin/Bash:wq:command not Foundshell returned127Press ENTER or type command toContinue[No write since last change]press ENTER or type command toContinueHanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/apache2/users/Hanxueying.confPassword:hanxueyingdeMacBook-pro:~hanxueying$ sudo apachectl restarthanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/apache2/users/Hanxueying.confPassword:hanxueyingdeMacBook-pro:~ hanxueying$ sudo vi/etc/apache2/users/Hanxueying.confhanxueyingdemacbook-pro:~ hanxueying$ sudo vi/etc/apache2/httpd.conf## This isThe main Apache HTTP server configuration file. It contains the# configuration directives that give the server its instructions.# see<url:http://httpd.apache.org/docs/2.4/> for detailed information.# in particular, see#<url:http://httpd.apache.org/docs/2.4/mod/directives.html># fora discussion of each configuration directive.## does not simply read the instructionsinchHere without understanding# what they Do. They'Re here only as hints or reminders. If you are unsure# Consult the online docs. You have been warned.## Configuration and logfile names:if the filenames you specify formany# of the server's control files begin with "/" (or "drive:/" for Win32), the# Server would use thisExplicitPath. If the Filenames Do*not*begin# with"/", the value of ServerRoot isprepended--so"Logs/access_log"# with ServerRootSetTo"/usr/local/apache2"would be interpreted by the# server as "/usr/local/apache2/logs/access_log", whereas"/logs/access_log"# would be interpreted as '/logs/access_log'. # # Serverroot:the Top of the directory tree under which the server's# Configuration, error, and log files are kept."/etc/apache2/httpd.conf" 531L, 20592C
And in the/private/etc/apache2/users/your username.conf to write as
" /users/yourusername/sites/ "> Options Indexes multiviews allowoverride None Require all granted</ Directory>
OS X Apache configuration, if encountered "the requested URL/~your Username/was not found on this server." Here are the detailed answers