思路:根据Linux系统以及集团网站体系的新闻,接纳适宜的安装包进行设置

思路:依照Linux系统以及公司网站系统的音信,接纳恰当的安装包进行设置

设置包请各位自行消除哈,提议去各官网下载最新稳定版,不多说,直接开搞

CentOS6.8编译安装LNMP,centos6.8编译lnmp

思路:依据Linux系统以及店堂网站系统的消息,采纳适合的安装包举办设置

一 、查看系统音讯
澳门金沙国际 1

# uname -a                        # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue       # 查看操作系统版本
# grep MemTotal /proc/meminfo    # 查看内存总量
#fdisk -l                                      # 查看所有分区

View Code

二 、具体安装

健康依赖包安装

澳门金沙国际 2

1 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers make zlib-devel pcre-devel openssl-devel libtool* git tree bison perl gd gd-devel

View Code

安装libiconv库

澳门金沙国际 3

1 tar zxvf libiconv-1.14.tar.gz
2 cd libiconv-1.14
3 ./configure --prefix=/usr/local/libiconv
4 make && make install
5 cd ..

View Code

安装libmcrypt,mhash,mcrypt库

澳门金沙国际 4

 1 tar zxvf libmcrypt-2.5.8.tar.gz
 2 cd libmcrypt-2.5.8
 3 ./configure
 4 make && make install
 5 cd ..
 6 tar jxvf mhash-0.9.9.9.tar.bz2
 7 cd mhash-0.9.9.9
 8 ./configure
 9 make && make install
10 cd ..
11 tar zxvf mcrypt-2.6.8.tar.gz
12 cd mcrypt-2.6.8
13 ./configure
14 make && make install
15 cd ..

View Code

8源码包编译安装搭建LNMP,编译安装LNMP。安装CMake工具

澳门金沙国际 5

1 tar zxvf cmake-3.7.2.tar.gz
2 cd cmake-3.7.2
3 ./bootstrap && make && make install
4 cd..

View Code

安装MySQL

澳门金沙国际 6

 1 #卸载旧版本
 2 rpm -e mysql --nodeps
 3 #创建mysql用户
 4 groupadd mysql && useradd -g mysql -M mysql
 5 tar zxvf mysql-5.6.24.tar.gz
 6 cd mysql-5.6.24
 7 cmake \
 8 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
 9 -DMYSQL_DATADIR=/usr/local/mysql/data \
10 -DSYSCONFDIR=/etc \
11 -DMYSQL_USER=mysql \
12 -DWITH_MYISAM_STORAGE_ENGINE=1 \
13 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
14 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
15 -DWITH_MEMORY_STORAGE_ENGINE=1 \
16 -DWITH_READLINE=1 \
17 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
18 -DMYSQL_TCP_PORT=3306 \
19 -DENABLED_LOCAL_INFILE=1 \
20 -DENABLE_DOWNLOADS=1 \
21 -DWITH_PARTITION_STORAGE_ENGINE=1 \
22 -DEXTRA_CHARSETS=all \
23 -DDEFAULT_CHARSET=utf8 \
24 -DDEFAULT_COLLATION=utf8_general_ci \
25 -DWITH_DEBUG=0 \
26 -DMYSQL_MAINTAINER_MODE=0 \
27 -DWITH_SSL:STRING=bundled \
28 -DWITH_ZLIB:STRING=bundled
29 make && make install
30 #修改目录权限
31 chown -R mysql:mysql /usr/local/mysql
32 #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
33 cp support-files/my-default.cnf /etc/my.cnf
34 #编辑配置文件,在 [mysqld] 部分增加下面一行
35 vi /etc/my.cnf
36 datadir = /usr/local/mysql/data #添加MySQL数据库路径
37 #执行初始化配置脚本,创建系统自带的数据库和表
38 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
39 #加入系统服务
40 cp support-files/mysql.server /etc/init.d/mysqld
41 chmod +x /etc/init.d/mysqld
42 #启动mysql
43 service mysqld start
44 #开机启动
45 chkconfig mysqld on
46 #加入环境变量
47 echo 'PATH=/usr/local/mysql/bin:$PATH'>>/etc/profile
48 export PATH
49 #让配置生效
50 source /etc/profile
51 #设置root密码,默认是没有密码的
52 /usr/local/mysql/bin/mysqladmin -uroot -p password
53 cd ..

