Linux LNMP架构搭建
一.搭建LNMP基本架构
1.L(http) N(nginx) M(mysql) P(php)
2.安装顺序 Mysql-->PHP-->Nginx
3.安装包
Discuz_3..0_SC_GBK
nginx-1.4.
httpd-2.4.
php-5.3.
mysql-5.6.38-linux-glibc2.12-i686
4.安装mysql数据库
(1)解压mysql压缩包
tar zxvf mysql.tar.gz
(2)将mysql目录移动/usr/下。
mv mysql目录 /usr/local/mysql
(3)在mysql目录下,创建目录,作为datadir(数据目录)
mkdir /data/mysql
(4)创建mysql用户,不允许登陆,不创建家目录。
useradd -s /sbin/nologin -M mysql
(5)将/data/mysql/目录所属组所属主给mysql用户。
chown -R mysql:mysql /data/mysql/
(6)将配置文件存放到/etc/my.conf覆盖。
cp /mysql目录/support-files/my-large.cnf /etc/my.cnf
(7)修改配置文件
vim进入/etc/my.conf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. [mysqld]
port = 3306
socket = /usr/local/mysql/mysql.sock
datadir = /data/mysql
pid-file = /data/mysql/mysql.pid
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at % of total RAM for dedicated server, else %.
# innodb_buffer_pool_size = 128M
------------------------------------------
常用参数: Port #监听端口 Socket #通信方式 Key_buffer_size #mysql内存使用大小 Log-bin=mysql-bin #记录二进制日志,注释掉。 Binlog_format=mixed #日志相关参数,注释掉。 Server_id= #主从复制参数,注释掉。
(8)将服务的启动脚本放入/etc/init.d/下。
cp /mysql目录/support-files/mysql.server /etc/init.d/mysqld
(9)修改启动文件。
vi /etc/init.d/mysqld
# The following variables are only set for letting mysql.server find things. # Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
mysqld_pid_file_path=/data/mysql/master.pid
------------------------------------------ basedir #定义程序所在路径 bindir #定义数据库启动路径
(10)在mysql目录下初始化mysql服务,看到两个ok就没问题。
mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
报错1:Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.: cannot open shared object file: No such file or directory
解决:yum install –y libai* 报错2:Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libnuma.so.: cannot open shared object file: No such file or directory
解决:yum install –y numactl-*
(10)报错
(11)查看是否生成mysql,test。
mysql]# ls /data/mysql
(12)启动mysql。
mysql]# /etc/init.d/mysqld start
报错1:Starting MySQL.... ERROR! The server quit without updating PID file (/data/mysql/localhost.localdomain.pid).
解决:[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql.mysql .
(12)报错
(13)查看mysql进程。
ps aux|grep mysql
(14)开启mysql命令终端Mysql>。
/usr/local/mysql/bin/mysql
报错1:ERROR (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决:ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock
(14)报错
报错1:ERROR (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
解决:ln -s /usr/local/mysql/mysql.sock /tmp/mysql.
(15)设置开机自启动
chkconfig --list | grep mysql #查看是否存在mysql服务。
chkconfig --add mysqld #添加mysqld服务
chkconfig mysqld on #打开开机自启动
/usr/local/mysql/bin/mysql
注:测试启动mysql
(16)添加环境变量赋值。可使用mysql命令直接启动。在当前终端生效。
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root]# mysql #测试登陆
(17)设置所有终端都可访问。
vim /etc/profile
#文件最下面输入
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
source /etc/profile #即时生效
(18)设置mysql管理员密码。
mysqladmin -uroot password ’123456‘
mysql -u root -p #登陆
注:再次登陆应输入管理员,与密码。
(19)mysql下添加普通用户赋予管理权限,对应主机,与密码。
mysql> grant all on *.* to 'user1'@'localhost' identified by 'discuz';
5.安装PHP
(1)解压php压缩包。
tar xvzf php-5.3.22.tar.gz
(2)创建PHP禁止登陆用户。
useradd -s /sbin/nologin php-fpm
(3)进入php目录下。
cd php-5.3.22
(4)编译安装PHP。
php-5.3.22]#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-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 --enable-zend-multbyte --disable-ipv6 --with-pear --with-curl
yum -y install gcc
yum -y install libxml2-devel*
yum -y install bzip2-devel*
yum -y install curl curl-devel
yum -y install libjpeg-devel
yum -y install openssl-devel*
yum -y install freetype-devel*
yum -y install libpng-devel
yum -y install libmcrypt-devel*
#没有安装包需要下载源码包
#安装编译包
注:如果报错可同过 yum list | grep 报错名 :来查找需要安装的包
php-5.3.22]#make #编译
php-5.3.22]#make install #编译安装
(5)拷贝php配置文件。
php-5.3.22]#cp php.ini-production /usr/local/php/etc/php.ini
(6)修改PHP配置文件,将off改为on。
vim /usr/local/php/etc/php.ini
short_open_tag = on
(6)拷贝启动脚本。
php-5.3.22]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
(7)赋予php-fpm文件权限。
chmod 755 /etc/init.d/php-fpm
(8)启动php服务。
/etc/init.d/php-fpm start
报错1:ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
解决:进入/usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
(8)报错
(9)查看PHP进程。
ps aux | grep php

