티스토리 뷰

1. Apache2

1-1. Apache Version

$ httpd -v

$ apachectl -v


1-2. Apache HTTP Server Control Interface

$ sudo apachectl [command]

# apachectl [command]


$ sudo apachectl start


http://localhost/


1-3. System Level Web Root

The default system document root is still found at -

http://localhost:80/


The files are shared in the filing system at -

/Library/WebServer/Documents/


Configuration file -

/etc/apache2/httpd.conf


1-4. User Level Web Root

The other web root directory which is missing by default is the ‘~/Sites’ folder in the User account. This takes a bit longer to set up but some users are very accustomed to using it.

$ mkdir ~/Sites


You need to make a “Sites” folder at the root level of your account and then it will work. Once you make the Sites folder you will notice that it has a unique icon which is a throwback from a few versions older. Make that folder before you set up the user configuration file described next.

You have to make a few additional tweaks to get the ~/Sites folder back up and running.



Add a “username.conf” filed under:

/etc/apache2/users/


If you don’t already have one (very likely), then create one named by the short username of the account with the suffix .conf, its location and permissions/ownership is best tackled by using the Terminal, the text editor ‘nano‘ would be the best tool to deal with this.


Launch Terminal, (Applications/Utilities), and follow the commands below, first one gets you to the right spot, 2nd one cracks open the text editor on the command line (swap ‘username‘ with your account’s shortname, if you don’t know your account shortname type ‘whoami‘ the Terminal prompt):


$ cd /etc/apache2/users

$ sudo nano username.conf


Then add the content below swapping in your ‘username’ in the code below:

<Directory "/Users/username/Sites/">

AllowOverride All

Options Indexes MultiViews FollowSymLinks

Require all granted

</Directory>


Permissions on the file should be:

$ ls -l dhkim.conf

$ sudo chmod 644 dhkim.conf


Open the main httpd.conf and allow some modules:

$ sudo vi /etc/apache2/httpd.conf


And make sure these 3 modules are uncommented (the first 2 should be on a clean install):

LoadModule authz_core_module libexec/apache2/mod_authz_core.so

LoadModule authz_host_module libexec/apache2/mod_authz_host.so

LoadModule userdir_module libexec/apache2/mod_userdir.so


And also uncomment this configuration file also in httpd.conf

Include /private/etc/apache2/extra/httpd-userdir.conf


Then open another Apache config file and uncomment another file:

$ sudo vi /etc/apache2/extra/httpd-userdir.conf


And uncomment:

Include /private/etc/apache2/users/*.conf


Restart Apache for the new file to be read:

$ sudo apachectl restart


Then this user level document root will be viewable at:

http://localhost/~username/

You should only see a directory tree like structure if the folder is empty.


1-5. Override .htaccess and allow URL Rewrites

If you are going to use the document root at /Library/WebServer/Documents it is a good idea to allow any .htaccess files used to override the default settings – 

this can be accomplished by editing the httpd.conf file and setting the AllowOverride to All and then restart Apache. This is already taken care of at the Sites level webroot by following the previous step.


$ sudo vi /etc/apache2/httpd.conf

AllowOverride All


Also whilst here allow URL rewrites so your permalinks look clean not ugly. Uncomment in httpd.conf

LoadModule rewrite_module libexec/apache2/mod_rewrite.so



2. PHP

PHP 5.5.38 is loaded in the final build of OS X 10.10 Yosemite and needs to be turned on by uncommenting a line in the httpd.conf file.


$ sudo vi /etc/apache2/httpd.conf

Uncomment the line (remove the #):

LoadModule php5_module libexec/apache2/libphp5.so


Reload apache to kick in

$ sudo apachectl restart


To see and test PHP, create a file name it “phpinfo.php” and file it in your document root with the contents below, then view it in a browser.


<?php phpinfo(); ?>

댓글
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
링크
공지사항
Total
Today
Yesterday