欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

lnmp

程序员文章站 2022-05-17 18:01:35
...

lnmp = linux + nginx + mysql + php/python

mysql 源码安装

[aaa@qq.com ~]# mkdir /var/local/lnmp

[aaa@qq.com ~]# ls
cmake-2.8.12.2-4.el6.x86_64.rpm  mysql-boost-5.7.17.tar.gz
[aaa@qq.com ~]# yum install cmake-2.8.12.2-4.el6.x86_64.rpm

[aaa@qq.com ~]# yum install gcc gcc-c++

[aaa@qq.com ~]# ls
cmake-2.8.12.2-4.el6.x86_64.rpm  mysql-boost-5.7.17.tar.gz
[aaa@qq.com ~]# tar -zxf mysql-boost-5.7.17.tar.gz 
[aaa@qq.com ~]# ls
cmake-2.8.12.2-4.el6.x86_64.rpm  mysql-5.7.17  mysql-boost-5.7.17.tar.gz
[aaa@qq.com ~]# cd mysql-5.7.17/
[aaa@qq.com mysql-5.7.17]# ls
boost            dbug                 libmysql     rapid          testclients
BUILD            Docs                 libmysqld    README         unittest
client           Doxyfile-perfschema  libservices  regex          VERSION
cmake            extra                man          scripts        vio
CMakeLists.txt   include              mysql-test   sql            win
cmd-line-utils   INSTALL              mysys        sql-common     zlib
config.h.cmake   libbinlogevents      mysys_ssl    storage
configure.cmake  libbinlogstandalone  packaging    strings
COPYING          libevent             plugin       support-files


