编译安装LNMP全程实录
此次是在CentOs 7.4上进行安装配置,先把编译环境配置好:
yum -y install gcc automake autoconf libtool makeyum install gcc gcc-c++
准备一些软件的安装包:
安装包 | 地址 | 用途 |
---|---|---|
php-7.1.6.tar.bz2 | http://cn2.php.net/distributions/php-7.1.6.tar.bz2 | 后端语言 |
nginx-1.12.2.tar.gz | http://nginx.org/download/nginx-1.12.2.tar.gz | 服务器 |
mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz | https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz | 数据库 |
openssl-1.0.2n.tar.gz | https://www.openssl.org/source/openssl-1.0.2n.tar.gz | nginx扩展,安全套接字层密码库 |
pcre-8.41.tar.gz | ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz | nginx扩展,支持rewrite功能 |
zlib-1.2.9.tar.gz | http://www.zlib.net/fossils/zlib-1.2.9.tar.gz | nginx扩展,gzip压缩 |
将表中安装包使用tar命令解压,.tar.gz格式可使用-xf参数解压,.tar.bz2可使用-jxvf参数解压,如果tar.bz2解压报错:
tar: bzip2: Cannot exec: No such file or directory
说明没有安装bzip2,使用yum安装:
yum install bzip2
#现在进行nginx安装:
先安装扩展:
pcre
cd pcre-8.41
./configure
make
make install
zlib
cd zlib-1.2.9
./configure
make
make install
openssl
cd openssl-1.0.2n
./config
make
make install
nginx
添加nginx使用的用户组:
groupadd nginx
useradd -g nginx nginx -s /bin/false
编译nginx(下一篇博文有详细编译参数解析):
cd nginx-1.12.2./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=nginx --group=nginx --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.2n --with-zlib=/usr/local/src/zlib-1.2.9 --with-pcre=/usr/local/src/pcre-8.41
make
make install
这样就安装好了,使用/usr/local/nginx/sbin/nginx
即可启动nginx服务。
在浏览器中输入服务器地址出现“Welcome to nginx!”提示,即说明nginx正常运行:
接下来设置nginx开机启动:
编辑启动文件:vi /etc/init.d/nginx
写入下面的内容:
#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ [${NETWORKING} = "no"] ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];thenecho "nginx already running...."exit 1fiecho -n $"Starting $prog: "daemon $nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/subsys/nginxreturn $RETVAL}# Stop nginx daemons functions.stop() {echo -n $"Stopping $prog: "killproc $nginxdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid}# reload nginx service functions.reload() {echo -n $"Reloading $prog: "#kill -HUP `cat ${nginx_pid}`killproc $nginxd -HUPRETVAL=$?echo}# See how we were called.case "$1" instart)start;;stop)stop;;reload)reload;;restart)stopstart;;status)status $progRETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|reload|status|help}"exit 1esacexit $RETVAL
赋予文件执行权限:
chmod 775 /etc/init.d/nginx
设置开机启动:
chkconfig nginx on
重启:
/etc/init.d/nginx restart
将nginx服务加入chkconfig管理列表:
chkconfig --add /etc/init.d/nginx
现在可以使用service nginx restart
来重启服务了
#现在进行Mysql安装:
添加mysql使用的用户组:
groupadd mysql
useradd -g mysql mysql -s /bin/false
将mysql目录移动到默认安装目录:
mv -R /usr/lcoal/src/mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
并修改权限:
chown -R mysql:mysql /usr/local/mysql
进入mysql目录:
cd /usr/local/mysql
执行安装脚本:
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
复制mysql到服务自动启动里面
cp support-files/mysql.server /etc/init.d/mysqld
修改权限为755,增加执行权限:
chmod 755 /etc/init.d/mysqld
添加为开机自启服务:
chkconfig --add mysqld
设定mysqld在各等级为on:
chkconfig mysqld on
启动mysql:
service mysqld start
在执行安装脚本的步骤中,输出日志中有设置密码的命令提示:
执行./bin/mysqladmin -u root -h 主机名 password 'new-password'
再测试是否设置成功:./bin/mysql -uroot -p[new-password]
现在将mysql命令加入环境变量:
在/etc/profile
文件末尾添加一行:export PATH=$PATH:/usr/local/mysql/bin
使配置立刻生效:source /etc/profile
接下来登录mysql后执行:
grant all privileges on *.* to root@'%' identified by 'root';
flush privileges```使数据库可以远程连接。
最后把myslq的库文件链接到系统默认的位置:
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
重启mysql就好了:service mysqld restart
#最后安装PHP
依赖包太多,就yum安装吧:
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
编译:
./configure \--prefix=/usr/local/php \--with-config-file-path=/etc \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache
如果报错:error: mcrypt.h not found,则依次执行下面两个yum安装
yum install -y epel-release
yum install -y libmcrypt-devel
安装:
make && make install
配置环境变量:
在/etc/profile
末尾添加:
export PATH=$PATH:/usr/local/php/bin
使得改动立即生效:
source /etc/profile
配置php-fpm:
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
启动php-fpm:
/etc/init.d/php-fpm start
添加为系统服务:
chkconfig --add php-fpmchkconfig php-fpm on
重启php-fpm:
service php-fpm start
#配置nginx支持PHP:
vi /usr/local/nginx/conf/nginx.conf
取消下面这部分注释,并将fastcgi_param
这一行改成下面代码提供的参数:
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;
}
重启nginx和php-fpm:
service nginx start
service php-fpm start
#测试
在nginx安装目录中的html文件夹中新建一个php文件:
vi index.php
输入:
<?php phpinfo();
然后再在浏览器中访问http://–ip–/index.php,正常输出如下:
编译安装LNMP全程实录相关推荐
- CentOS6.9编译安装LNMP环境
CentOS6.9编译安装LNMP环境 今天尝试一下用编译的方式来搭建lnmp运行环境.所有软件都采用当前最新版本,除了CentOS.这是由于目前企业大多数应该都还在使用CentOS6的缘故,并且Ce ...
- CentOS 7.6编译安装LNMP
一.前期准备 1.服务器以最小化方式安装CentOS 7.6 2.配置本地源及安装epel源 #cd /etc/yum.repos.d #vi CentOS-Base.repo 增加enable=1 ...
- 测评宝塔编译安装LNMP与LNMP一键安装包速度比较
之前搭建网站用过宝塔编译安装LNMP和LNMP一键安装包,感觉两者还是有点差距,现在对两者做比较 服务器信息 服务器物理位置:香港沙田 线路:cn2 GIA 服务器价格:25元/月 配置:1H1G 3 ...
- 源码编译安装LNMP平台(使用Linux, Nginx,MySQL与PHP搭建论坛)
目录 编译安装NGINX 安装依赖包 新建用户 组便于管理(nginx 服务程序默认 以 nobody 身份运行,建议为其创建专门的用户账户,以便更准确的控制访问权限) 编译安装Nginx 添加 Ng ...
- 源码编译安装LNMP
Nginx是一种最重要的技能,在公司里可以不会其他的,nginx精通了你也可以所向披靡. 这篇文章也许是有史以来最长的文章了,没有之一. LNMP=Linux Nginx MysqlPHP nginx ...
- centos 6.8 php mysql_Centos 6.8编译安装LNMP环境(Nginx+MySQL+PHP)教程
前言 对于新手的一点建议: 最好熟悉一下linux 的基本命令,vim的常用命令 千万不要无脑复制,先看一下命令,特别是路径要注意 学会排查错误 本篇安装的软件版本为: Linux:Centos6.8 ...
- centos系统php环境配置,CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤
一.准备工作 上pkgs.org下载rmpforge.rpmforge是一个第三方yum源. 选择相应的版本下载安装. // 安装成功后,清空yum list 并 重新获取 [root@pangou ...
- CentOS 6.5 生产环境编译安装LNMP
一.环境准备 1.操作系统安装:CentOS 6.5 64位最小化安装. 2.配置好IP.DNS.网关.主机名 3.配置防火墙,开启80.3306端口 vim /etc/sysconfig/iptab ...
- debian源码编译安装mysql5.6_MySQL 5.6 Linux Debian/Ubuntu源码编译安装 LNMP之MySQL
安装所需依赖和工具apt-get install make gcc g++ libncurses5-dev cmake bison 配置cmake编译参数cmake . -DCMAKE_INSTALL ...
最新文章
- 生成大小写字母加数字混合ID与自定义进制转换
- TensorFlow 学习(十)—— 工具函数
- 链表C++ | 从尾部打印头部(使用栈、递归实现)_3
- 写给自己--70年代的程序员
- mysql 刚安装完的用户_mysql 离线安装后用户初始化
- 码栈——让一切变得自动化
- mysql修改字段的名称类型_MySQL修改字段名和字段数据类型
- Random Features for Large-Scale Kernel Machines笔记
- 人工智能发展历史 考题答案
- 使用deepin 20作为开发环境
- excel更改页眉页脚_如何在Excel的页眉和页脚中键入“&”号
- your compiler does not support AVX
- win10系统u盘安装单个文件超过4g解决办法
- 使用源码编译安装AMD ROCm
- xm-select 原始数据的回显及修改
- 笔记本电脑一开盖就开机?
- linux下简单配置zlib软件
- 局部载入html后 主页面变了,html局部刷新_Jquery.load载入页面实现局部刷新的代码...
- 佳能Canon imagePRESS C7010VP 打印机驱动
- teamviewer早期版本11-14 版 官方链接地址
热门文章
- Oreo授权系统V1.0.6公益开源版本源码
- CREAMy简洁大气模板Typecho主题
- 执子之手简约唯美的表白网站HTML源码
- xMenuTools(超实用右键菜单工具) v7.6
- 浪潮服务器系统套件,浪潮服务器随机套件版本列表
- 百度爬虫页面自动繁殖程序+教程自动SEO优化
- WordPress简洁大气自适应博客杂志类网站主题CX-MULTI
- Magento教程 3:如何在Magento社群版(Community Edition)安装范例资料?
- 深入理解Magento – 第二章 – Magento请求分发与控制器
- IBM PHP教程链接