在点滴中成长

【原】LNMP编译安装

常用的LANMP一键安装包有Oneinstack和LNMP一键安装包,如果遇到新版本的安装问题可以参照一键安装包脚本

关闭SELinux[Ubuntu默认没有安装SELinux]

vim /etc/selinux/config
SELINUX=disabled

允许防火墙80端口访问

iptables  -Ziptables  -X4

安装各必要组件

yum -y install make pcre-devel cmake gcc gcc-c++ flex bison libaio file libtool libtool-libs autoconf kernel-devel patch wget libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl libjpeg libjpeg-devel libpng libpng-devel curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel aspell-devel libcap diffutils net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel freetype-devel libxslt libxslt-devel

编译安装PHP7.1

./configure --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-gd --enable-gd-native-ttf --with-freetype-dir --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl --prefix=/opt/php --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-gd-jis-conv
make
make install

* 安装完记得将php.ini移动到指定目录
* 安装完记得修改php-fpm的配置文件
* 安装完记得启动php-fpm

编译安装PHP7.2

./configure --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-gd --with-freetype-dir --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl --prefix=/opt/php --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-gd-jis-conv
make
make install

* 安装完记得将php.ini移动到指定目录
* 安装完记得修改php-fpm的配置文件
* 安装完记得启动php-fpm

编译安装Nginx

  • 编译Nginx
./configure --prefix=/opt/nginx --user=www --group=www --error-log-path=/usr/local/log/nginx_error.log --with-http_mp4_module --with-http_flv_module --pid-path=/var/run/nginx/nginx.pid --with-http_ssl_module --http-fastcgi-temp-path=/var/tmp/nginx/fcgi
  • 配置PHP-fastcgi
location ~ \.php$ {            
    root           html;           
    fastcgi_pass   127.0.0.1:9000;            
    fastcgi_index  index.php;            
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;           
    include        fastcgi_params;
}

安装MySQL(centos)这里使用Yum安装,并且使用国内镜像。

国内镜像地址:http://mirrors.ustc.edu.cn/
  • 获取rpm包地址,并且安装相关yum源【在标准yum源中并没有mysql的rpm包】
** 当前示例只支持64位系统,别的系统的rpm包请去MySQL官网获取
wget http://mirrors.ustc.edu.cn/mysql-repo/mysql80-community-release-el7-1.noarch.rpm
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
  • 修改/etc/yum.repos.d/mysql-community.repo【由于MySQL8变化特别大,所以我们先安装5.7】
# 修改baseurl,切换国内镜像,修改enable字段开启5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# 修改enable字段关闭8.0
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# 修改baseurl,切换国内镜像
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://mirrors.ustc.edu.cn/mysql-repo/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  • 安装MySQL
yum install mysql-community-server
  • 启动MySQL
systemctl start mysqld.service
  • 查看默认密码,并且修改MySQL默认密码
# 查看默认密码
grep 'temporary password' /var/log/mysqld.log
# 修改默认密码,先登录再修改
mysql -uroot -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
  • 配置MySQL开机启动
systemctl enable mysqld.service

判断是否编译完成

  • 安装过程停止
  • 停止后,一页界面中出现error或者warning no

需要注意的

  • 在configure检测系统环境和检测lib库文件的时候如果出现缺少组件的情况可以用yum install -devel安装开发包才可以**
  • useradd -M -s "/sbin/nologin" nginx 记得建立相关用户
已有 2 条评论
  1. GalinaSal

    rx

    GalinaSal
  2. 李小帅

    喵喵

    李小帅