Lnamp source installation integration plus forum and static and dynamic separation

Source: Internet
Author: User
Tags mysql login

Lnamp (linux+nginx+apache+mysql+php) architecture is favored by many IT companies, instead of the original thought of a good lnmp (linux+nginx+mysql+php) architecture, then we say Lnamp what is the advantage of it, You have to start with the pros and cons of Nginx and Apache.

Nginx processing static file ability is very strong, Apache processing dynamic file is very strong and stable, the two integrated in one, performance improved many times. Perhaps a lot of Linux SA in the LNMP operation, you will find that PHP (FastCGI) mode will appear some 502 error phenomenon, because of the nginx+php (FastCGI) combination of instability caused by the cause.

Test machine:

[Email protected]_168_77_189 ~]# uname-alinux 192_168_77_189 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 04:27:16 UTC x 86_64 x86_64 x86_64 gnu/linux[[email protected]_168_77_189 ~]# cat/etc/issuecentos Release 6.6 (Final) Kernel \ r on an \m
    • The source installation Lnamp Nginx

[[email protected]_168_77_189 ~]# yum install pcre pcre-devel -y        #依赖包 [[email protected]_168_77_189 autolamp]# tar -xzvf  nginx-1.8.0.tar.gz [[email protected]_168_77_189 nginx-1.8.0]# ./configure  -- Prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module[[email protected] _168_77_189 nginx-1.8.0]# make && make install[[email protected]_168_77_ 189 nginx-1.8.0]# /usr/local/nginx/sbin/nginx[[email protected]_168_77_189 nginx-1.8.0]#  ps -ef | grep nginx    root       9982     1  0 19:38 ?         00:00:00 nginx: master process /usr/local/nginx/sbin/nginxnobody     9983  9982  0 19:38 ?        00:00:00 nginx:  worker process      root      9987   7577  0 19:38 pts/1    00:00:00 grep nginx
    • source installation Lnamp Apache

[[email protected]_168_77_189 autolamp]# yum -y install epel-release [[ email protected]_168_77_189 apr-1.5.2]# ./configure --prefix=/usr/local/apr[[email  Protected]_168_77_189 apr-1.5.2]# make && make install[[email protected] _168_77_189 apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/ local/apr[[email protected]_168_77_189 apr-util-1.5.2]# make && make  Install[[email protected]_168_77_189 httpd-2.4.16]# ./configure --prefix=/usr/local/apache   --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib -- With-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most  --enable-mpms-shared=all --with-mpm=event[[email protected]_168_77_189 httpd-2.4.16]#  make && Make install 
    • source installation lnamp MySQL

 yum install gcc gcc-c++ make cmake  ncurses-devel bison  perl  [[email protected]_168_77_189 mysql-5.5.44]# cmake -dcmake_install_prefix= /data/app/mysql3306 -dmysql_datadir=/data/mysql3306  -dwith_myisam_storage_engine=1 -dwith _innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_readline=1 -dmysql_tcp_port= 3306 -denabled_local_infile=1 -dwith_partition_storage_engine=1 -dextra_charsets=all - Ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dwith_debug=0 -dmysql_user=mysql  -DMYSQL_UNIX_ADDR=/data/mysql3306/mysql3306.sock  [[email protected]_168_77_189  Mysql-5.5.44]#  make && make install   [[email protected] _168_77_189 mysql-5.5.44]# cp -a support-files/my-large.cnf /data/mysql3306/my.cnf   [[email protected]_168_77_189 data]# chown mysql.mysql app/ -r[[email protected]_168_77_189  data]# chown mysql.mysql mysql3306/ -R [[email protected]_168_77_189  mysql3306]# cp -a support-files/mysql.server /etc/init.d/mysqld[[email protected]_168 _77_189 mysql3306]# cd /data/app/mysql3306/ [[email protected]_168_77_189  mysql3306]# ./scripts/mysql_install_db --basedir=/data/app/mysql3306/ --datadir=/data/mysql3306 / --user=mysql[[email protected]_168_77_189 mysql3306]#  echo  "export PATH= "\ $PATH":/data/app/mysql3306/bin/" >>/root/.bash_profile && source /root/. bash_profile [[email protected]_168_77_189 mysql3306]# /etc/init.d/mysqld  Restartshutting down mysql. success! starting mysql.  success!
    • source installation lnamp PHP

yum install libxml2-devel  libmcrypt-devel  bzip2-devel libxml2-devel openssl-devel  bzip2 bzip2-devel[[email protected]_168 _77_189 php-5.4.42]# ./configure --prefix=/usr/local/php --with-mysql=/data/app/mysql3306  --with-openssl --with-mysqli=/data/app/mysql3306/bin/mysql_config --enable-mbstring -- with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr - -enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-bz2 -- With-config-file-path=/etc/php/php.ini --with-config-file-scan-dir=/etc/php/php.d/ --with-apxs2=/usr /local/apache/bin/apxs[[email protected]_168_77_189 php-5.4.42]# make && make  install 
    • source installation apache+php integration

