How to reinstall the original Apache after Mac OS X is deleted, osapache

Source: Internet
Author: User
Tags install brew

How to reinstall the original Apache after Mac OS X is deleted, osapache

I have been saying on the Internet that it is not recommended to delete the Apache that comes with OSX.

But now that you have deleted it, you have to install it and update it along with it.

Okay, start


Install brew directly, saving time and effort. If you prefer to manually install brew, we recommend that you set it up first.

Get Apache first. Baidu didn't know where to download it for half a day.

Later, I realized that the original goods was named httpd ......)


Step 1:

-------------------------------------------------- Manual operation control --------------------------------------------------

Apache httpd:

Download link: http://httpd.apache.org/download.cgi


This is for PHP. You need to click "Old archives" on the right of the Old version such as 5.3.

Download link: http://php.net/downloads.php


For httpd installation, run the terminal first. For 32-bit system hosts, use i386.

sudo ./configure --prefix=/usr/local/apache2 --with-apr=/usr/sbin/apr --with-apr-util=/usr/sbin/apr-util --host=amd64

If you're lucky, you certainly don't have an error. If you're lucky, use brew to install the apr and apr-util.

Then let's make & make install. After the installation, all the files will go to/usr/local/apache2.

Open httpd. conf in conf to configure ServerRoot, Listen Port, Module, etc.

-----------------------------------------------------------------

Brew install what is missing

Brew install httpd24 press enter to wait

Then add the PHP extension Library

brew tap homebrew/dupesbrew tap homebrew/phpbrew tap josegonzalez/homebrew-php

If there is a problem, brew update before adding the extension.

After installing php, you need to write php54 in 5.4 and php55 in 5.5. The latest sub-version is automatically downloaded.

For example, I will download 5.3.29 after installing php53.

Brew install php53 press enter to wait


If the error message is "apxs", Apache does not use -- enable-so,/usr/share/httpd/build or something.

First create a soft link to httpd/usr/share, then cd to the httpd directory, and then

ln -s ./ /usr/share/httpd
The installation error is fixed again.

The httpd configuration file installed by brew is in/usr/local/etc/apache2/2.x/.

----------------------------------------------------------------- Tail control -----------------------------------------------------------------

Don't be too happy. There are still a lot of details to deal.

Step 2:

Edit the httpd. conf file.

Here are a few things we need to modify.

1. ServerRoot. The value is the directory where httpd is located. It must not be wrong.

2. Listen, port number, I used to 80

3. LoadModule. If the so file of the php cp is manually installed, go to the libexec directory in httpd; if it is installed by brew

A file similar to LoadModule php5_module/usr/local/Cellar/php53/5.3.29/libexec/apache2/libphp5.so should be automatically added

4. Change "Daemon" and "Group Daemon" to "www ".

5. ServerAdmin, Administrator email, can be changed or not

6. ServerName. If the # number is added, change it to localhost or 127.0.0.1.

7. DocumentRoot is the www folder in Windows. We recommend that you change it to/Users/user name/Sites. If no Sites is created,

After modification, the following <Directory should also be changed to the same value as DocumentRoot.

After saving the changes, we still cannot access the php web page at this time. Do not believe to write a php file in the Sites directory.

<?phpphpinfo();?>
Of course, before opening the terminal, we will run the following command:

sudo apachectl start

Then open localhost in the browser and check whether the php code is directly available --

Okay, don't let it go. let's solve this problem.

Create a new file, such as within the split line:

Bytes --------------------------------------------------------------------------------------------------------------------

#
# Additional PHP Apache ctives ves,
# Part of the entropy. ch PHP package for Mac OS X
#
# For more information, go to http://www.entropy.ch/software/macosx/php/
#
# Change the php module path to the location of your so file.
LoadModule php5_module/usr/local/Cellar/php53/5.3.29/libexec/apache2/libphp5.so

# This solves the problem of php code display.
<IfModule mod_php5.c>

AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps

# This setting allows default access to index. php
<IfModule mod_dir.c>
DirectoryIndex index.html index. php
</IfModule>
</IfModule>

Bytes --------------------------------------------------------------------------------------------------------------------

Save it as php. conf. Manually install httpd and put the file under/etc /.

Put brew's child paper in/usr/local/etc/php/5.x/.

Then edit the httpd. conf file again.

Comment out the php5_module line in LoadModule (add # above #)

Add a sentence at the end of the file:

Include/etc/php. conf or

Include/usr/local/etc/php/5.x/ php. conf

Then save


Step 3:

Open the php. ini file in the php Directory and find [Date]. There is a line below; date. timezone =

Change to date. timezone = PRC save

PHP Warning: phpinfo (): It is not safe to rely on the system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.