首页 > 代码库 > Lnmp源码安装

Lnmp源码安装

Lnmp

Centos6.5 + nginx/1.7.6 + PHP 5.3.29 + Mysql5.6.20

 

Nginx(/usr/local/nginx)

 

PHP(/usr/local/php)

 

Mysql(/usr/local/mysql)

 

Nginx

yum install zlib zlib-devel openssl openssl-devel pcre pcre-devel

useradd -M -d /dev/null -s /sbin/nologin

[root@Fantast nginx-1.7.6]# ./configure --prefix=/usr/local/nginx \
http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module

make && make install

 

Mysql(mysql-advanced-5.6.20-linux-glibc2.5-x86_64)(二进制包安装)

yum install libaio-devel libaio -y

useradd -M -d /dev/null -s /sbin/nologin mysql

cd /usr/local

ln -s mysql-advanced-5.6.20-linux-glibc2.5-x86_64 mysql

cp mysql-advanced*/support-files/my-default.cnf /etc/my.cnf

cp mysql-advanced*/support-files/mysql.server /etc/init.d/mysqld

chmod 755 /etc/init.d/mysqld

cd mysql

chown -R mysql:mysql .

vim /etc/my.cnf

  datadir = /usr/local/mysql/data

  port = 3306

  socket = /var/lib/mysql/mysql.sock

  user = mysql

  pid-file = /var/run/mysql/mysqld.pid

  [mysqld_safe]

  log-error=/var/log/mysqld.log

mkdir /var/lib/mysql

chown mysql:mysql /var/lib/mysql

#安装

scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock # Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘  防止报这个错 原因不明

#启动mysql

bin/mysqld_safe --user=mysql &

 

PHP

php-fpm下载地址 http://php-fpm.org/downloads/

php-5.2.8-fpm-0.5.10.diff.gz(php-fpm源码)

#PHP5.3.3已经集成php-fpm 不在是第三方包 --enable-fpm

#PHP-FPM作为补丁加入PHP源码中

gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.3.29 -p1

cd php-5.3.29

./configure --prefix=/usr/local/php --enable-mbstring --without-sqlite  --without-sqlite3 --without-pdo-sqlite --with-mysql=/usr/local/mysql --enable-fpm

make && make install

cp php.ini-production  /usr/local/php/lib/php.ini

#php-fpm 配置

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

vim /usr/local/php/etc/php-fpm.conf

  user = nginx

  group = nginx

  listen.allowed_clients = 127.0.0.1\

#启动fastcgi进程

/usr/local/php/sbin/php-fpm

 

#配置nginx 支持php

vim /usr/local/nginx/conf/nginx.conf

  location ~ \.php$ {

  root /data/nginx;

  fastcgi_pass 127.0.0.1:9000;

  fastcgi_index index.php;

  fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

  include fastcgi_params;

  }

 

 

Lnmp源码安装