[[email protected]_168_77_189 php-5.4.42]# echo  "addtype application/x-httpd-php   .php " >> /usr/local/apache/conf/httpd.conf[[email protected]_168_77_189  php-5.4.42]# sed -i  ' s/directoryindex index.html/directoryindex index.php  Index.html/g '  /usr/local/apache/conf/httpd.conf[[email protected]_168_77_189 php-5.4.42]#  /usr/local/apache/bin/apachectl -t  00557: httpd: apr_sockaddr_info_get ()  failed  for 192_168_77_189ah00558: httpd: could not reliably determine the  server ' s fully qualified domain name, using set the   ' ServerName '  directive globally to suppress this messageSyntax  okservername www.example.com:80 change to servername localhost:80 can be [[email protected]_168_77_189  conf]# /usr/local/apache/bin/apachectl -tsyntax ok[[email protected]_168_77_189 conf]# ps -ef |  Grep httproot     23847     1  0 21:05  ?        00:00:00 /usr/local/apache/bin/httpd -k  restartdaemon   23849 23847  0 21:05 ?         00:00:00 /usr/local/apache/bin/httpd -k restartdaemon   23850  23847  0 21:05 ?        00:00:00 /usr/ Local/apache/bin/httpd -k restartdaemon   23851 23847  0 21:05  ?        00:00:00 /usr/local/apache/bin/httpd -k  restartdaemon   23937 23847  0 21:06 ?      &NBSP;&NBSP;&NBSP;00:00:00 /usr/local/apache/bin/httpd -k restartroot     23973 22611   0 21:10 pts/1    00:00:00 grep http[[email protected] _168_77_189 ~]# cd /usr/local/apache/htdocs/in index.php add <?phpphpinfo ();? >~   on the client input  test get the following page

650) this.width=650; "title=" qq20150813212927.jpg "src=" http://s3.51cto.com/wyfs02/M02/71/61/wKiom1XMm_ Lg5430aamujtncfli513.jpg "alt=" Wkiom1xmm_lg5430aamujtncfli513.jpg "/>

    • Source Installation Discuz Forum

Download Discuz Source Package file

[Email protected]_168_77_189 ~]# wget [[email protected]_168_77_189 autolamp]# Unzip discuz_x3.1_sc_utf8.zip-d/usr/ Local/apache/htdocs/[[email protected]_168_77_189 autolamp]# cd/usr/local/apache/htdocs/;mv upload/*. [[Email protected]_168_77_189 htdocs]# chmod 777-r data/uc_server/config/uc_client/then visit Install the Discuz forum, for example, select "I Agree"

650) this.width=650; "title=" qq20150813213641.jpg "src=" http://s3.51cto.com/wyfs02/M02/71/5D/ Wkiol1xmn4yq0ngfaaqc0aqncxo275.jpg "alt=" Wkiol1xmn4yq0ngfaaqc0aqncxo275.jpg "/>

650) this.width=650; "title=" qq20150813213844.jpg "src=" http://s3.51cto.com/wyfs02/M02/71/61/wKiom1XMnfyywpiqAAH_ Gr_v1hu013.jpg "alt=" Wkiom1xmnfyywpiqaah_gr_v1hu013.jpg "/>

Database authorization:

[[Email protected]_168_77_189 ~]#/data/app/mysql3306/bin/mysql login, here the database does not have a password set mysql> create databases Discuz charset   =utf8;grant all on discuz.* to identified by "123456"; Authorized

Then enter the account information on the Forum page the next step will be installed successfully ....

650) this.width=650; "title=" qq20150813214648.jpg "src=" http://s3.51cto.com/wyfs02/M00/71/5D/ Wkiol1xmoezirhm9aajw-arhg04871.jpg "alt=" Wkiol1xmoezirhm9aajw-arhg04871.jpg "/>

Since the lamp environment has been integrated and built successfully, how can you use Nginx to integrate lamp?

    • Source Installation Nginx+lamp Integration

First modify Apache access port to 8080,nginx port default to 80

Then modify the Nginx configuration file: The Vi/usr/local/nginx/conf/nginx.conf,server configuration section reads as follows:

Define the upstream equalization module, configure dynamic and static separation, dynamically forward to Apache, static file directly local response), where the configuration of the dynamic separation, dynamically walk

upstreamapp_lamp {    server weight=1 max_fails=2  fail_timeout=30s;    }    server {         listen       80;         server_name  localhost;          location / {            root    /usr/local/apache/htdocs;            index  index.php index.html index.htm;        }         location ~ .*\. (php|jsp|cgi)? $    {         proxy_set_header  Host   $host;          proxy_set_header x-real-ip$remote_addr;          proxy_set_header x-forwarded-for$proxy_add_x_forwarded_for;          proxy_pass http://app_lamp;    }         location ~.*\. (HTML|HTM|GIF|JPG|JPEG|BMP|PNG|ICO|TXT|JS|CSS) $       {         root /usr/local/apache/htdocs;         expires      3d;      }     }

In the client input can be directly accessed, the dynamic picture picture program to walk the app_lamp module inside the host, of course, can be another machine, static webpage go is local

Since then, all the Lnamp source code has been integrated

The package is too big to be uploaded ......... ..........

Lnamp source installation integration plus forum and static and dynamic separation

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.