First, the premise of site construction
Setting up the lamp running environment.
Download the website program, here with Discuz X 3.2 as an example
Discuz Program:
Simplified Chinese GBK Http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
Traditional Chinese BIG5 http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_TC_BIG5.zip
Simplified UTF-8 http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
Traditional UTF-8 http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_TC_UTF8.zip
Second, installation, configuration
# Create a Web site program Files directory [[email protected] ~]# mkdir/data/mydiscuz/<== Place the site program, a name you know # Unzip the installer, move the files inside the upload to the site monitoring directory/data /mydiscuz[[email protected] mydiscuz]# mv upload/*.
Modify the Apache Master Profile httpd.conf to turn on the virtual host configuration
# Virtual hosts# the comment "#" in front of this line to remove the include conf/extra/httpd-vhosts.conf
Modify the Apache virtual host profile httpd-vhosts.conf, keeping the following content,
[Email protected] ~]# vim/usr/local/apache2/conf/extra/httpd-vhosts.confnamevirtualhost *:80<virtualhost *:80 ># Admin email address, generally do not need, deliberately commented out #ServerAdmin [email protected]# host address ServerName www.myd.com# monitored files directory documentroot "/dat A/mydiscuz "</VirtualHost>
Detect configuration information, restart Apache service
Enter the IP address through the browser, the following interface appears:
650) this.width=650; "style=" width:600px;height:451px; "src=" Http://s3.51cto.com/wyfs02/M01/6C/2C/wKioL1VBmhuSqKN _aaq_bgwygs0375.jpg "title=" discuzinstall.jpg "alt=" wkiol1vbmhusqkn_aaq_bgwygs0375.jpg "height=" 451 "hspace=" 0 " Border= "0" vspace= "0" width= "~"/>
Click "I agree", go to the next step, you will see the current environment information, prompting the required directory does not have permissions, we need to make permission changes.
650) this.width=650; "style=" width:600px;height:600px; "src=" http://s3.51cto.com/wyfs02/M01/6C/2C/ Wkiol1vbmpsxxkgpaal8_yujvww199.jpg "title=" discuz00.jpg "alt=" wkiol1vbmpsxxkgpaal8_yujvww199.jpg "height=" 600 " Hspace= "0" border= "0" vspace= "0" width= "/>"
# Modify permissions for these directories [[email protected] mydiscuz]# chown-r Daemon.daemon data/> uc_client/data/uc_server/data/config/
Permissions modified complete, can next, we are the first installation, so choose a new installation, the next
650) this.width=650; "style=" width:600px;height:361px; "src=" http://s3.51cto.com/wyfs02/M01/6C/30/ Wkiom1vbnmnz8-j7aahcktogvuy364.jpg "title=" install.jpg "alt=" wkiom1vbnmnz8-j7aahcktogvuy364.jpg "height=" 361 " Hspace= "0" border= "0" vspace= "0" width= "/>"
Next I'll configure MySQL database information, create a database for the site, and the corresponding account
# MySQL for the first time, you need to configure MySQL with a MySQL administrator password [[email protected] ~]# mysqladmin -u root password ' mysql123 ' # log in to MySQL, you need to use a password [[Email protected] ~]# mysql -uroot -penter password:welcome to the mysql monitor. commands end with ; or \g.your mysql connection id is 7server version: 5.1.40-log MySQL Community Server (GPL) type ' help; ' or ' \h ' for help. Type ' \c ' to clear the current input statement.# Create a database named Mydiscuz, note that the end of each sentence of MySQL requires a semicolon ";", indicating the end of mysql> create database Mydiscuz; query ok, 1 row affected (0.00 sec) # All rights of the native Mydiscuz database to a user named Mydiscuz, with a password of mydiscuz123mysql> grant all on mydiscuz.* to ' Mydiscuz ' @ ' localhost ' identified by ' mydiscuz123 '; query ok, 0 rows affected (0.00 sec) # exit End mysqlmysql> exit; bye[[email protected] ~]#
Now that the database basic information has been created, go to the browser, configure
650) this.width=650; "style=" width:600px;height:612px; "src=" http://s3.51cto.com/wyfs02/M01/6C/30/ Wkiom1vbo0szzf56aaotjj_c81g920.jpg "title=" mysqlinstall.jpg "alt=" wkiom1vbo0szzf56aaotjj_c81g920.jpg "height=" 612 "hspace=" 0 "border=" 0 "vspace=" 0 "width="/> "
After the input is complete, the next step is to install
650) this.width=650; "style=" width:600px;height:526px; "src=" http://s3.51cto.com/wyfs02/M02/6C/30/ Wkiom1vbpgvtv1w9aamj1_eklbo351.jpg "title=" install123.jpg "alt=" wkiom1vbpgvtv1w9aamj1_eklbo351.jpg "height=" 526 " Hspace= "0" border= "0" vspace= "0" width= "/>"
Installation Complete
650) this.width=650; "style=" WIDTH:600PX;HEIGHT:619PX; "src=" http://s3.51cto.com/wyfs02/M01/6C/30/ Wkiom1vbpriyp1amaaq4mjicj-w733.jpg "title=" finish.jpg "alt=" wkiom1vbpriyp1amaaq4mjicj-w733.jpg "height=" 619 " Hspace= "0" border= "0" vspace= "0" width= "/>"
Third, the increase of Apache function configuration
The addition of Apache functionality is primarily a modification of the virtual configuration file httpd-vhosts.conf
1) User authentication
① Creating authenticated Users and Passwords with Htpassword
#-C for creation, only at the first build, configuration, if the subsequent use does not need to add the parameter-C, after adding will rewrite #-M to encrypt with MD5 [[email protected] ~]#/usr/local/apache2/bin/htpasswd-c/ DATA/MYDISCUZ/.HTPPASSWD mylinuxnew password:re-type new password:adding password for user mylinux[[email protected] ~]# # two different encryption schemes [[email protected] ~]# Cat/data/mydiscuz/.htppasswdmylinux:fq4fmf7jzfuny <== encrypted with random characters [[Email protect Ed] ~]# Cat/data/mydiscuz/.htppasswdmylinux: $apr 1$KSKAK0DY$EV/FH3TWLG2D2OR99APO3. <== encrypted with MD5 value [[email protected] ~]#
② Add the configuration to the following content
# user authentication <Directory *> AllowOverride AuthConfig # Input dialog box prompt information AuthName "Please input your info" # Specifying character Types AuthType Basic # Specify user file address authuserfile /data/mydiscuz/.htppasswd require valid-user </directory>
Example effect: When user authentication is enabled, enter the host address, the authentication window pops up, such as:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/2D/wKioL1VBuJ-zmYjYAAEr335QDiI337.jpg "title=" user authentication. jpg "alt=" wkiol1vbuj-zmyjyaaer335qdii337.jpg "/>
2) Domain name jump
Domain Jump: Host has more than one domain name address, has the primary domain address, will all point to the host domain name address, automatically jumps to the default primary domain address.
Configuration examples
# Domain Jump (Note: Jump function on the premise is to define the domain name alias, the address of all non-primary domain name is defined in the alias) <ifmodule mod_rewrite.c> # turn on the domain jump function rewriteengine on # Jump Condition One: The first domain address Rewritecond%{http_host} ^www.b.com [OR] # Jump condition Two: The second domain address Rewritecond%{http_hos T} ^www.c.com$ # Jump rule: All host domain address automatic jump execution, primary domain address Rewriterule ^/(. *) $ http://www.a.com/$1 [r=301,l] </ifmodul E>
3) Configure Apache log (error log and access log)
# Configuration Log # Configuration error log (additional log cutting feature) ErrorLog |/usr/local/ apache2/bin/rotatelogs -l /usr/local/apache2/logs/mydiscuz-error_%y%m%d.log 86400 " # set the content of the request SetEnvIf Request_URI ". *\.gif$" image-request SetEnvIf Request_URI ". *\.jpg$" image-request setenvif request_uri ". *\.png$" image-request setenvif request_uri ". *\.bmp$" image-request SetEnvIf Request_URI ". *\.swf$" image-request setenvif request_uri ". *\.js$" image-request SetEnvIf Request_URI ". *\.css$" image-request # Configure the Access log (additional log cutting feature) CustomLog |/usr/local/apache2/bin/rotatelogs -l /usr/ Local/apache2/logs/mydiscuz-access_%y%m%d.log 86400 " combined env=!image-request
4) Anti-theft chain
# Configure the anti-theft chain # Configure forwarding conditions setenvifnocase Referer "^http://.*\.a\.com" Local_ref setenvifnocase Referer ". *\.a\.com" Local_ Ref setenvifnocase Referer "^$" local_ref # matches file keyword <filesmatch "\. (txt|doc|mp3|zip|rar|jpg|gif) "> Order allow,deny allow from Env=local_ref </filesmatch>
5) File access control
#配置文件访问控制 <Directory /data/mydiscuz/> Order deny,allow Deny from all # Directory is open only to native Allow from 127.0.0.1 # Manage Admin pages <filesmatch "(. *) admin (. *) "> order deny,allow Deny from all # Administration page is only for local and specified IP directions allow from 127.0.0.1 </filesmatch> </Directory>
Test spaces
6) Configure the static file cache
<ifmodule mod_expires.c> expiresactive on Expiresbytype image/gif "Access plus 1 days" expiresbytype image /jpeg "Access plus hours" expiresbytype image/png "Access plus hours" Expiresbytype text/css "now plus 2 hour" Expiresbytype Application/x-javascript "now plus 2 hours" Expiresbytype Application/x-shockwave-flash "now plus 2 h Ours "ExpiresDefault" now plus 0 min "</IfModule>
This article is from the "Mylinux" blog, make sure to keep this source http://mylinuxlife.blog.51cto.com/4706737/1641140
Linux Learning Notes-19th lesson-lamp's website Building (ii)