Apache is an ordinary server. It only supports HTML, that is, ordinary web pages. It can support PHP through plug-ins, and it can also connect with Tomcat (one-way Apache connection to tomcat, that is, it can access Tomcat resources through APACHE). Tomcat cannot access the Apache resource. Apache only supports static web pages, but dynamic web pages such as ASP, PHP, CGI and JSP need Tomcat to handle. For Apache tomcat, it is estimated that many children’s shoes will be installed. Today, let’s talk about the installation of Tomcat on Mac;
I downloaded Tomcat yesterday. I thought it would be finished soon, but I still encountered some pitfalls. Here is a brief introduction to the installation process:
1. Download tomcat, address: http://tomcat.apache.org/download-80.cgi
Mac download zip and tar.gz All right. I downloaded it tar.gz
2. After compression, it is directly copied to the resource library. The name of the compressed folder is tomcat8, and the specific location is as follows:
3. Open the terminal and enter the following command library / tomcat8 / bin/ startup.sh , enter in browser localhost:8080 , you can see the following effect:
If you encounter an error prompt no such file or directory, you need to execute sudo Chmod 755 library / Tomcat / bin / *. Sh, and then execute it again startup.sh , if you want to stop tomcat, execute it directly shutdown.sh That’s it. When doing sudo, you must use a user with a password. If it is troublesome to write the path every time, you need to set the environment variable at this time.
4. Setting environment variables of Tomcat
① Enter touch. Bash_ profile ( pico .bash_ Profile is OK
② Open Bash_ profile open -e .bash_ profile(nano .bash_ Profile
③ Enter export path = $path / users / keso / library / tomcat8 / bin
④ Update the configured environment variable source. Bash_ profile
⑤ Verify whether it is successful. Enter $path in the terminal
The display is as follows – bash / usr / local / bin / usr / bin / bin / usr / SBIN / SBIN / users / keso / library / tomcat8 / bin: no such file or directory
5. Input in the terminal startup.sh ， startup.sh After that, a similar “permission denied” appears. At this time, you need to set the permissions of the directory: enter sudo Chmod 755 library / tomcat8 / bin / *. Sh to set the read / write execution permissions of the file;
6. After setting startup.sh The start:
7. Closing needs to be used shutdown.sh That’s it;
Digression: sudo is usually the super administrator of the system. 755 represents that the user has the right to read, write and execute the file. Other people in the same group have the right to execute and read the file. Without the right to write, other users have the same right as the people in the same group. 777 represents that users, groups and others all have read-write and executable permissions.
Manage Apache that comes with Mac OS
Apache and PHP are built into Mac OS X
Management method 1:
Open System Preferences > sharing > Web sharing
Management method 2:
Start Apache: run “sudo apachectl start”, and then enter the password of the root account
Stop Apache: run “sudo apachectl stop”,
Check Apache: Version: run “sudo apachectl-v”,
Restart Apache: run “sudo apachectl restart”
Default location of Apache files in Mac OS
Apache 2 configuration file for Mac OS（ httpd.config ）Save in / etc / apache2
The program files (httpd, ab) of apache2 on Mac OS are stored in / usr / SBIN/
Default root directory of apache2 on Mac OS: Library / webserver / documents
Modify the configuration file of apache2 and run “sudo VI / etc / apache2” on the terminal/ httpd.conf ”, open the configuration file of apche to modify.
Modifying hosts configuration in Mac OS
Run “sudo VI / etc / hosts” and open the hosts configuration file, which can be understood by local DNS.
Description of Apache AB stress testing tool for Mac OS
Mac OS comes with apache2.2.22, and the supporting AB testing tool is not easy to use.
So on March 25, 2012, the new Apache 2.4.1 was installed in / usr / local / Apache.
And copy / usr / local / Apache / bin / AB to / usr / SBIN / AB, covering the original ab.
AB version is 2.3, the trumpet is different. Now the AB testing tool is working.
Running PHP on Mac OS
Running “sudo VI / etc / apache2” in the terminal/ httpd.conf ”To open the Apache configuration file.
Find “# loadmodule PHP5_ Module libexec / apache2 / libphp5. So “, remove the #, save and exit VI (enter WQ on the command line).
Run “sudo CP / etc”/ php.ini.default /etc/ php.ini ”So you can run sudo VI / etc/ php.ini To edit php.ini All kinds of functions are configured. For example:
; adjust the maximum value of PHP submission file through the following two items, such as the maximum value of imported data in phpMyAdmin
upload_max_filesize = 2M
post_max_size = 8M
; via display_ Error to control whether the error information of PHP program is displayed, which is very useful when debugging PHP program
display_errors = Off
Run “sudo apachectl restart” and restart Apache so that PHP can be used.
Run “sudo CP / library / webserver / documents”/ index.html.en /Library/WebServer/Documents/ info.php ”, that is, copy in the root directory of Apache index.html.en File and rename to info.php .
Running “sudo VI / library / webserver / document” in the terminal/ info.php ”, so you can edit it in VI info.php The document is ready.
Add “<? PHP phpinfo();? >” after “it’s works!” and save it. So that you can http://localhost/info.php For example, the built-in PHP version number in 10.8 is 5.3.13.
Mac OS terminal color matching
Modify ~ /. Bash_ Profile file, add the following lines of configuration to the file.
# for color
# \h:\W \u\$
export PS1=’\[\033[01;33m\]\[email protected]\h\[\033[01;31m\] \W\$\[\033[00m\] ‘
alias grep=’grep –color=always’
Installing nginx on Mac OS
The PCRE and zlib libraries on which nginx is installed are included in my system.
However, when using the system’s own PCRE, make nginx reports an error:
-lpcre -lcrypto -lcrypto -lz
Undefined symbols for architecture x86_64:
“_pcre_free_study”, referenced from:
_ngx_pcre_free_studies in ngx_regex.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [objs/nginx] Error 1
make: *** [build] Error 2
I use the brew package manager (I don’t like ports)
Using the brew package management tool to re install PCRE (brew install PCRE), the problem has not been solved.
I unloaded PCRE again.
You can’t install PCRE manually.
You can only install MAC ports and then use port to install PCRE according to the official instructions.
sudo port install pcre