安装准备:

Centos7.3

MYSQL5.6

PHP5.6

NGINX1.10.3

一、安装Mysql

mysql:
[root@host129 src]#cd /usr/local/src/ [root@host129 src]# wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
[root@host129 src]# tar zxvf mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz 
[root@host129 src]# mv mysql-5.6.41-linux-glibc2.12-x86_64 /usr/local/mysql
[root@host129 src]# useradd -s /sbin/nologin mysql [root@host129 src]# cd /usr/local/mysql/
[root@host129 mysql]# mkdir -p /data/mysql
[root@host129 mysql]# chown -R mysql:mysql /data/mysql/
[root@host129 mysql]#
[root@host129 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@host129 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
出现以上报错:安装一下软件,再次执行脚本
[root@host129 mysql]# yum -y install autoconf
[root@host129 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
[root@host129 mysql]# cp support-files/my-default.cnf /etc/my.cnf
[root@host129 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@host129 mysql]# chmod /etc/init.d/mysqld
[root@host129 mysql]# vim /etc/init.d/mysqld datadir=/data/mysql [root@host129 mysql]# chkconfig --add mysqld
[root@host129 mysql]# chkconfig mysqld on
[root@host129 mysql]# service mysqld start
Starting MySQL.Logging to '/data/mysql/host129.err'.
. SUCCESS!
[root@host129 mysql]# ps aux | grep mysqld 首次进入mysql:
[root@host129 ~]# /usr/local/mysql/bin/mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.41 MySQL Community Server (GPL)

mysql> exit
Bye

二、安装PHP

PHP:
[root@host129 src]#cd /usr/local/src/
[root@host129 src]#wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
[root@host129 src]#tar zxf php-5.6..tar.gz
[root@host129 src]# useradd -s /sbin/nologin php-fpm
[root@host129 src]# cd php-5.6.
[root@host129 php-5.6.]# [root@host129 php-5.6.]# ./configure \
--prefix=/usr/local/php-fpm \
--with-config-file-path=/usr/local/php-fpm/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl error1:
configure: error: xml2-config not found. Please check your libxml2 installation.
[root@host129 php-5.6.]# yum -y install libxml2
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors..com
* epel: mirrors.ustc.edu.cn
* extras: mirrors..com
* updates: mirrors..com
软件包 libxml2-2.9.-.el7_2..x86_64 已安装并且是最新版本
无须任何处理
解决:
[root@host129 php-5.6.]# yum -y install libxml2-devel error2:
configure: error: Cannot find OpenSSL's <evp.h>
解决:
[root@host129 php-5.6.]#yum -y install openssl.x86_64 openssl-devel.x86_64 error3:
checking for T1lib support... no
checking whether to enable truetype string function in GD... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-vpx-dir=<DIR>
configure: error: jpeglib.h not found.
解决:
[root@host129 php-5.6.]# yum -y install libjpeg libjpeg-devel error4:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:
[root@host129 php-5.6.]#yum -y install libmcrypt libmcrypt-devel [root@host129 php-5.6.]#make install
[root@host129 php-5.6.]# echo $? [root@host129 php-5.6.]# cp php.ini-production /usr/local/php-fpm/etc/php.ini
[root@host129 php-5.6.]# vim /usr/local/php-fpm/etc/php-fpm.conf
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
listen.mode =
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children =
pm.start_servers =
pm.min_spare_servers =
pm.max_spare_servers =
pm.max_requests =
rlimit_files = [root@host129 php-5.6.]# /usr/local/php-fpm/sbin/php-fpm -t
[-Apr- ::] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful [root@host129 php-5.6.]# cp /usr/local/src/php-5.6./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@host129 php-5.6.]# chmod /etc/init.d/php-fpm
[root@host129 php-5.6.]# useradd -s /sbin/nologin php-fpm
useradd:用户“php-fpm”已存在
[root@host129 php-5.6.]# service php-fpm start
Starting php-fpm done
[root@host129 php-5.6.]# chkconfig php-fpm on
[root@host129 php-5.6.]# ps aux |grep php-fpm

三、安装Nginx

NGINX:

NGINX官网https://nginx.org/
[root@host129 src]#cd /usr/local/src/
[root@host129 src]# wget https://nginx.org/download/nginx-1.10.3.tar.gz
[root@host129 src]# tar zxvf nginx-1.10..tar.gz
[root@host129 src]# cd nginx-1.10./
[root@host129 nginx-1.10.]# ./configure --prefix=/usr/local/nginx
[root@host129 nginx-1.10.]# make & make install 编写nginx启动脚本:
[root@host129 nginx-1.10.]# vim /etc/init.d/nginx #!/bin/bash
# chkconfig: -
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=
esac
exit $RETVAL 保存以上脚本更改权限:
[root@host129 nginx-1.10.]# chmod /etc/init.d/nginx
添加nginx服务项命令:
[root@host129 nginx-1.10.]# chkconfig --add nginx
添加完设置启动项:
[root@host129 nginx-1.10.]# chkconfig nginx on 清空原配置文件:
[root@host129 nginx-1.10.]# > /usr/local/nginx/conf/nginx.conf 重新写入一下内容:
[root@host129 nginx-1.10.]#vim /usr/local/nginx/conf/nginx.conf user nobody nobody;
worker_processes ;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile ;
events
{
use epoll;
worker_connections ;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size ;
server_names_hash_max_size ;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
' $host "$request_uri" $status'
' "$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout ;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size ;
client_header_buffer_size 1k;
large_client_header_buffers 4k;
request_pool_size 4k;
output_buffers 32k;
postpone_output ;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 8k;
gzip_comp_level ;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm
application/xml;
server
{
listen ;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
} 验证一nginx下配置文件:
[root@host129 nginx-1.10.]# /usr/local/nginx/sbin/nginx -t
内容显示如下正常:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful (查看一下:
[root@host129 nginx-1.10.]#ps aux |grep httpd
[root@host129 nginx-1.10.]#service stop httpd
也可以直接卸载:yum -y remove httpd )如果没下边启动报错可以不用做这一步 启动Nginx:
[root@host129 nginx-1.10.]# service nginx start
StartStarting nginx (via systemctl): Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details 如果报以上错误:
通过查看日志:/var/log/messages这个日志
[root@host129 nginx-1.10.]# less /var/log/messages
Apr :: host129 nginx: Starting Nginx: nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
Apr :: host129 nginx: nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
Apr :: host129 nginx: nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
Apr :: host129 nginx: nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
Apr :: host129 nginx: nginx: [emerg] bind() to 0.0.0.0: failed (: Address already in use)
Apr :: host129 nginx: nginx: [emerg] still could not bind()
Apr :: host129 nginx: [失败]
Apr :: host129 systemd: nginx.service: control process exited, code=exited status=
Apr :: host129 systemd: Failed to start SYSV: http service..
Apr :: host129 systemd: Unit nginx.service entered failed state.
Apr :: host129 systemd: nginx.service failed. 发现nginx端口被占用:
[root@host129 nginx-1.10.]# ps aux |grep httpd
root 0.0 0.3 ? Ss : : /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.2 ? S : : /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.2 ? S : : /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.2 ? S : : /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.2 ? S : : /usr/sbin/httpd -DFOREGROUND
apache 0.0 0.2 ? S : : /usr/sbin/httpd -DFOREGROUND
root 0.0 0.0 pts/ R+ : : grep --color=auto httpd
[root@host129 nginx-1.10.]# service stop httpd
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@host129 nginx-1.10.]# systemctl stop httpd
[root@host129 nginx-1.10.]# service nginx start
Starting nginx (via systemctl): [ 确定 ] 查看nginx启动进程:
[root@host129 nginx-1.10.]# ps aux |grep nginx
root 0.0 0.0 ? Ss : : nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 0.0 0.2 ? S : : nginx: worker process
nobody 0.0 0.2 ? S : : nginx: worker process
root 0.0 0.0 pts/ R+ : : grep --color=auto nginx 验证php解析:
[root@host129 nginx-1.10.]# vim /usr/local/nginx/html/.php
<?php
echo "test php scripts"
?>
[root@host129 nginx-1.10.]# curl localhost/.php
test php scripts
证明php解析正常

四、配置虚拟主机

[root@host129 ~]# vim /usr/local/nginx/conf/nginx.conf
结束符之前:
include vhost/*.conf;
}
[root@host129 ~]# mkdir /usr/local/nginx/conf/vhost
[root@host129 ~]# cd /usr/local/nginx/conf/vhost/
[root@host129 vhost]# vim default.conf server
{
listen 80 default_server;
server_name yanglt.com;
index index.html index.htm index.php;
root /data/nginx/default;
} [root@host129 vhost]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful # /usr/local/nginx/sbin/nginx -s reload
#makdir -r /data/nginx/default
#echo "default_server" > /data/nginx/default/index.html
[root@host129 nginx]# curl -x127.9.9.1:80 yanglt.com
default_server
[root@host129 nginx]# curl -x127.9.9.1:80 ssss.com
default_server

【Linux运维】LNMP环境配置的更多相关文章

  1. linux运维之路配置网络

    前言裸机上装操作系统,想和物理机通信需要设置IP 开机以后: 第一步:setup命令  ——>  NetWork configguation  ---->Device configurat ...

  2. 网络配置——Linux运维基础

    今天把Linux的网络配置总结了一下,尽管并不难可是是个比較重要的基础.然后我也不知到自己以后是否会做运维,可是我知道自己比較喜欢刨根问底.还有就是我很珍惜我以前掌握过的这些运维的技能.今天突然间问自 ...

  3. 做linux运维工程师,必须要掌握以下几个工具

    linux系统如果是学习可以选用redhat或centos,特别是centos在企业中用得最多,当然还会有其它版本的,但学习者还是以这2个版本学习就行,因为这两个版本都是兄弟,没区别的,有空可以再研究 ...

  4. Linux运维入门到高级全套常用要点

    Linux运维入门到高级全套常用要点 目 录 1. Linux 入门篇................................................................. ...

  5. 要做linux运维工程师的朋友,必须要掌握以下几个工具才行 ...

    要做linux运维工程师的朋友,必须要掌握以下几个工具才行 ...  [复制链接]   发表于 2013-12-13 15:59 | 来自  51CTO网页 [只看他] 楼主           本人 ...

  6. Linux运维工程师入门的10大实用工具

    说到工具,在行外可以说是技能,在行内我们一般称为工具,就是运维必须要掌握的工具. 我就大概列出这几方面,这样入门就基本没问题了. 工具如下: 1.Linux系统基础 这个不用说了,是基础中的基础,连这 ...

  7. Linux运维工程师入门须掌握的10个技术点

    本人是linux运维工程师,对这方面有点心得,现在我说说要掌握哪方面的工具吧 说到工具,在行外可以说是技能,在行内我们一般称为工具,就是运维必须要掌握的工具. 我就大概列出这几方面,这样入门就基本没问 ...

  8. 详解linux运维工程师入门级必备技能

    详解linux运维工程师入门级必备技能 | 浏览:659 | 更新:2013-12-24 23:23 | 标签:linux it自动化运维就是要很方便的运用各种工具进行管理维护,有效的实施服务器保护 ...

  9. Linux 运维工程师的十个基本技能点

    本人是linux运维工程师,对这方面有点心得,现在我说说要掌握哪方面的工具吧. 说到工具,在行外可以说是技能,在行内我们一般称为工具,就是运维必须要掌握的工具.我就大概列出这几方面,这样入门就基本没问 ...

  10. linux运维工程师

    本人是linux运维工程师,对这方面有点心得,现在我说说要掌握哪方面的工具吧说到工具,在行外可以说是技能,在行内我们一般称为工具,就是运维必须要掌握的工具.我就大概列出这几方面,这样入门就基本没问题了 ...

随机推荐

  1. java中String、StringBuffer和StringBuilder的区别(简单介绍)

    简单介绍 java中用于处理字符串常用的有三个类: 1.java.lang.String 2.java.lang.StringBuffer 3.java.lang.StrungBuilder 三者共同 ...

  2. linux多线程编程基本操作(2)

    linux c多线程总结: :关于线程和进程 a:使用多线程的理由之一是和进程相比,它是一种非常"节俭"的多任务操作方式.我们知道,在Linux系统下,启动一个新的进程必须分配给 ...

  3. 课时57.HTML被废弃的标签(掌握)

    1.为什么HTML中有一部分标签会被废弃? 因为当前HTML中的标签只有一个作用,就是用来添加语义,而早期的HTML标签中有一部分标签是没有语义的 有一部分标签是用来修改样式的 所以这部分标签就被淘汰 ...

  4. ios学习路线—Objective-C(堆(heap)和栈(stack))

    Objective-C的对象在内存中是以堆的方式分配空间的,并且堆内存是由你释放的,即release 栈由编译器管理自动释放的,在方法中(函数体)定义的变量通常是在栈内,因此如果你的变量要跨函数的话就 ...

  5. Webpack4 学习笔记七 跨域服务代理

    webpack 小插件使用 webpack 监听文件变化配置 webpack 处理跨域问题 Webpack 小插件使用 clean-webpack-plugin: 用于在生成之前删除生成文件夹的Web ...

  6. Excel导入功能(Ajaxfileupload)

    前言: 前端采用Easyui+Ajaxfileupload实现 后端采用springmvc框架,其中把解析xml封装成了一个jar包,直接调用即可 准备: 前端需要导入(easyui导入js省略,自行 ...

  7. pushlet(QQ提示框)

    Pushlet 实现服务端往客服端推送消息 系统页面弹出消息框,类似QQ提示框 1. java代码 package com.test.jbpm.common; import java.io.Seria ...

  8. php第二节(变量、常量)

    <?php /** * 类型转换 * 自动转换 数据在运算过程中自动转换 * 空字符串 false * "0" false * null false * 0 false * ...

  9. 洛谷P1196 [NOI2002]银河英雄传说(带权并查集)

    题目描述 公元五八○一年,地球居民迁至金牛座α第二行星,在那里发表银河联邦创立宣言,同年改元为宇宙历元年,并开始向银河系深处拓展. 宇宙历七九九年,银河系的两大军事集团在巴米利恩星域爆发战争.泰山压顶 ...

  10. phpstudy配置域名后apache无法启动

    1.设置域名后重启 apache停止了 检查步骤1.php路径不要有中文,phpstudy重新安装在无中文路径 2.检查80端口是否被占用,如果被占用可以停止该程序或者修改apache/nginx 端 ...