View Code

安装PHP

澳门金沙国际 7

 1 tar zxvf php-5.6.30.tar.gz
 2 cd php-5.6.30
 3 ./configure \
 4 --prefix=/usr/local/php \
 5 --with-fpm-user=www --with-fpm-group=www \
 6 --with-config-file-path=/usr/local/php/etc \
 7 --with-mhash --with-mcrypt --enable-bcmath \
 8 --enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql \
 9 --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir \
10 --enable-fpm \
11 --enable-mbstring \
12 --enable-pcntl \
13 --enable-sockets \
14 --enable-opcache \
15 --with-openssl \
16 --with-zlib \
17 --with-curl \
18 --with-libxml-dir \
19 --with-iconv-dir
20 make && make install
21 #移动生成php-fpm配置文件
22 mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
23 #复制生成一份php配置文件
24 cp php.ini-production /usr/local/php/etc/php.ini
25 #将php-fpm加入系统服务
26 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
27 #赋予执行权限
28 chmod +x /etc/init.d/php-fpm
29 #开机启动
30 chkconfig php-fpm on#创建www用户
31 groupadd www && useradd -d /home/www -g www www
32 #启动php-fpm
33 service php-fpm start
34 cd ..
35 vim /etc/profile
36 修改PATH=/usr/local/php/bin:/usr/local/mysql/bin:$PATH
37 export PATH
38 source /etc/profile

View Code

安装Nginx

澳门金沙国际 8

tar zxvf nginx-1.10.2.tar.gz 
cd nginx-1.10.2
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-pcre
make && make install

View Code

充足Nginx运营管制脚本/etc/init.d/nginx

澳门金沙国际 9

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx# pidfile: /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
  # make required directories
  user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
  if [ -n "$user" ]; then
  if [ -z "`grep $user /etc/passwd`" ]; then
  useradd -M -s /bin/nologin $user
  fi
  options=`$nginx -V 2>&1 | grep 'configure arguments:'`
  for opt in $options; do
  if [ `echo $opt | grep '.*-temp-path'` ]; then
  value=`echo $opt | cut -d "=" -f 2`
  if [ ! -d "$value" ]; then
  # echo "creating" $value
  mkdir -p $value && chown -R $user $value
  fi
  fi
  done
  fi
}

start() {
  [ -x $nginx ] || exit 5
  [ -f $NGINX_CONF_FILE ] || exit 6
  make_dirs
  echo -n $"Starting $prog: "
  daemon $nginx -c $NGINX_CONF_FILE
  retval=$?
  echo
  [ $retval -eq 0 ] && touch $lockfile
  return $retval
}

stop() {
  echo -n $"Stopping $prog: "
  killproc $prog -QUIT
  retval=$?
  echo
  [ $retval -eq 0 ] && rm -f $lockfile
  return $retval
}

restart() {
  configtest || return $?
  stop
  sleep 1
  start
}

reload() {
  configtest || return $?
  echo -n $"Reloading $prog: "
  killproc $nginx -HUP
  RETVAL=$?
  echo
}

force_reload() {
  restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
  status $prog
}

rh_status_q() {
  rh_status >/dev/null 2>&1
}

case "$1" in
  start)
  rh_status_q && exit 0
  $1
  ;;
  stop)
  rh_status_q || exit 0
  $1
  ;;
  restart|configtest)
  $1
  ;;
  reload)
  rh_status_q || exit 7
  $1
  ;;
  force-reload)
  force_reload
  ;;
  status)
  rh_status
  ;;
  condrestart|try-restart)
  rh_status_q || exit 0
  ;;
  *)
  echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
  exit 2
esac

澳门金沙国际,View Code

用法指南

澳门金沙国际 10

chmod +x /etc/init.d/nginx
service nginx start #启动nginx服务
chkconfig nginx on #开机启动
cd ..

View Code

迄今,LNMP环境已搭建达成。

思路:依照Linux系统以及集团网站系统的音信,采取适用的安装包进行设置
① 、查看系统音讯 # uname…

一 、查看系统消息

一 、查看系统消息

例行依赖包安装

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers make zlib-devel pcre-devel openssl-devel libtool* git tree bison perl gd gd-devel

澳门金沙国际 11澳门金沙国际 12

