编译lnmp

Part 1 编译nginx

将nginx下载至   /usr/local/src  下

解压后进入    ./configure --prefix=/usr/local/nginx

错误:http重写模块需要pcre库。

可以禁用模块;或者在系统里安装pcre;或者通过pcre源代码构建pcre库,只要指明路径

 

这里采用第三种方法:

将pcre下载解压之后

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.40

又出现错误

同样的,将zlib下载解压之后

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.40 --with-zlib=/usr/local/src/zlib-1.2.3

之后make&&make install

nginx安装完成

来到 /usr/local/  下  多了一个nginx文件夹

运行nginx   ./nginx/sbin/nginx

局域网ping得通,外界连不上80端口,可能是防火墙的原因

service iptables stop

访问到了!

 Part 2 编译PHP

在官网上下载PHP   如:http://dk2.php.net/get/php-5.6.31.tar.bz2/from/this/mirror

下载之后默认保存名 mirror  改个名字: mv mirror php-5.6.31.tar.bz2

解压之后进入:(多行时必须先打反斜线  再回车,且反斜线之后不能有空格)

./configure --prefix=/usr/local/php \
--with-gd \
--enable-gd-native-ttf \
--enable-mysqlnd \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--enable-mbstring \
--enable-fpm

出现错误:

查过之后,网友:这是选择安装GD模块才会出现的错误 , 安装libpng 可解决

yum install libpng libpng-devel

重新编译 ...... 编译成功!

运行php

/usr/local/php5.6/sbin/php-fpm

出现错误:

来到etc 下,确实没有php-fpm.conf,有php-fpm.conf.default

拷贝一份改名 : cp php-fpm.conf.default php-fpm.conf

重新运行

查看进程  ps aux|grep php

启动了!

 

 Part 3 整合nginx + php

编辑nginx的配置文件 : vim /usr/local/nginx/conf/nginx.conf

打开注释,并添上文件路径

vim /usr/local/nginx/html/a.php

<?php phpinfo();

浏览器上运行a.php

没有加载到 php.ini

 

来到 /usr/local/src/php-5.6.31  下 把开发版的php.ini拷到lib下

重启php  刷新浏览器  成功加载

至此,nginx+php 整合完毕!

 

Part 4 安装mysql

到官网下载二进制版本安装

如何下载 ---> 怎样从Mysql官网下载mysql.tar.gz版本的安装包

 

官方示例:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql # 安装初始化数据
shell> chown -R root .
shell> chown -R mysql data

将mysql解压到 /usr/local下,进入其中操作

执行完上述步骤,在 /var/run/ 下创建目录 mysqld ,并更改其所有者及群组

mkdir /var/run/mysqld

chown mysql /var/run/mysqld

chgrp mysql /var/run/mysqld

启动mysql

/usr/local/mysql/bin/mysqld_safe --user=mysql &

连接mysql

/usr/local/mysql/bin/mysql

错误:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,但linux系统总是去/tmp/mysql.sock查找,所以会报错

有两种方法解决:

1::建立软件连接

ln /var/lib/mysql/mysql.sock /tmp/mysql.sock

2:直接指定mysql通道

mysql -S /var/lib/mysql/mysql.sock

 

 

 

 

 

 

 

 

 

 

 

 

posted on 2017-08-20 10:22  谁抢了我的满天星  阅读(127)  评论(0编辑  收藏  举报

导航