In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the "mac os apache configuration method" related knowledge, in the actual case of the operation process, many people will encounter such a dilemma, then let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
The Mac OS X version I use is 10.8.2, and the Mac comes with an Apache environment.
start Apache
Set up virtual hosts
start Apache
Open "terminal" and type sudo apachectl -v,(machine secret may be required). The Apache version is shown below.
Then type sudo apachectl start and Apache starts. Open the Safari browser address bar and enter "http://localhost" to see the content "It works!" "The page. It is located under "/Library/WebServer/Documents/," which is Apache's default root directory.
Apache is installed in/etc/apache2/, which is hidden by default. There are three ways to view:
1. Right click Finder under dock, select "Go to folder" and enter "/etc"
2. Under finder----> Go to---> Go to folder and type/etc
3. You can type "open /etc" in terminal
Set up virtual hosts
1. Run "sudo vi /etc/apache2/httpd.conf" on the terminal and open the configuration file of Apche
2. Find "#Include /private/etc/apache2/extra/httpd-vhosts.conf" in httpd.conf, remove the previous "#," save and exit.
3. Run "sudo apachectl restart", restart Apache and turn on the virtual host configuration function.
4. Run "sudo vi /etc/apache2/extra/httpd-vhosts.conf" to open the configuration virtual host file httpd-vhosts.conf and configure the virtual host. Note that this file opens two virtual hosts by default as examples:
The code is as follows:
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
In fact, these two virtual hosts do not exist. When no other virtual hosts are configured, the following prompt may appear when accessing localhost:
Forbidden
You don't have permission to access/index.php on this server The easiest way to do this is to put #in front of each line and comment it out, so that you can refer to it without causing other problems.
5. Add the following configuration
The code is as follows:
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
ErrorLog "/private/var/log/apache2/localhost-error_log"
CustomLog "/private/var/log/apache2/localhost-access_log" common
DocumentRoot "/Users/snandy/work"
ServerName mysites
ErrorLog "/private/var/log/apache2/sites-error_log"
CustomLog "/private/var/log/apache2/sites-access_log" common
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
Save exit and restart Apache.
6. Run "sudo vi /etc/hosts", open the hosts configuration file, add "127.0.0.1 mysites", so you can configure the sites virtual host, you can access "http://mysites", Mac OS X version before 10.8 its content and "http: /localhost/~[username]" exactly the same.
7. Note that logging "ErrorLog "/private/var/log/apache2/sites-error_log"can also be deleted, but logging is actually a good habit to help us judge when problems occur. If you keep these log codes, certain log file paths exist, and if you change one that doesn't exist, Apache will fail to serve without an error prompt.
"Mac OS apache configuration method" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.