澳门金沙国际 13澳门金沙国际 14

安装libiconv库

有了这么些以往就足以在PHP里使用iconv函数来更换字符编码啦,比如想将字符串的编码从GBK转到UTF-8,就用:
iconv(‘GBK’, ‘UTF-8’, $str);

tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
cd ..
# uname -a                        # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue       # 查看操作系统版本
# grep MemTotal /proc/meminfo    # 查看内存总量
#fdisk -l                                      # 查看所有分区
# uname -a                        # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue       # 查看操作系统版本
# grep MemTotal /proc/meminfo    # 查看内存总量
#fdisk -l                                      # 查看所有分区

安装libmcrypt,mhash,mcrypt库

如若PHP自带的加密算法不大概满意你的须要,就应有考虑第一方加密扩张库了(指出一定要装呀,本人写代码大概没用到,但是有个别PHP框架只是要用到的,比如Laravel)。
按梯次安装libmcrypt,mhash,mcrypt

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
cd ..
tar jxvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure
make && make install
cd ..
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make && make install
cd ..

编译mcrypt若是报错:configure: error: *** libmcrypt was not found

echo '/usr/local/lib/'>>/etc/ld.so.conf
ldconfig

编译mcrypt若是报错:/bin/rm: cannot remove ‘libtoolT’: No such file or
directory
修改 configure 文件,找到RM='$RM'并改为RM='$RM -f'就行啦

View Code

View Code

安装CMake工具

MySQL从5.5版本起始,通过./configure进行编译配置格局已经被裁撤,取而代之的是cmake工具

tar zxvf cmake-3.7.2.tar.gz
cd cmake-3.7.2
./bootstrap && make && make install
cd..

二 、具体安装

② 、具体安装

安装MySQL

#卸载旧版本
rpm -e mysql --nodeps
#创建mysql用户
groupadd mysql && useradd -g mysql -M mysql
tar zxvf mysql-5.6.24.tar.gz
cd mysql-5.6.24
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG=0 \
-DMYSQL_MAINTAINER_MODE=0 \
-DWITH_SSL:STRING=bundled \
-DWITH_ZLIB:STRING=bundled
make && make install
#修改目录权限
chown -R mysql:mysql /usr/local/mysql
#拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
cp support-files/my-default.cnf  /etc/my.cnf
#编辑配置文件,在 [mysqld] 部分增加下面一行
vi /etc/my.cnf
datadir = /usr/local/mysql/data  #添加MySQL数据库路径
#执行初始化配置脚本,创建系统自带的数据库和表
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
#加入系统服务
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
#启动mysql
service mysqld start
#开机启动
chkconfig mysqld on
#加入环境变量
echo 'PATH=/usr/local/mysql/bin:$PATH'>>/etc/profile
export PATH
#让配置生效
source /etc/profile
#设置root密码,默认是没有密码的
/usr/local/mysql/bin/mysqladmin -uroot -p password
cd ..

好端端重视包安装

符合规律依赖包安装

安装PHP

tar zxvf php-5.6.30.tar.gz
cd php-5.6.30
./configure \
--prefix=/usr/local/php \
--with-fpm-user=www --with-fpm-group=www \
--with-config-file-path=/usr/local/php/etc \
--with-mhash --with-mcrypt --enable-bcmath \
--enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql \
--with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir \
--enable-fpm \
--enable-mbstring \
--enable-pcntl \
--enable-sockets \
--enable-opcache \
--with-openssl \
--with-zlib \
--with-curl \
--with-libxml-dir \
--with-iconv-dir
make && make install
#移动生成php-fpm配置文件
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#复制生成一份php配置文件
cp php.ini-production /usr/local/php/etc/php.ini
#将php-fpm加入系统服务
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#赋予执行权限
chmod +x /etc/init.d/php-fpm
#开机启动
chkconfig php-fpm on
#创建www用户
groupadd www && useradd -d /home/www -g www www
#启动php-fpm
service php-fpm start
cd ..

设若编译报错:gcc: Internal error: Killed (program cc1),在编译参数后加
--disable-fileinfo
编辑/etc/profile将php参加环境变量(和前边mysql一样)

修改PATH=/usr/local/php/bin:/usr/local/mysql/bin:$PATH
export PATH
source /etc/profile

澳门金沙国际 15澳门金沙国际 16

