首页 > 代码库 > debian系统安装最新lnmp编译最新php7.1.2及nginx1.10.3及mysql5.7及5.6

debian系统安装最新lnmp编译最新php7.1.2及nginx1.10.3及mysql5.7及5.6

aptitude 安装nginx/mysql,编译安装php7.1.2

Created 星期四 23 二月 2017

一、配置镜像源,默认debian没有Nginx最新版本,以及php7.0版本(编译安装),mysql5.7版本!
1.1 vim /etc/apt/sources.list   添加如下
deb http://nginx.org/packages/debian/ jessis nginx
deb-src
http://nginx.org/packages/debian/  jessis nginx


1.2安装mysql社区版本5.7  
wget https://repo.mysql.com//mysql-apt-config_0.8.2-1_all.deb
dpkg -i mysql-apt-config_0.8.2-1_all.deb
选择对应的版本,有5.6及5.7两个版本,还有工具。


安装Nginx1.10.3
  aptitude install nginx
 查看版本
 root@user:~# /usr/sbin/nginx -v
 nginx version: nginx/1.10.3

 安装mysql
 aptitude install mysql-server-5.6
 版本信息:
 Welcome to the MySQL monitor.  Commands end with ; or \g.
 Your MySQL connection id is 3
 Server version: 5.6.35 MySQL Community Server (GPL)


编译安装php7.1.2
 make编译安装
 build-essential autoconf automake libtool bison re2c
 依赖包安装(大部分依赖包都在此若是还缺少请查找)
 libxml2-dev libssl-dev libbz2-dev libjpeg-dev libpng-dev 

 libxpm-dev libfreetype6-dev libgmp-dev libgmp3-dev 

 libmcrypt-dev libmysqlclient15-dev libpspell-dev librecode-dev
 libcurl4-gnutls-dev libgmp-dev libgmp3-dev librecode-dev 

 libpspell-dev  libmysqlclient15-dev  libmcrypt-dev libxml2-dev
 openssl报错:
  ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/


下载php7.1.2

wget http://cn2.php.net/distributions/php-7.1.2.tar.gz
tar zxf php-7.1.2.tar.gz
cd php-7.1.2
  ./configure --prefix=/usr/local/php7 --sysconfdir=/etc/php7 \

--with-config-file-path=/etc/php7 --enable-fpm --with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd --with-mhash --with-openssl --with-zlib \

--with-bz2 --with-curl --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir \

--with-zlib --enable-mbstring --with-mcrypt --enable-sockets --with-iconv-dir \

--with-xsl --enable-zip --with-pcre-dir --with-pear --enable-session  \

--enable-gd-native-ttf --enable-xml --with-freetype-dir --enable-gd-jis-conv \

--enable-inline-optimization --enable-shared --enable-bcmath \

--enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-mbregex \

--enable-pcntl --with-xmlrpc --with-gettext --enable-exif --with-readline \

--with-recode --with-tidy

编译安装

make && make install



配置nginx php文件
配置文件都在/etc目录下,先备份好
#cd /etc/nginx
#cp nginx.conf nginx.conf.bak
#vim nginx.conf

把user XXX;改成如下:
user  www-data;

退出在进入
cd conf.d/
cp default.conf default.conf.bak
vim default.conf

修改成如下:
server {
listen       80;
server_name  localhost;

location / {

root   /usr/share/nginx/html;
index index.php index.html index.htm;

}

error_page   500 502 503 504  /50x.html;
location = /50x.html {

root   /usr/share/nginx/html;

}

location ~ \.php$ {

        root                 /usr/share/nginx/html;

        fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
        fastcgi_index  index.php;                    
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;

}

}

配置php文件
root@user:~#  cd /etc/php7/php-fpm.d
root@user:# cp www.conf.default  www.conf.default.bak
root@user:#  mv www.conf.default lnmp.conf
root@user:# vim lnmp.conf
 user = nobody   改成   user = www-data
 group = nobody  改成  group = www-data
 listen = 127.0.0.1:9000改成listen =
/run/php/php7.0-fpm.sock
 listen.owner = www-data    取消注释改成如此
 listen.group = www-data    取消注释改成如此
 listen.mode = 0660          取消注释改成如此

然后在解压的安装包里复制php.ini-production  在/etc/php7/目录下。


启动服务
/etc/init.d/nginx start /restart /stop
/usr/local/php7/sbin/php-fpm
/etc/init.d/mysql start
进程
root@user:~#  ps -ef | grep php-fpm
root      1070     1  0 10:33 ?        00:00:00 php-fpm: master process (/etc/php7/php-fpm.conf)
www-data  1071  1070  0 10:33 ?        00:00:00 php-fpm: pool www          
www-data  1072  1070  0 10:33 ?        00:00:00 php-fpm: pool www          
root      1106  1065  0 10:42 pts/0    00:00:00 grep php-fpm
root@user:~# ps -ef | grep nginx
root       512     1  0 10:29 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
www-data   513   512  0 10:29 ?        00:00:00 nginx: worker process                  
root      1108  1065  0 10:42 pts/0    00:00:00 grep nginx
root@user:~# ps -ef | grep mysql
mysql     1179     1  0 10:47 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql     1455  1179  1 10:47 ?        00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
root      1505  1065  0 10:47 pts/0    00:00:00 grep mysql

结束进程
killall php-fpm

大部分报错都可以进入cat /var/log/nginx/error.log查看,然后google!




debian系统安装最新lnmp编译最新php7.1.2及nginx1.10.3及mysql5.7及5.6