Mac OS X Leopard: Configure Apache, PHP, SQLite, MySQL, and phpMyAdmin (1)

Source: Internet
Author: User
Tags administrator password
Update history:
: The sections were reorganized to facilitate reading.
Added some content and rewritten the preface.

Preface :
Lamp systems are widely used in many network systems, including open software systems. OS X is a commercial desktop/server system that is one of the mainstream graphic user interfaces based on BSD, it originally supports lamp (not exactly), but by default, the main elements in lamp (Apache, MySQL, and PHP) are disabled, you only need several steps to enable these features.
Despite this idea, various problems still occur when configuring these software, especially when operating on leopard. Due to the differences between different parts and versions, it may cause some trouble, so it is necessary to record it for future use. This article also hopes to provide instructions on the configuration of each software on the Mac system as a reference; in addition, take into account the features of the system administrator as much as possible, and try to use shell commands to make management work as automated as possible.

OS X Leopard 10.5 comes with various software versions that can meet the requirements of most systems. My system is currently 10.5.5, and its Apache is 2.2.9 (the latest open source version 2.2.11 ), PHP is 5.2.6 (the latest version is 5.2.8 ). the biggest problem with lamp on MAC systems is that these components may need to be targeted at the binary version of OS X, and PPC/Intel/universal binary may also be a problem, according to Apple, they can work well under Rosetta, But I didn't test it. In short, these upgrades may need to be released by a third party or apple.

I. Web Services:
1. enale Apache
The apache2 program is stored in the/etc/apache2 directory.
This function can be opened in a GUI, as shown in the following figure:

Note 1
Note 1

After completing the above work, you can test whether the Web server is working. Open any browser and enter http: // localhost/to view the simple image of Apache.

Use the following shell command:

  1. Sudo apachectl start

At the same time, the Web serice of OS X has a feature, that is, it automatically opens the Web Service for every user on the machine, in other words, you can enter the user's address in the browser to view the user's web page, for example: http: // localhost /~ Student /.

2. another point is that the default root directory of web content is/library/webserver/documents, and each user's own is/users/username/sites /. these settings can be found in/etc/apache2/httpd. find the corresponding settings in the conf file.

3. Firewall:
If you want to allow users on the LAN or Internet to access your web, check whether the firewall of OS X has opened a port for the web service, when you open the web server, the system automatically opens the port, but if there is no access problem, you should check it. This setting is displayed:


4. Disable User Web Services:
If the administrator wants to disable a user's web service, it is a good solution. You only need to delete or move the conf file of the corresponding user, the conf file corresponding to each user can be found in the/etc/apache2/users/directory.

Ii. php
1. Enable PHP
The PHP configuration file PHP. INI is stored in the/etc/directory, and its program is in the/usr/apache2/libexec/directory.
In fact, PHP support has been built in, but it has been commented out. Look,

This line is found: # loadmodule php5_module libexec/apache2/libphp5.so. there is a # symbol at the beginning. This line is changed to a comment line, as long as we delete the # symbol and run Apache again.
It is a good habit to make a backup before modifying the content.

  1. CP/private/etc/apache2/httpd. conf/tmp/httpd. conf
  2. MV/private/etc/apache2/httpd. conf/private/etc/apache2/httpd.conf.org

Use any familiar text editor to edit/tmp/httpd. conf and delete. I use the Nano in terminal. It is a built-in Editor:

  1. Nano/tmp/httpd. conf

Press Ctrl + W and enter PhP5. Then, the nano will find the row. After deletion, press Ctrl-X to check whether the change is saved, enter y, and press Enter, you can save it, and finally move the files in the/tmp directory back. (If the system asksPassword, Enter the administrator password)

  1. MV/tmp/httpd. conf/private/etc/apache2/
  2. Sudo chown root: wheel/private/etc/apache2/httpd. conf

2. Set Change inspection:
First, run the following command to restart Apache or restart the computer:

  1. Sudo/usr/sbin/apachectl restart

Finally, the test result is displayed. Open textedit and enter the following line of code:

  1. <? PHP phpinfo ();?>

The file name saved to the user's sites directory isPhpinfo. phpFile, and then enter http: // localhost/~ in the address bar of the browser /~ Test/phpinfo. php, as long as the above steps are correct, you can see the PHP infomation page.

3. Use SQLite.
In phpinfo, you can find that SQLite has been opened. For details, see:

In general, there is no problem with the above operations. After all, it is built into leopard, but the work in this section requires some patience. Please refer to Mac OS X Leopard: Configuring Apache, PHP, SQLite, MySQL, and phpMyAdmin (2 ).

NOTE 1: The resource is from the page in Ref.
Ref: http://developer.apple.com/mac/articles/internet/phpeasyway.html

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.