澳门金沙国际 17澳门金沙国际 18

安装Nginx

tar zxvf nginx-1.10.2.tar.gz 
cd nginx-1.10.2
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-pcre

接下去添加Nginx运行管制脚本/etc/init.d/nginx
至于运营脚本请参考链接Nginx运营管制脚本,修改脚本变量nginx=”/usr/local/nginx/sbin/nginx”,保障起见其余变量也硬着头皮核对下

chmod +x /etc/init.d/nginx
service nginx start #启动nginx服务
chkconfig nginx on #开机启动
cd ..

Nginx配置相关的情节后续有空会补充
迄今,LNMP环境已搭建完结。

1 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers make zlib-devel pcre-devel openssl-devel libtool* git tree bison perl gd gd-devel
1 yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openldap openldap-devel openldap-clients openldap-servers make zlib-devel pcre-devel openssl-devel libtool* git tree bison perl gd gd-devel

View Code

View Code

安装libiconv库

安装libiconv库

澳门金沙国际 19澳门金沙国际 20

澳门金沙国际 21澳门金沙国际 22

1 tar zxvf libiconv-1.14.tar.gz
2 cd libiconv-1.14
3 ./configure --prefix=/usr/local/libiconv
4 make && make install
5 cd ..
1 tar zxvf libiconv-1.14.tar.gz
2 cd libiconv-1.14
3 ./configure --prefix=/usr/local/libiconv
4 make && make install
5 cd ..

View Code

View Code

安装libmcrypt,mhash,mcrypt库

安装libmcrypt,mhash,mcrypt库

澳门金沙国际 23澳门金沙国际 24

澳门金沙国际 25澳门金沙国际 26

 1 tar zxvf libmcrypt-2.5.8.tar.gz
 2 cd libmcrypt-2.5.8
 3 ./configure
 4 make && make install
 5 cd ..
 6 tar jxvf mhash-0.9.9.9.tar.bz2
 7 cd mhash-0.9.9.9
 8 ./configure
 9 make && make install
10 cd ..
11 tar zxvf mcrypt-2.6.8.tar.gz
12 cd mcrypt-2.6.8
13 ./configure
14 make && make install
15 cd ..
 1 tar zxvf libmcrypt-2.5.8.tar.gz
 2 cd libmcrypt-2.5.8
 3 ./configure
 4 make && make install
 5 cd ..
 6 tar jxvf mhash-0.9.9.9.tar.bz2
 7 cd mhash-0.9.9.9
 8 ./configure
 9 make && make install
10 cd ..
11 tar zxvf mcrypt-2.6.8.tar.gz
12 cd mcrypt-2.6.8
13 ./configure
14 make && make install
15 cd ..

View Code

View Code

编译 mcrypt 假诺报错:configure: error: *** libmcrypt was not found,则

编译 mcrypt 借使报错:configure: error: *** libmcrypt was not found,则

echo '/usr/local/lib/'>>/etc/ld.so.conf
ldconfig
echo '/usr/local/lib/'>>/etc/ld.so.conf
ldconfig

编译 mcrypt 假使报错:/bin/rm: cannot remove ‘libtoolT’: No such file or
directory,则修改 configure 文件,找到 本田UR-VM=’$猎豹CS6M’ 并改为 中华VM=’$牧马人M -rf’。

编译 mcrypt 假诺报错:/bin/rm: cannot remove ‘libtoolT’: No such file or
directory,则修改 configure 文件,找到 翼虎M=’$MuranoM’ 并改为 CRUISERM=’$景逸SUVM -rf’。

安装CMake工具

安装CMake工具

澳门金沙国际 27澳门金沙国际 28

澳门金沙国际 29澳门金沙国际 30

1 tar zxvf cmake-3.7.2.tar.gz
2 cd cmake-3.7.2
3 ./bootstrap && make && make install
4 cd..
1 tar zxvf cmake-3.7.2.tar.gz
2 cd cmake-3.7.2
3 ./bootstrap && make && make install
4 cd..

View Code

View Code

安装MySQL

安装MySQL

澳门金沙国际 31澳门金沙国际 32

澳门金沙国际 33澳门金沙国际 34

 1 #卸载旧版本
 2 rpm -e mysql --nodeps
 3 #创建mysql用户
 4 groupadd mysql && useradd -g mysql -M mysql
 5 tar zxvf mysql-5.6.24.tar.gz
 6 cd mysql-5.6.24
 7 cmake \
 8 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
 9 -DMYSQL_DATADIR=/usr/local/mysql/data \
