centos7.2 安装Lnmp
1. 安装编译工具及库文件
yum install -y make apr* autoconf automake curl
\ curl-devel gcc gcc-c++ cmake gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl
\ kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libarchive
\ libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng*
\ php-common php-gd gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch policycoreutils bison
2. 安装依赖文件
2.1 编译安装cmake
wget https://cmake.org/files/v3.3/cmake-3.3.2.tar.gz
tar -zxvf cmake-3.3.2.tar.gz
cd cmake-3.3.2.tar.gz
./configure --prefix=/usr/local/soft/cmake
make
make install
vim /etc/profile 在path路径中增加cmake执行文件路径:
export PATH=$PATH:/usr/local/cmake/bin
使配置立即生效:
source /etc/profile
cmake --version
2.2 安装 pcre
wget https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure --prefix=/usr/local/soft/pcre
make && make install
2.3 安装 libmcrypt
wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/soft/libmcrypt
make && make install
2.4 安装GD库
wget https://jaist.dl.sourceforge.net/project/gd2/gd-2.0.35.tar.gz
tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --enable-m4_pattern_allow --prefix=/usr/local/soft/gd --with-jpeg=/usr/lib --with-png=/usr/lib --with-xpm=/usr/lib --with-freetype=/usr/lib --with-fontconfig=/usr/lib
make && make install
3.安装nginx
3.1 配置nginx支持php
nginx.conf文件 的 http {} 里面加入 include conf/*.conf;
server {
listen 80 default_server;
listen 80;
#listen 443 ssl;
server_name www.test.com;
#access_log /data/wwwlogs/xxx.xxxx.log
#error_log /data/wwwlogs/xxx.xxxxx_error.log;
set $root /www/test;
#ssl_certificate cert/www.weigeee.com.pem;
#ssl_certificate_key cert/www.weigeee.com.key;
index index.html index.php;
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
root $root;
}
location / {
root $root;
index index.html index.php;
if ( -f $request_filename) {
break;
}
if ( !-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
}
3.2 nginx快捷启动配置
在/etc/init.d下创建nginx启动脚本文件: nginx
#!/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/soft/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/soft/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
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
killall -9 nginx
} 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
修改脚本权限:
chmod 755 nginx
将脚本文件加入到chkconfig中:
chkconfig --add nginx
设置nginx开机在3和5级别自动启动:
chkconfig --level 35 nginx on
创建软连接:
cd /usr/bin
ln -s /etc/init.d/nginx
示例:
nginx start
nginx stop
nginx restart
4.安装php7.2
./configure --prefix=/usr/local/soft/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel openssl openssl-devel curl curl-devel cp ./php.ini-development /usr/local/soft/php/etc/php.ini cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/soft/php/etc/php-fpm.conf.default /usr/local/soft/php/etc/php-fpm.conf
cp /usr/local/soft/php/etc/php-fpm.d/www.conf.default /usr/local/soft/php/etc/php-fpm.d/www.conf # 加入服务
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm # 将PHP加入全局变量
vim /etc/profile export PATH=$PATH:/usr/local/soft/php/bin
#保存并在命令行执行
source /etc/profile # 启动
systemctl start php-fpm
5.安装MySQL
groupadd mysql#添加mysql组
useradd -g mysql mysql -s /sbin/nologin #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
mkdir -p /data/mysql #创建MySQL数据库存放目录
chown -R mysql:mysql /data/mysql #设置MySQL数据库目录权限
cd /lnmp/src
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz #修改文件夹名字
#将解压后的文件夹修改名字,文件夹名字改为mysql #创建data文件夹
mkdir /usr/local/soft/mysql/data #授权目录和用户
chown -R mysql:mysql mysql/
chmod -R 755 mysql/ #安装并初始化 datadir就是安装路径,basedir就是根目录
/usr/local/soft/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/soft/mysql/data --basedir=/usr/local/soft/mysql #最后一行会有默认生成的密码,记下来
A temporary password is generated for root@localhost: n2ta1yWih9-/ #复制启动脚本到资源目录
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动
chmod 755 /etc/init.d/mysqld #增加执行权限
chkconfig mysqld on #加入到服务里面 vi /etc/rc.d/init.d/mysqld #编辑
datadir=/usr/local/soft/mysql/data #MySQL程序安装路径
basedir=/usr/local/soft/mysql/ #MySQl数据库存放目录
service mysqld start #启动 # 编辑/etc/my.cnf
[mysqld]
datadir=/usr/local/soft/mysql/data
basedir=/usr/local/soft/mysql/
socket=/usr/local/soft/mysql/data/mysql/mysql.sock user=mysql
port=3306
character-set-server=utf8 [mysqld_safe]
log-error=/usr/local/soft/mysql/logs/mysqld.log
pid-file=/usr/local/soft/mysql/logs/mysqld.pid vim /etc/profile #把mysql服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/usr/local/soft/mysql/bin
source /etc/profile #使配置立即生效 mkdir /var/lib/mysql #创建目录
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock #添加软链接 # 开放远程连接
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; grant all privileges on *.* to 'root'@'%' identified by 'root'; flush privileges;
6.安装redis
6.1 安装phpredis 扩展(让php7可以使用redis)
centos7.2 安装Lnmp的更多相关文章
- centos7 yum 安装lnmp
centos7 yum 安装lnmp 安装7.2把7.1改成7.2就行 使用第三方扩展epel源安装php7.2 #移除旧版php [root@web02 ~]# yum remove php-m ...
- 用Xshell在centos7下安装lnmp服务
虚拟机已创建好,本机已安装Xshell 一.准备工作:安装常用工具 1.1 yum install -y vim 备注:-y是同意安装过程中的询问,不被询问打断安装 vim:vim是一个类似于Vi的 ...
- centos7.0 安装LNMP运行环境
LNMP作为php流行的运行环境,而最近需要搭建一个内部的php论坛.记录下LNMP的安装: 1.安装mysql 请参考:centos7 安装mysql5.7.11注意事项 2.安装php yum i ...
- CentOS7 编译安装LNMP
(文章来自:http://www.cnblogs.com/i-it/p/3841840.html,请各位到这个网址去看原文的) LNMP(Linux-Nginx-Mysql-PHP),本文在CentO ...
- Centos7 yum安装LNMP
1.Centos7系统库中默认是没有nginx的rpn包的,所以我们需要先更新下rpm依赖库 (1):使用yum安装nginx,安装nginx库 rpm -Uvh http://nginx.org/p ...
- Centos7编译安装lnmp(nginx1.10 php7.0.2)
我使用的是阿里云的服务器 Centos7 64位的版本 1. 连接服务器 这个是Xshell5的版本 安装好之后我们开始连接服务器 2. 安装nginx 首先安装nginx的依赖 yum instal ...
- CentOS7 下安装 Lnmp 架设 Laravel
最近在hostos上买了个香港的 vps, 装的 centos7, 在架设了 pptp vpn, 效果还行,就想顺便架设个 laravel 看看.下面是架设的过程.准备工作 更新 yum 源,自带的源 ...
- centos7编译安装LNMP(nginx-1.16.0,mysql8.0.16,php-7.3.6)常见问题报错及解决方法
LNMP的安装与配置 nginx-1.16.0安装及配置: 第一步:前往官网下载nignx源码包 下载完毕后上传至服务器(先安装lrzsz) yum -y install lrzsz 安装完毕后执行: ...
- centos7编译安装lnmp
1.前言 本文适合于已经对Linux操作系统具有基本操作经验,并且能够在Linux或Windows上通过一键搭建工具或者yum命令行进行环境搭建的读者,阅读本文需具有一定的专业知识,本文不建议初学者阅 ...
随机推荐
- Python3操作YAML文件
数据及配置文件之争 数据及文件通常有三种类型: 配置文件型:如ini,conf,properties文件,适合存储简单变量和配置项,最多支持两层,不适合存储多层嵌套数据 表格矩阵型:如csv,exce ...
- go语言学习笔记之数组
package main import ( "fmt" ) func main() { // Declare arrays var x[5] int //Assign value ...
- Jmeter Web 性能测试入门 (四):一个小实例带你学会 Jmeter 脚本编写
测试场景: 模拟并发100个user,在TesterHome 站内搜索VV00CC 添加线程组 添加HTTP信息头管理器 添加HTTP Sampler 填写HTTP Sampler中的信息 添加监听器 ...
- Server2012R2实现活动目录(Active Directory)双域控制器互为冗余
在活动目录中部署两台主控域控制器,两台域控制器互为冗余. Server 2012 R2新建活动目录和DC refer to: https://www.cnblogs.com/jfzhu/p/40061 ...
- 黑马vue---56-58、vue组件创建的三种方式
黑马vue---56-58.vue组件创建的三种方式 一.总结 一句话总结: 不论是哪种方式创建出来的组件,组件的 template 属性指向的模板内容,必须有且只能有唯一的一个根元素 1.使用 Vu ...
- c++自定义数组越异常 ArrayIndexOutOfBoundsException (学习)
#include <iostream> using namespace std; const int DefaultSize = 10; class Array{public: Array ...
- 实现在线阅读WORD,PDF等文件,JAVA,PHP都可以
1 <?php 2 //header("Content-type:text/html;charset=utf-8"); 3 //word转html 展示 4 $lj=$_GE ...
- 如何开始学习使用TensorFlow?
Harrison Kinsley ——PythonProgramming.net的创始人 TensorFlow官方网站有相当多的文档和教程,但这些往往认为读者掌握了一些机器学习和人工智能知识.除了知道 ...
- HAProxy+Keepalived 高可用负载均衡
转自 https://www.jianshu.com/p/95cc6e875456 Keepalived+haproxy实现高可用负载均衡 Master backup vip(虚拟IP) 192.16 ...
- Maven项目添加阿里云HBase依赖之后第一行才出现红叉报错“Missing artifact jdk.tools:jdk.tools:jar:1.6”的解决办法
首先是从阿里云上下载了一个样例项目"hbase-demo",然后用eclipse打开,此时eclipse会去下载aliyun.hbase依赖. 等待一段时间后,pom.xml却报错 ...