Apache + PHP + MySQL
Note:
Sudo indicates that the command is executed with the administrator privilege to protect the system files from being damaged. Using sudo requires a password.
I. vi shortcut keys. vi has two statuses: View status and edit status.
Exit the editing status of esc.
I insert at the current position
I insert at the beginning of a row
X Delete the current character
: Wq save and exit
: Q! Directly exit and save
/Search
1. Apache Web Server on apple, TomCat provides Web Services
Configure Apache for browsing.
1) start Apache
Sudo apachectl-k start
2) check Apache running status
Open Safari and enter http: // localhost. If you see It works! Indicates that Apache has been started.
3) The default Apache document directory is/Library/WebServer/Documents/
Normally, set files in this directory
4) create a personal website directory
A) create a Sites folder in the Finder.
B)
Cd/etc/apache2/users to enter the Apache user folder
Create a file, file hanging: User hanging. conf
Whoami can view the current user crane
Sudo vi apple. conf create a configuration file
Teacher: users apple $ sudo vi apple. conf
Enter the following content in the file, where/Users/apple/Sites/is the complete location of the previously created Sites folder
<Directory "/Users/apple/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
After adding the content, Press esc in vi to enter view mode. Enter wq to save and exit.
Restart Apache
Sudo apachectl-k restart
Test user folder
Http: // localhost /~ Apple/to access user folders
Before accessing the user folder, you must create an html file in the Sites folder.
Enter
<Html>
<Head>
<Title> test </title>
</Head>
<Body>
<H1> Hello World! </H1>
</Body>
</Html>
2. php
By default, php has been installed on Mac, but it is not activated. To use php, You need to modify the apache configuration file.
Cd/etc/apache2
Sudo vi httpd. conf
Enter/search for php
Find LoadModule php5_module libexec/apache2/libphp5.so
Start by I to the beginning of the line
Press esc to exit the editing status
Delete the current character by x
: Wq save and exit
Restart apache
Sudo apachectl-k restart
<? Php phpinfo ();?>
3. Configure the mysql shortcut
Cd/etc
Ls-l bashrc
Sudo chmod + w bashrc modify administrator write mode
Sudo vi bashrc
Add the following two lines to the end of the file:
Alias mysql = '/usr/local/mysql/bin/mysql'
Alias mysqladmin = '/usr/local/mysql/bin/mysqladmin'
Set administrator password
Mysqladmin-u root password "123"
For more information, see html and SQL files.