10 -DSYSCONFDIR=/etc \
11 -DMYSQL_USER=mysql \
12 -DWITH_MYISAM_STORAGE_ENGINE=1 \
13 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
14 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
15 -DWITH_MEMORY_STORAGE_ENGINE=1 \
16 -DWITH_READLINE=1 \
17 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
18 -DMYSQL_TCP_PORT=3306 \
19 -DENABLED_LOCAL_INFILE=1 \
20 -DENABLE_DOWNLOADS=1 \
21 -DWITH_PARTITION_STORAGE_ENGINE=1 \
22 -DEXTRA_CHARSETS=all \
23 -DDEFAULT_CHARSET=utf8 \
24 -DDEFAULT_COLLATION=utf8_general_ci \
25 -DWITH_DEBUG=0 \
26 -DMYSQL_MAINTAINER_MODE=0 \
27 -DWITH_SSL:STRING=bundled \
28 -DWITH_ZLIB:STRING=bundled
29 make && make install
30 #修改目录权限
31 chown -R mysql:mysql /usr/local/mysql
32 #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
33 cp support-files/my-default.cnf /etc/my.cnf
34 #编辑配置文件,在 [mysqld] 部分增加下面一行
35 vi /etc/my.cnf
36 datadir = /usr/local/mysql/data #添加MySQL数据库路径
37 #执行初始化配置脚本,创建系统自带的数据库和表
38 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
39 #加入系统服务
40 cp support-files/mysql.server /etc/init.d/mysqld
41 chmod +x /etc/init.d/mysqld
42 #启动mysql
43 service mysqld start
44 #开机启动
45 chkconfig mysqld on
46 #加入环境变量
47 echo 'PATH=/usr/local/mysql/bin:$PATH'>>/etc/profile
48 export PATH
49 #让配置生效
50 source /etc/profile
51 #设置root密码,默认是没有密码的
52 /usr/local/mysql/bin/mysqladmin -uroot -p password
53 cd ..
 1 #卸载旧版本
 2 rpm -e mysql --nodeps
 3 #创建mysql用户
 4 groupadd mysql && useradd -g mysql -M mysql
 5 tar zxvf mysql-5.6.24.tar.gz
 6 cd mysql-5.6.24
 7 cmake \
 8 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
 9 -DMYSQL_DATADIR=/usr/local/mysql/data \
10 -DSYSCONFDIR=/etc \
11 -DMYSQL_USER=mysql \
12 -DWITH_MYISAM_STORAGE_ENGINE=1 \
13 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
14 -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
15 -DWITH_MEMORY_STORAGE_ENGINE=1 \
16 -DWITH_READLINE=1 \
17 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
18 -DMYSQL_TCP_PORT=3306 \
19 -DENABLED_LOCAL_INFILE=1 \
20 -DENABLE_DOWNLOADS=1 \
21 -DWITH_PARTITION_STORAGE_ENGINE=1 \
22 -DEXTRA_CHARSETS=all \
23 -DDEFAULT_CHARSET=utf8 \
24 -DDEFAULT_COLLATION=utf8_general_ci \
25 -DWITH_DEBUG=0 \
26 -DMYSQL_MAINTAINER_MODE=0 \
27 -DWITH_SSL:STRING=bundled \
28 -DWITH_ZLIB:STRING=bundled
29 make && make install
30 #修改目录权限
31 chown -R mysql:mysql /usr/local/mysql
32 #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
33 cp support-files/my-default.cnf /etc/my.cnf
34 #编辑配置文件,在 [mysqld] 部分增加下面一行
35 vi /etc/my.cnf
36 datadir = /usr/local/mysql/data #添加MySQL数据库路径
37 #执行初始化配置脚本,创建系统自带的数据库和表
38 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
39 #加入系统服务
40 cp support-files/mysql.server /etc/init.d/mysqld
41 chmod +x /etc/init.d/mysqld
42 #启动mysql
43 service mysqld start
44 #开机启动
45 chkconfig mysqld on
46 #加入环境变量
47 echo 'PATH=/usr/local/mysql/bin:$PATH'>>/etc/profile
48 export PATH
49 #让配置生效
50 source /etc/profile
51 #设置root密码,默认是没有密码的
52 /usr/local/mysql/bin/mysqladmin -uroot -p password
53 cd ..

