program development

Construction of php environment for Mountain Lion system

I started macbookpro a few days ago, and I feel a lot after using it for a few days. Let's stop talking and get straight to the point. Because it requires website construction, it requires a php environment. […]

article directories

I started macbookpro a few days ago, and I feel a lot after using it for a few days. Let's not talk nonsense here and get straight to the point. Because it requires website construction, it requires a php environment.

Open the terminal and run the start Apache command:

sudo apachectl start

Close command:

sudo apachectl stop

Restart command:

sudo apachectl restart

Check the Apache version of commands:

httpd -v

After enabling Apache, you can access http://localhost directly in the browser, if "It works!" appears It means that the operation is normal.

Here is how to enable php

Open the following file:

sudo nano /etc/apache2/httpd.conf

Then search for "php", and the first match should be the following code:

LoadModule php5_module libexec/apache2/libphp5.so

Remove the #before this code and save the file.

Next, restart Apache again:

sudo apachectl restart

Now that PHP should be working, you can put a PHP test file in the user-level root directory (~/Sites/), with the code as follows:

<? php phpinfo(); ?>

The third step of mysql installation

Mysql is not integrated in Mountain Lion and requires manual installation. You can click this link to download the MySQL installation package. Please download Mac OS X ver. 10.6(x86, 64-bit), DMG Archive(works normally under Mountain Lion).

After clicking Download, you will be redirected to a registration/login page. You don't need to register or login. Just click the button below the login box: No thanks, just take me to the downloads! You can skip this step and start downloading directly. The entire DMG package is about 113MB.

After the software is installed, enter "System Preferences". At the bottom of the panel, you will see a MySQL setting item. After clicking it, you can start MySQL, or you can open it with the following command:

sudo /usr/local/mysql/support-files/mysql.server start

If you want to check the version of MySQL, you can use the following command:

/usr/local/mysql/bin/mysql -v

After running the above command, you will log in to MySQL directly from the command line and enter the command q to exit.

As the last step, you should also set a root user password for your MySQL, with the following command:

/usr/local/mysql/bin/mysqladmin -u root password 'Enter the password you want to set here'

One thing to note is that if the first installation fails and the mysql cannot start, it is recommended to install it several times. I installed it at least 5 times and almost gave up on uninstalling it. Speaking of uninstall, here's how to uninstall mysql. After you install mysql, you can't see the mysql files. There is only the mysql icon in the system preferences, which is actually the one that launches mysql.

First stop all mysql related processes on the home page.
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

Without any surprises, the php environment will be ready... How to communicate with each other? Next, my QQ page is on the homepage, and I am a mac Xiaobai..