注:Ss是主进程 S是子进程
(10)查看PHP监听端口。

注:查看监听端口9000
6.安装nginx
(1)解压Nginx压缩包。
tar xvzf nginx-1.4.4.tar.gz
(2)进入Nginx目录。
cd nginx-1.4.4
(3)Nginx编译安装
nginx-1.4.4]#./configure --prefix=/usr/local/nginx --with-pcre
报错1:error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决:yum install -y pcre-devel
(3)报错
make #编译
make install #编译安装
(4)启动Nginx程序
nginx-1.4.4]# /usr/local/nginx/sbin/nginx
(5)查看Nginx进程
ps aux | grep nginx

(6)关闭防火墙,SELINUX
service iptables stop
getenforce 0
(7)测试Nginx

二.论坛安装
1.Nginx配置文件调试
(1)调试Nginx主配置文件
vim /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ; #处理的连接数
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; #gzip on;
server { #虚拟主机
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main;
location / { #配置网站所在的路径
root /usr/local/url; #网站根目录
index index.html index.htm index.php; #首页索引类型
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
# keepalive_timeout ; #gzip on; server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main;
location / {
root /usr/local/url;
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#解开注释调用php
location ~ \.php$ {
root /usr/local/url; #网站路径(修改)
fastcgi_pass 127.0.0.1:9000; #指定通信代理(可改为soket)
fastcgi_index index.php; #指定主页索引页
fastcgi_param SCRIPT_FILENAME /usr/local/usl$fastcgi_script_name; #脚本所在路径 (修改)
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
(2)测试Nginx配置文件
/usr/local/nginx/sbin/nginx -t
注:yntax is ok 没问题!
(3)加载配置文件
/usr/local/nginx/sbin/nginx -s reload
2.安装论坛网站
(1)解压论坛文件包。
unzip Discuz_X3.2_SC_GBK.zip
(2)创建网站根目录。
mkdir /usr/local/url
(3)将网站程序移动到网站目录下。
mv uplocad/* /usr/local/url
(4)删除多余文件。
rm -rf upload/ utility/ readme/
(5)权限修改。
ps aux | grep nginx
注:nginx执行用户位nobody用户,而网站文件是root用户,则没有权限执行
chown -R nobody config/ data uc_client/data uc_server/data
注:修改网站文件目录的执行用户,-R递归目录下的子目录。
(6)安装论坛
Linux LNMP架构搭建的更多相关文章
- 基于LNMP架构搭建wordpress博客之安装架构说明
架构情况 架构情况:基于LNMP架构搭建wordpress系统 软件包版本说明: 系统要求 : CentOS-6.9-x86_64-bin-DVD1.iso PHP版本 : php-7.2.29 ...
- Linux:LNMP架构的搭建
LNMP架构的搭建 centos6.8-i686 MySQL PHP Nginx 搭建前先安装一些必要的rpm和php组件(全新系统) yum install -y wget gcc vim* lib ...
- Linux系统下LNMP架构搭建
一.防火墙状态: 1.查看防火墙状态: systemctl status firewalld service iptables status firewall-cmd --state 2.永久有效开启 ...
- 企业级LNMP架构搭建实例(基于Centos6.x)
1.1 部署LNMP架构说明 1.1.1 LNMP架构内容 01.部署linux系统 02.部署nginx网站服务 03.部署mysql数据库服务 04.部署php动态解析服务 1.1.2 配置LNM ...
- 部署企业LNMP架构搭建bbs
部署企业LNMP架构 1===============部署Nginx 2===============安装及部署Mysql数据库 3===============安装PHP解析环境 4======== ...
- LNMP架构搭建
目录 一:LNMP架构简介 1.Nginx与uwsgi 二:django框架+python 1.创建用户 2.安装依赖包 3.安装uwsgi和django 4.测试python 5.创建django项 ...
- lnmp架构搭建实例
lamp->lnmp nginx survey.netcraft.net 查看各大网站使用的web服务器,使用下面的命令 # curl -I www.sina.com 结论:现在大型网站几乎统一 ...
- Linux LAMP架构搭建
一.部署LAMP基本架构 1.L(linux)A(apache)M(mysql)P(php) 2.稳定版本(mysql5.1,php5.3,apache2.2) 3.安装顺序,mysql-->a ...
- 基于LNMP架构搭建wordpress个人博客
搭建过程 注意防火墙和selinux的影响可以先关闭. 一.安装nginx # 1.更改nginx源安装nginx [root@web01 ~]# vi /etc/yum.repos.d/nginx. ...
随机推荐
- ICSharpCode.SharpZipLib.dll 压缩多文件
网站:http://icsharpcode.github.io/SharpZipLib/ 引用:ICSharpCode.SharpZipLib.dll private string CompassZi ...
- Spark集群高可用HA配置
本文中的Spark集群包含三个节点,分别是Master,Worker1,Worker2. 1.在Master机器上安装Zookeeper,本文安装在/usr/etc目录下 2.在Master机器配置Z ...
- 一套准确率高且效率高的分词、词性标注工具-thulac
软件简介 THULAC(THU Lexical Analyzer for Chinese)由清华大学自然语言处理与社会人文计算实验室研制推出的一套中文词法分析工具包,具有中文分词和词性标注功能.THU ...
- Oracle管理监控之oracle用户管理方法
创建用户语法: create user 用户名 identified by 密码: em:create user wangwc identified by tiger; 修改用户密码语法: alter ...
- idea启动tomcat后访问项目报java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
一.报错“java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet” 1.File --- ...
- 2015 湘潭大学程序设计比赛(Internet)--E题--烦人的异或
烦人的异或 Accepted : 27 Submit : 102 Time Limit : 5000 MS Memory Limit : 65536 KB 题目描述 如下图,有一N*M的表格, ...
- Django ORM之QuerySet
Django ORM用到三个类:Manager.QuerySet.Model.Manager定义表级方法(表级方法就是影响一条或多条记录的方法),我们可以以models.Manager为父类,定义自己 ...
- 【Python】详解Python多线程Selenium跨浏览器测试
前言 在web测试中,不可避免的一个测试就是浏览器兼容性测试,在没有自动化测试前,我们总是苦逼的在一台或多台机器上安装N种浏览器,然后手工在不同的浏览器上验证主业务流程和关键功能模块功能,以检测不同浏 ...
- (3.13)mysql基础深入——mysql日志分析工具之mysqlsla【待完善】
(3.13)mysql基础深入——mysql 日志分析工具之mysqlsla 关键字:Mysql日志分析工具.mysqlsla 常用工具 [1]mysqldumpslow:官方提供的慢查询日志分析工具 ...
- mysql 权限管理介绍
mysql权限管理 就是对控制用户对库.对表的权限.对表中字段权限 权限管理分步 1.创建账号 创建账号有本地账号和远程账号 本地账号 本地账号只能在mysql服务端机器做操作 '; # mysql ...