View Code

View Code

启航 mysql 时如果报错:mysqld_safe Directory ‘/var/lib/mysqld’ for UNIX
socket file don’t exists,则

起步 mysql 时只要报错:mysqld_safe Directory ‘/var/lib/mysqld’ for UNIX
socket file don’t exists,则

mkdir -p /var/lib/mysqld 
chown mysql:mysql /var/lib/mysqld
mkdir -p /var/lib/mysqld 
chown mysql:mysql /var/lib/mysqld

安装PHP

安装PHP

澳门金沙国际 35澳门金沙国际 36

澳门金沙国际 37澳门金沙国际 38

 1 tar zxvf php-5.6.30.tar.gz
 2 cd php-5.6.30
 3 ./configure \
 4 --prefix=/usr/local/php \
 5 --with-fpm-user=www --with-fpm-group=www \
 6 --with-config-file-path=/usr/local/php/etc \
 7 --with-mhash --with-mcrypt --enable-bcmath \
 8 --enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql \
 9 --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir \
10 --enable-fpm \
11 --enable-mbstring \
12 --enable-pcntl \
13 --enable-sockets \
14 --enable-opcache \
15 --with-openssl \
16 --with-zlib \
17 --with-curl \
18 --with-libxml-dir \
19 --with-iconv-dir
20 make && make install
21 #移动生成php-fpm配置文件
22 mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
23 #复制生成一份php配置文件
24 cp php.ini-production /usr/local/php/etc/php.ini
25 #将php-fpm加入系统服务
26 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
27 #赋予执行权限
28 chmod +x /etc/init.d/php-fpm
29 #开机启动
30 chkconfig php-fpm on#创建www用户
31 groupadd www && useradd -d /home/www -g www www
32 #启动php-fpm
33 service php-fpm start
34 cd ..
35 vim /etc/profile
36 修改PATH=/usr/local/php/bin:/usr/local/mysql/bin:$PATH
37 export PATH
38 source /etc/profile
 1 tar zxvf php-5.6.30.tar.gz
 2 cd php-5.6.30
 3 ./configure \
 4 --prefix=/usr/local/php \
 5 --with-fpm-user=www --with-fpm-group=www \
 6 --with-config-file-path=/usr/local/php/etc \
 7 --with-mhash --with-mcrypt --enable-bcmath \
 8 --enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql \
 9 --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir \
10 --enable-fpm \
11 --enable-mbstring \
12 --enable-pcntl \
13 --enable-sockets \
14 --enable-opcache \
15 --with-openssl \
16 --with-zlib \
17 --with-curl \
18 --with-libxml-dir \
19 --with-iconv-dir
20 make && make install
21 #移动生成php-fpm配置文件
22 mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
23 #复制生成一份php配置文件
24 cp php.ini-production /usr/local/php/etc/php.ini
25 #将php-fpm加入系统服务
26 cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
27 #赋予执行权限
28 chmod +x /etc/init.d/php-fpm
29 #开机启动
30 chkconfig php-fpm on#创建www用户
31 groupadd www && useradd -d /home/www -g www www
32 #启动php-fpm
33 service php-fpm start
34 cd ..
35 vim /etc/profile
36 修改PATH=/usr/local/php/bin:/usr/local/mysql/bin:$PATH
37 export PATH
38 source /etc/profile

View Code

View Code

安装Nginx

安装Nginx

澳门金沙国际 39澳门金沙国际 40

澳门金沙国际 41澳门金沙国际 42

tar zxvf nginx-1.10.2.tar.gz 
cd nginx-1.10.2
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-pcre
make && make install
tar zxvf nginx-1.10.2.tar.gz 
cd nginx-1.10.2
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-pcre
make && make install

View Code

View Code

累加Nginx运维管制脚本/etc/init.d/nginx

拉长Nginx运转管制脚本/etc/init.d/nginx

澳门金沙国际 43澳门金沙国际 44

