码迷,mamicode.com
首页 > 其他好文 > 详细

LANMP框架搭建——源码编译

时间:2017-03-13 22:34:45      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:lanmp   nginx反向代理   

所需要的源码包:

mariadb-5.5.46-linux-x86_64.tar.gz

httpd-2.4.9.tar.bz2

php-5.4.26.tar.bz2

nginx-1.8.1.tar.gz



编译mariadb:

[root@centos7 ~]# yum -y remove mariadb*

[root@centos7 ~]# tar xf mariadb-5.5.46-linux-x86_64.tar.gz -C /usr/local/

[root@centos7 ~]# cd /usr/local/

[root@centos7 local]# ln -sv mariadb-5.5.46-linux-x86_64 mysql ‘mysql’ -> ‘mariadb-5.5.46-linux-x86_64’

[root@centos7 local]# id mysql

uid=27(mysql) gid=27(mysql) groups=27(mysql)

[root@centos7 local]# cd mysql/

[root@centos7 mysql]# chown -R root:mysql ./*       ——链接文件赋权规则

[root@centos7 mysql]# mkdir /mydata/data -p

[root@centos7 mysql]# chown -R mysql.mysql /mydata/data/

[root@centos7 mysql]# cp support-files/my-large.cnf  /etc/my.cnf

[root@centos7 mysql]# vim /etc/my.cnf        

添加:

datadir = /mydata/data

skip_name_resolve = ON

innodb_file_per_table = ON

[root@centos7 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

[root@centos7 mysql]# chkconfig --add mysqld

[root@centos7 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data

[root@centos7 mysql]# ls /mydata/data/

aria_log.00000001 mysqlmysql-bin.000002 performance_schema

aria_log_control mysql-bin.000001 mysql-bin.index test

[root@centos7 mysql]# service mysqld start

Starting MySQL.. SUCCESS!

[root@centos7 mysql]# ss -tnl

StateRecv-Q Send-Q Local Address:PortPeer Address:Port

LISTEN05192.168.122.1:53*:*

LISTEN0128*:22*:*

LISTEN0128127.0.0.1:631*:*

LISTEN0100127.0.0.1:25*:*

LISTEN0128:::22:::*

LISTEN0128::1:631:::*

LISTEN0100::1:25:::*

[root@centos7 mysql]# vim /etc/profile.d/mysql.sh                              ——命令调用

export PATH=/usr/local/mysql/bin:$PATH

[root@centos7 mysql]# chmod +x /etc/profile.d/mysql.sh

[root@centos7 mysql]# vim /etc/lb.so.conf.d/mysql.conf                      ——配置mysql的库

/usr/local/bin/lib

[root@centos7 mysql]# lbconfig

 

 

 

 

编译apache:

[root@centos7 ~]# yum groupinstall "Development Tools" "Server Platform Development" -y

[root@centos7 ~]# yum -y install pcre-devel openssl-devel zlib-devel

[root@centos7 ~]# tar xf httpd-2.4.9.tar.bz2

[root@centos7 ~]# cd httpd-2.4.9/

[root@centos7 httpd-2.4.9]# yum -y install apr-devel apr-util-devel

[root@centos7 httpd-2.4.9]# ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24--enable-so --enable-ssl -- enable-rewrite --with-zlib --with-pcre --with-apr=/usr --with-apr-util=/usr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork

[root@centos7 httpd-2.4.9]# make -j 4 && make install

[root@centos7 profile.d]# cat /etc/profile.d/http24.sh

export PATH=/usr/local/apache24/bin:$PATH

[root@centos7 apache24]# . /etc/profile.d/httpd24.sh

 

 

编译php:

[root@centos7 ~]# yum -y install libxml2-devel libmcrypt-devel bzip2-devel 

[root@centos7 ~]# tar xf php-5.4.26.tar.bz2

[root@centos7 ~]# cd php-5.4.26/

[root@centos7 php-5.4.26]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2

[root@centos7 php-5.4.26]# make && make install

 

配置apache与php映射:

[root@centos7 php-5.4.26]# cp /root/php-5.4.26/php.ini-production /etc/php.ini 

[root@centos7 php-5.4.26]# cd /etc/httpd24/

[root@centos7 httpd24]# cp httpd.conf{,.backup}

[root@centos7 httpd24]# vim httpd.conf

添加:

AddType application/x-httpd-php .php

DirectoryIndex index.php index.html

Listen  808                                                                     ——修改协议端口(因为这是自己编译的apache)

[root@centos7 httpd24]# apachectl stop

[root@centos7 httpd24]# apachectl start

[root@centos7 httpd24]# vim /usr/local/apache24/htdocs/index.php

[root@centos7 httpd24]# rm /usr/local/apache24/htdocs/index.html

[root@centos7 httpd24]# firefox http://localhost:808

 

编译nginx:

[root@centos7 ~]# tar xf nginx-1.8.1.tar.gz

 

[root@centos7 nginx-1.8.1]# ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log  --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_gzip_static_module --with-debug --with-http_stub_status_module

 

[root@centos7 nginx-1.8.1]# make && make install

[root@centos7 nginx-1.8.1]# useradd nginx

root@centos7 nginx]# vim /etc/profile.d/nginx.sh

export PATH=/usr/local/nginx/sbin:$PATH

[root@centos7 nginx]# .  /etc/profile.d/nginx.sh

[root@centos7 nginx]# nginx -t

 

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

 

nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@centos7 nginx]# nginx -h

nginx version: nginx/1.8.1

 

Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

 

Options:

 

-?,-h: this help

 

-v: show version and exit

 

-V: show version and configure options then exit

 

-t: test configuration and exit

 

-q: suppress non-error messages during configuration testing

 

-s signal: send signal to a master process: stop, quit, reopen, reload

-p prefix  : set prefix path (default: /usr/local/nginx/)

-c filename : set configuration file (default: /etc/nginx/nginx.conf)

-g directives : set global directives out of configuration file

[root@centos7 html]# nginx                                                             ——启动nginx

 

 

配置nginx:

[root@centos7 html]# vim /etc/nginx/nginx.conf

添加:

upstream lamp {                                                                                ——虚拟主机

server 127.0.0.1:808 weight=1 max_fails=2 fail_timeout=30s;
}

        location / {

           root  /usr/local/apache24/htdocs ;

           index  index.html index.htm index.php;

       }

 

location ~.*\.(php|jsp|cgi)?$                                                                ——动态页面给lamp执行
{
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://lamp;
}

 

location ~.*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$             ——静态页面自己执行
{
root /usr/local/apache24/htdocs;
expires 3d;


本文出自 “淼先森” 博客,请务必保留此出处http://zhaom0109.blog.51cto.com/11675013/1905959

LANMP框架搭建——源码编译

标签:lanmp   nginx反向代理   

原文地址:http://zhaom0109.blog.51cto.com/11675013/1905959

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!