[aaa@qq.com mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all

-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql  ##指定目录
-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data    ##指定数据库路径
-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock  ##Unix socket 存放路径
-DWITH_MYISAM_STORAGE_ENGINE=1      ##安装 myisam 存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1    ##安装 innodb 存储引擎
-DWITH_PARTITION_STORAGE_ENGINE=1   ##安装数据库分区
-DDEFAULT_CHARSET=utf8          ##使用 utf8 字符
-DDEFAULT_COLLATION=utf8_general_ci ##校验字符
-DEXTRA_CHARSETS=all            ##安装所有扩展字符集
-DWITH_BOOST=boost/boost_1_59_0/    ##指定 boost 路径
依赖软件。按照提示安装。
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all

CMake Error at cmake/boost.cmake:81 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>


[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/

  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):

[root@server1 mysql-5.7.17]# rm -rf CMakeCache.txt
[root@server1 mysql-5.7.17]# yum install ncurses-devel

[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/

CMake Warning at cmake/bison.cmake:20 (MESSAGE):
  Bison executable not found in PATH

[root@server1 mysql-5.7.17]# yum install bison
[root@server1 mysql-5.7.17]# rm -rf CMakeCache.txt

[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/
make && make install
  • 初始化:

[aaa@qq.com mysql-5.7.17]# cd /usr/local/lnmp/mysql/

[aaa@qq.com mysql]# cd support-files/
[aaa@qq.com support-files]# ls
magic  my-default.cnf  mysqld_multi.server  mysql-log-rotate  mysql.server
[aaa@qq.com support-files]# cp my-default.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[aaa@qq.com support-files]# vim /etc/my.cnf  配置一下

[aaa@qq.com support-files]# cp mysql.server /etc/init.d/mysqld

[aaa@qq.com support-files]# groupadd -g 27 mysql
[aaa@qq.com mysql]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/data -s /sbin/nologin mysql
[aaa@qq.com mysql]# cd bin/
[aaa@qq.com bin]# pwd
/usr/local/lnmp/mysql/bin
[aaa@qq.com bin]# cd ~
[aaa@qq.com ~]# vim .bash_profile 
[aaa@qq.com ~]# source .bash_profile 

[aaa@qq.com mysql]# mysqld --initialize --user=mysql
2018-08-05T03:08:09.732491Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-05T03:08:09.732538Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2018-08-05T03:08:09.732542Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2018-08-05T03:08:11.826611Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-05T03:08:12.184322Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-05T03:08:12.295367Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c9afc6b8-985c-11e8-bdda-525400d0916d.
2018-08-05T03:08:12.377937Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-08-05T03:08:12.378588Z 1 [Note] A temporary password is generated for 
aaa@qq.com: WG.wto%gk4l!    这是mysql初始密码,等会修改密码会用到。


[aaa@qq.com mysql]# chgrp -R root  data/
[aaa@qq.com mysql]# ls
bin      data  include  man         README  support-files
COPYING  docs  lib      mysql-test  share

[aaa@qq.com mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/usr/local/lnmp/mysql/data/server1.err'.
 SUCCESS! 
[aaa@qq.com mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS! 

[aaa@qq.com mysql]# mysql_secure_installation 


[aaa@qq.com mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/usr/local/lnmp/mysql/data/server1.err'.
 SUCCESS! 
[aaa@qq.com mysql]# mysql_secure_installation 

mysql安全配置,密码就是刚才初始化的,修改

[aaa@qq.com mysql]# mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.17 Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql>




php源码编译安装

[aaa@qq.com ~]# tar -jxf php-5.6.35.tar.bz2 
[aaa@qq.com ~]# ls
gd-devel-2.0.35-11.el6.x86_64.rpm  php-5.6.35.tar.bz2
php-5.6.35                         re2c-0.13.5-1.el6.x86_64.rpm
[aaa@qq.com ~]# cd php-5.6.35

[aaa@qq.com ~]# ./configure –prefix=/usr/local/lnmp/php –with-config-file-path=/usr/local/lnmp/php/etc –with-mysql=mysqlnd –enable-mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-openssl –with-snmp –with-gd –with-zlib –with-curl –with-libxml-dir –with-png-dir –with-jpeg-dir –with-freetype-dir –with-pear –with-gettext –with-gmp –enable-inline-optimization –enable-soap –enable-ftp –enable-sockets –enable-mbstring –enable-fpm –with-fpm-user=nginx –with-fpm-group=nginx –with-mcrypt –with-mhash

php源码编译时不会生成缓存文件,看报错缺少啥就安装啥!!(devel)

这几个包要到网上下,其他的yum都有

gd-devel-2.0.35-11.el6.x86_64.rpm       
libmcrypt-2.5.8-9.el6.x86_64.rpm       
libmcrypt-devel-2.5.8-9.el6.x86_64.rpm  
re2c-0.13.5-1.el6.x86_64.rpm    这是个警告需要的包

这里不一一列举了。。。

配置:

[root@server1 ~]# cd  /usr/local/lnmp/
[root@server1 lnmp]# ls
mysql  php
[root@server1 lnmp]# cd php/
[root@server1 php]# cd etc/
[root@server1 etc]# ls
pear.conf  php-fpm.conf.default
[root@server1 etc]# cp php-fpm.conf.default  php-fpm.conf
[root@server1 etc]# ls
pear.conf  php-fpm.conf  php-fpm.conf.default
[root@server1 etc]# cd ~
[root@server1 ~]# cd php-5.6.35

[root@server1 php-5.6.35]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server1 php-5.6.35]# vim /usr/local/lnmp/php/etc/php.ini
------------------
    修改date.timezone =Asia/Shanghai
------------------

[root@server1 php-5.6.35]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# ls
pear.conf  php-fpm.conf  php-fpm.conf.default  php.ini
[root@server1 etc]# vim php-fpm.conf


[root@server1 etc]# id nginx
id: nginx: No such user

[root@server1 etc]# useradd -M -d /usr/local/lnmp/nginx -s /sbin/nologin nginx
[root@server1 etc]# cd ~
[root@server1 ~]# cd php-5.6.35
[root@server1 php-5.6.35]# cd sapi/
[root@server1 sapi]# cd fpm/
[root@server1 fpm]# ls
config.m4       init.d.php-fpm.in  php-fpm.8        php-fpm.service     tests
CREDITS         LICENSE            php-fpm.8.in     php-fpm.service.in  www.conf.in
fpm             Makefile.frag      php-fpm.conf     status.html
init.d.php-fpm  php-fpm            php-fpm.conf.in  status.html.in
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm
[root@server1 fpm]# /etc/init.d/php-fpm start
Starting php-fpm  done
[root@server1 fpm]# 

nginx解压与安装:


[root@server1 ~]# tar zxf nginx-1.10.1.tar.gz 
[root@server1 ~]# tar zxf nginx-sticky-module-1.1.tar.gz 
[root@server1 ~]# ls
nginx-1.10.1         nginx-sticky-module-1.1
nginx-1.10.1.tar.gz  nginx-sticky-module-1.1.tar.gz
[root@server1 ~]# rm -rf nginx-1.10.1.tar.gz nginx-sticky-module-1.1.tar.gz
[root@server1 ~]# ls
nginx-1.10.1  nginx-sticky-module-1.1
[root@server1 ~]# cd nginx-1.10.1/
     cd src/core/
     vim nginx.h
       ##修改标示符
       ------------------------
       14 #define NGINX_VER          "nginx"
       ------------------------

     cd ../..
     cd auto/cc
     vim gcc 
       ##关掉debug 加快编译进度
       ---------------
       171 # debug
       172 #CFLAGS="$CFLAGS -g"
       ---------------

     cd -
     ./configure --help
     ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-threads --with-file-aio --user=nginx --group=nginx

      ##报错:安装pcre-devel
      ------------------------------
       ./configure: error: the HTTP rewrite module requires the PCRE library.
      -----------------------------

    yum install -y pcre-devel

      ##报错:安装openssl
     ----------------------------
     ./configure: error: SSL modules require the OpenSSL library.
     -----------------------------

    yum install -y openssl-devel

    make && make install
    cd /usr/local/lnmp
    cd nginx/sbin
    cd conf/
    ln -s /usr/local/lnmp/nginx/sbin/nginx  /sbin/  ##建立启动命令

    nginx -t  ##检测nginx配置有没有问题

    vim /etc/security/limits.conf 
      ----------------------------
      54 nginx           -           nofile      65536
      -----------------------------

    useradd -u 800 nginx

    [aaa@qq.com conf]# vim nginx.conf

lnmp

检测:
lnmp

  • vim /usr/local/lnmp/nginx/html/index.php
    lnmp

[root@server1 ~]# cd /usr/local/lnmp/nginx/html/
[root@server1 html]# ls
50x.html  index.html  index.php  readme  upload  utility
[root@server1 html]# mv ./upload/ bbs
[root@server1 html]# ls
50x.html  bbs  index.html  index.php  readme  utility


[root@server1 mysql]# chmod 755 data 


/usr/local/lnmp/mysql/data/mysql.sock
添加mysqlsock路径,三个。 *socket= /usr/local/lnmp/mysql/data/mysql.sock

[root@server1 data]# vim /usr/local/lnmp/php/etc/php.ini 
[root@server1 data]# /etc/init.d/php-fpm reload
Reload service php-fpm  done

[root@server1 ~]# cd /usr/local/lnmp/nginx/html/bbs/
[root@server1 bbs]# chmod 777 config/ data/ uc_server/ uc_client/ -R

登陆172.25.5.1/bbs/install
lnmp

简单设置后;
lnmp

相关标签: lnmp