澳门金沙国际 45澳门金沙国际 46

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx# pidfile: /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
  # make required directories
  user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
  if [ -n "$user" ]; then
  if [ -z "`grep $user /etc/passwd`" ]; then
  useradd -M -s /bin/nologin $user
  fi
  options=`$nginx -V 2>&1 | grep 'configure arguments:'`
  for opt in $options; do
  if [ `echo $opt | grep '.*-temp-path'` ]; then
  value=`echo $opt | cut -d "=" -f 2`
  if [ ! -d "$value" ]; then
  # echo "creating" $value
  mkdir -p $value && chown -R $user $value
  fi
  fi
  done
  fi
}

start() {
  [ -x $nginx ] || exit 5
  [ -f $NGINX_CONF_FILE ] || exit 6
  make_dirs
  echo -n $"Starting $prog: "
  daemon $nginx -c $NGINX_CONF_FILE
  retval=$?
  echo
  [ $retval -eq 0 ] && touch $lockfile
  return $retval
}

stop() {
  echo -n $"Stopping $prog: "
  killproc $prog -QUIT
  retval=$?
  echo
  [ $retval -eq 0 ] && rm -f $lockfile
  return $retval
}

restart() {
  configtest || return $?
  stop
  sleep 1
  start
}

reload() {
  configtest || return $?
  echo -n $"Reloading $prog: "
  killproc $nginx -HUP
  RETVAL=$?
  echo
}

force_reload() {
  restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
  status $prog
}

rh_status_q() {
  rh_status >/dev/null 2>&1
}

case "$1" in
  start)
  rh_status_q && exit 0
  $1
  ;;
  stop)
  rh_status_q || exit 0
  $1
  ;;
  restart|configtest)
  $1
  ;;
  reload)
  rh_status_q || exit 7
  $1
  ;;
  force-reload)
  force_reload
  ;;
  status)
  rh_status
  ;;
  condrestart|try-restart)
  rh_status_q || exit 0
  ;;
  *)
  echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
  exit 2
esac
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx# pidfile: /var/run/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
  # make required directories
  user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
  if [ -n "$user" ]; then
  if [ -z "`grep $user /etc/passwd`" ]; then
  useradd -M -s /bin/nologin $user
  fi
  options=`$nginx -V 2>&1 | grep 'configure arguments:'`
  for opt in $options; do
  if [ `echo $opt | grep '.*-temp-path'` ]; then
  value=`echo $opt | cut -d "=" -f 2`
  if [ ! -d "$value" ]; then
  # echo "creating" $value
  mkdir -p $value && chown -R $user $value
  fi
  fi
  done
  fi
}

start() {
  [ -x $nginx ] || exit 5
  [ -f $NGINX_CONF_FILE ] || exit 6
  make_dirs
  echo -n $"Starting $prog: "
  daemon $nginx -c $NGINX_CONF_FILE
  retval=$?
  echo
  [ $retval -eq 0 ] && touch $lockfile
  return $retval
}

stop() {
  echo -n $"Stopping $prog: "
  killproc $prog -QUIT
  retval=$?
  echo
  [ $retval -eq 0 ] && rm -f $lockfile
  return $retval
}

restart() {
  configtest || return $?
  stop
  sleep 1
  start
}

reload() {
  configtest || return $?
  echo -n $"Reloading $prog: "
  killproc $nginx -HUP
  RETVAL=$?
  echo
}

force_reload() {
  restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
  status $prog
}

rh_status_q() {
  rh_status >/dev/null 2>&1
}

case "$1" in
  start)
  rh_status_q && exit 0
  $1
  ;;
  stop)
  rh_status_q || exit 0
  $1
  ;;
  restart|configtest)
  $1
  ;;
  reload)
  rh_status_q || exit 7
  $1
  ;;
  force-reload)
  force_reload
  ;;
  status)
  rh_status
  ;;
  condrestart|try-restart)
  rh_status_q || exit 0
  ;;
  *)
  echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
  exit 2
esac

View Code

View Code

用法指南

用法指南

澳门金沙国际 47澳门金沙国际 48

澳门金沙国际 49澳门金沙国际 50

chmod +x /etc/init.d/nginx
service nginx start #启动nginx服务
chkconfig nginx on #开机启动
cd ..
chmod +x /etc/init.d/nginx
service nginx start #启动nginx服务
chkconfig nginx on #开机启动
cd ..

View Code

View Code

迄今,LNMP环境已搭建完结。

由来,LNMP环境已搭建已毕。

相关文章