LNMP-day1-安装并配置
Nginx安装
#Nginx
[root@localhost downloads]# pwd
/root/downloads
#安装依赖pcre
[root@localhost downloads]# wget https://ftp.pcre.org/pub/pcre/pcre-8.30.tar.gz --no-check-certificate
[root@localhost downloads]# tar zxf pcre-8.30.tar.gz
[root@localhost downloads]# cd pcre-8.30
[root@localhost pcre-8.30]# ./configure
[root@localhost pcre-8.30]# make && make install
#安装nginx
[root@localhost downloads]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@localhost downloads]# tar zxf nginx-1.12.2.tar.gz
[root@localhost downloads]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# useradd nginx -s /sbin/nologin -M
[root@localhost nginx-1.12.2]# yum -y install openssl*
[root@localhost nginx-1.12.2]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[root@localhost nginx-1.12.2]# make && make install [root@localhost nginx-1.12.2]# /usr/local/nginx/sbin/nginx -t #查看语法是否正确
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1:
cannot open shared object file: No such file or directory
[root@localhost nginx-1.12.2]# find / -name "libpcre.so.1"
/usr/local/lib/libpcre.so.1
/root/downloads/pcre-8.30/.libs/libpcre.so.1
[root@localhost nginx-1.12.2]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib #加入
[root@localhost nginx-1.12.2]# ldconfig #修改生效
[root@localhost nginx-1.12.2]# /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@localhost nginx-1.12.2]# /usr/local/nginx/sbin/nginx #启动
[root@localhost nginx-1.12.2]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 37289 root 6u IPv4 80050 0t0 TCP *:http (LISTEN)
nginx 37290 nginx 6u IPv4 80050 0t0 TCP *:http (LISTEN)
Mysql安装
#Mysql单实例安装
#准备工作
[root@localhost downloads]# groupadd mysql #创建组
[root@localhost downloads]# useradd -s /sbin/nologin mysql -g mysql -M #创建用户
[root@localhost downloads]# wget https://downloads.mysql.com/archives/get/file/mysql-5.5.32.tar.gz --no-check-certificate #下载mysql包
[root@localhost mysql-5.5.32]# yum -y install ncurses-devel ncurses #安装依赖 #开始安装
[root@localhost mysql-5.5.32]# cmake ./ #检查编译环境
[root@localhost mysql-5.5.32]# make #编译
[root@localhost mysql-5.5.32]# make install #安装 #初始化和配置数据库
[root@localhost mysql-5.5.32]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R mysql:mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql #初始化数据库
[root@localhost mysql]# chown -R mysql:mysql ./data/
[root@localhost mysql]# chmod -R ug+rws .
[root@localhost mysql]# chown -R mysql /var/run/mysqld #配置数据库
[root@localhost mysql]# cat /etc/my.cnf
##
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
user=mysql
datadir=/var/lib/mysql
default-storage-engine=MyISAM
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0 [mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
##
[root@localhost mysql]# bin/mysqld_safe --user=mysql & #启动数据库
[root@localhost mysql]# ls /var/lib/mysql/
ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test [root@localhost mysql]# bin/mysqladmin -uroot password 1123.com #修改root密码
[root@localhost mysql]# bin/mysql -uroot -p #访问数据库
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld #配置server启动脚本
[root@localhost mysql]# service mysqld start
Starting MySQL [确定]
#启动成功
Mysql基础命令
mysql> select user,host from mysql.user;
#查看用户 mysql> select user,host from mysql.user\G;
*************************** 1. row ***************************
user: root
host: 127.0.0.1
*************************** 2. row ***************************
user: root
host: ::1
*************************** 3. row ***************************
user:
host: localhost
*************************** 4. row ***************************
user: root
host: localhost
4 rows in set (0.00 sec)
#竖着显示 mysql> help drop
Many help items for your request exist.
To make a more specific request, please type 'help <item>',
where <item> is one of the following
topics:
ALTER TABLE
ALTER TABLESPACE
DEALLOCATE PREPARE
DROP DATABASE
DROP EVENT
DROP FUNCTION
DROP FUNCTION UDF
DROP INDEX
DROP LOGFILE GROUP
DROP PROCEDURE
DROP SERVER
DROP TABLE
DROP TABLESPACE
DROP TRIGGER
DROP USER
DROP VIEW
#寻求drop命令提示帮助 mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.06 sec) mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| root | localhost |
+------+-----------+
3 rows in set (0.00 sec)
#删除用户并且查看 #因为大写的'host'删不掉,所以我们可以用一下办法
mysql> delete from mysql.user where user='' and host='MASTER'; #删除来自mysql.user表中的user=''和host='MASTER'
Query OK, 0 rows affected (0.00 sec)
PHP安装
#安装依赖库
[root@localhost mysql]# yum -y install zlib libxml* libjpeg freetype libpng gd curl zlib-devel libxml2-devel libjpeg-devel freetype-devel gd-devel curl-devel openldap openldap-devel
[root@localhost php-5.6.33]# cp -frp /usr/lib64/libldap* /usr/lib/ #安装libiconv库
[root@localhost downloads]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[root@localhost downloads]# tar zxf libiconv-1.14.tar.gz
[root@localhost downloads]# cd libiconv-1.14
[root@localhost libiconv-1.14]# ./configure --prefix=/usr/local/libconv
[root@localhost libiconv-1.14]# make && make install #安装libmcrypt库
[root@localhost downloads]# wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download --no-check-certificate
[root@localhost downloads]# tar zxf libmcrypt-2.5.8.tar.gz
[root@localhost downloads]# cd libmcrypt-2.5.8
[root@localhost libmcrypt-2.5.8]# ./configure
[root@localhost libmcrypt-2.5.8]# make && make install
[root@localhost libmcrypt-2.5.8]# ldconfig
[root@localhost libmcrypt-2.5.8]# cd libltdl/
[root@localhost libltdl]# ./configure --enable-ltdl-install
[root@localhost libltdl]# make && make install
[root@localhost libltdl]# cd ../.. #安装mhash加密扩展库
[root@localhost downloads]# wget https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download --no-check-certificate
[root@localhost downloads]# tar zxf mhash-0.9.9.9.tar.gz
[root@localhost downloads]# cd mhash-0.9.9.9
[root@localhost mhash-0.9.9.9]# ./configure
[root@localhost mhash-0.9.9.9]# make && make install
[root@localhost mhash-0.9.9.9]# rm -rf /usr/lib/libmcrypt*
[root@localhost mhash-0.9.9.9]# rm -rf /usr/lib/libmhash*
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.la /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.a /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.la /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/bin/libmcrypt-config /usr/bin/
[root@localhost mhash-0.9.9.9]# cd .. #安装mcrypt加密扩展库
[root@localhost downloads]# wget https://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download --no-check-certificate
[root@localhost downloads]# tar zxf mcrypt-2.6.8.tar.gz
[root@localhost downloads]# cd mcrypt-2.6.8
[root@localhost mcrypt-2.6.8]# ldconfig
[root@localhost mcrypt-2.6.8]# ./configure
[root@localhost mcrypt-2.6.8]# make && make install
[root@localhost downloads]# cd .. #安装PHP
[root@localhost downloads]# wget http://cn2.php.net/get/php-5.6.33.tar.gz/from/this/mirror
[root@localhost downloads]# tar zxf php-5.6.33.tar.gz
[root@localhost downloads]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
[root@localhost downloads]# ldconfig -v
[root@localhost downloads]# cd php-5.6.33
[root@locahost php-5.6.33]# yum -y install libxslt libxslt-devel
[root@locahost php-5.6.33]# ./configure --prefix=/usr/local/php5.6.33 --with-mysql=/usr/local/mysql/ --with-iconv-dir=/usr/local/libconv/ --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/ --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp
[root@locahost php-5.6.33]# make && make install
配置PHP
[root@locahost php-5.6.33]# vimdiff php.ini-development php.ini-production
#查看不同 php.ini-development #开发版
php.ini-production #生产环境 #配置
[root@locahost php-5.6.33]# cp php.ini-production /usr/local/php5.6.33/etc/php.ini
[root@locahost php-5.6.33]# ln -s /usr/local/php5.6.33/etc/php.ini /etc/
[root@locahost php-5.6.33]# cd /usr/local/php5.6.33/
[root@locahost php5.6.33]# cp etc/php-fpm.conf.default etc/php-fpm.conf #配置php-fpm.conf
#;pid = run/php-fpm.pid
pid = pid = /var/run/php-fpm.pid
#;error_log = log/php-fpm.log
error_log = /var/log/php-fpm.log
#;log_level = notice
log_level = error
#;rlimit_files = 1024
rlimit_files = 32768 #文件描述符
#;listen.owner = nginx #监听的用户
listen.owner = nginx
#;listen.group = nginx #监听的组
listen.group = nginx
#pm.max_children = 5 #最大的进程数
pm.max_children = 1024
#pm.start_servers = 2
pm.start_servers = 16
#pm.min_spare_servers = 1 #最小空闲
pm.min_spare_servers = 5
#pm.max_spare_servers = 3 #最大空闲
pm.max_spare_servers = 20
#;pm.process_idle_timeout = 10s; #空闲超时
pm.process_idle_timeout = 10s;
#;pm.max_requests =500 #最大请求数
pm.max_requests = 2048
slowlog = log/$pool.log.slow
#;request_slowlog_timeout = 0
request_slowlog_timeout = 10 [root@locahost php5.6.33]# mkdir log
[root@locahost php5.6.33]# sbin/php-fpm -t
[root@locahost php5.6.33]# sbin/php-fpm
[root@locahost php5.6.33]# cp sbin/php-fpm /etc/init.d/ #修改etc/php.ini
找到:;date.timezone = 修改为:date.timezone = PRC #设置时区 找到:expose_php = On 修改为:expose_php = Off #禁止显示php版本的信息 找到:short_open_tag = Off 修改为:short_open_tag = ON #支持php短标签 找到opcache.enable=0 修改为opcache.enable=1 #php支持opcode缓存 找到:;opcache.enable_cli=1 #php支持opcode缓存 修改为:opcache.enable_cli=0 在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能
配置并优化nginx配置文件
#配置nginx.conf使其支持php
[root@locahost nginx]# pwd
/usr/local/nginx/ #nginx.conf
##############################################
user nginx nginx;
worker_processes 8; error_log /var/log/nginx/nginx_error.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 65535; events {
use epoll;
worker_connections 65535;
} http {
include mime.types;
default_type application/octet-stream;
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 60;
tcp_nodelay on; fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on; include extra/www.conf;
include extra/blog.conf;
}
############################################## [root@locahost nginx]# mkdir conf/extra/
[root@locahost nginx]# touch conf/extra/www.conf conf/extra/blog.conf
[root@locahost nginx]# mkdir /var/log/nginx/ #www.conf
##############################################
server {
listen 80;
server_name www.daniel.org;
index index.html index.php index.htm;
root /var/www/html/www/;
location ~.*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 365d;
}
location ~.*\.(js|css)?$ {
expires 365d;
}
access_log /var/log/nginx/www_access.log main;
error_log /var/log/nginx/www_error.log error;
}
############################################## #blog.conf
##############################################
server {
listen 80;
server_name blog.daniel.org;
index index.html index.php index.htm;
root /var/www/html/blog/;
location ~.*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 365d;
}
location ~.*\.(js|css)?$ {
expires 365d;
}
access_log /var/log/nginx/blog_access.log main;
error_log /var/log/nginx/blog_error.log error;
}
############################################## [root@locahost nginx]# mkdir /var/www/html/www /var/www/html/blog
#启动nginx
测试连接mysql和php
[root@locahost local]# cat /var/www/html/www/index.php
<?php
$link_id=mysql_connect('localhost','root','1123.com') or mysql_error();
if ($link_id) {
echo "mysql is ok!!";
}else{
echo mysql_error();
}
?>
提示:LNMP系列是在一起的,前三章看完后再删掉所有的东西
LNMP-day1-安装并配置的更多相关文章
- Lnmp的安装、配置
一.首先在本地安装好虚拟机,在虚拟机上安装centos6.5,由于习惯问题,不喜欢直接在虚拟机上操作linux系统,习惯了ssh过去,直接用xshell操作,这完全是个人习惯问题: 1. 用xshe ...
- CentOS安装与配置LNMP
本文PDF文档下载:http://www.coderblog.cn/doc/Install_and_config_LNMP_under_CentOS.pdf 本文EPUB文档下载:http://www ...
- CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境
CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境 什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/ ...
- lnmp 一键安装配置
l系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian/Deepin Server/Aliyun/Amazon/Mint Linux发行版 需要5GB以上硬盘 ...
- LNMP安装与配置之CentOS7的安装。
LNMP与LAMP是我们常见的两种网站服务器架构.LNMP代表的就是Linux系统下Nginx+MySQL+PHP/Python,LAMP代表的则是Linux系统下Apache+MySQL+PHP/P ...
- LNMP安装与配置之MySQL
MySQL 是最流行的关系型数据库管理系统之一,今天的安装是在CentOS7环境下进行安装,安装的版本是MySQL5.7,有需要别的版本可点击 官网. 一.安装 1.配置YUM源 # 下载mysql ...
- LNMP 搭建 wordpress 站点 安装及配置过程
0x00 环境 阿里云ECS云服务器 CPU:1核 内存:4G 操作系统:Centos 系统盘:100G 0x01 安装及配置 主要使用 nginx . php 和 mysql 注意:如果下面的设置不 ...
- LNMP编译安装教程
LNMP编译安装教程 此次安装在Centos上,我采用的CentOS的版本是:CentOS release 6.5 (Final) 可以通过以下命令查看:lsb_release -a 一.准备工作: ...
- 在Linux环境下安装和配置phpmyadmin
phpmyadmin是一种MySQL的图形化管理工具,该工具允许你在web界面上管理你的mysql数据库,不可谓不方便快捷. 此次安装与配置是在centos 6.4系统下,该系统已部署lnmp环境.关 ...
- PPTP + FreeRADIUS + MySQL 安装与配置
原文地址:http://www.zhukun.net/archives/5375 PPTP + FreeRADIUS + MySQL 安装与配置 2012/03/29Linux运维centos.Fre ...
随机推荐
- 深度学习(五)正则化之L1和L2
监督机器学习问题无非就是“minimizeyour error while regularizing your parameters”,也就是在规则化参数的同时最小化误差.最小化误差是为了让我们的模型 ...
- redis数据类型(四)list类型
一.list类型 list是一个链表结构,可以理解为一个每个子元素都是 string 类型的双向链表. 主要功能是push.pop.获取一个范围的所有值等. 操作中key理解为链表的名字. 二.Lis ...
- IOS多选单选相册图片
之前做项目让实现多选相册的图片,自己写了一个demo一直保存在电脑上,今天下午发现电脑128G的容量已经快没有了,准备清理电脑,所以把之前做的一些demo放在博客上,以后方便用. 1.首先准备3个图片 ...
- WCF宿主asp.netMVC 并且发布restfull接口数据
项目中需要同时用到WCF的SOAP接口和RESTFul Service,查了下资料发现WCF可以支持发布两种服务接口,整理资料如下 1.首先建立服务接口 备注:如果宿主不是网站,则接口上增加属性Web ...
- PHP项目学习——控件
主要是在项目学习中总结的一些东西 动态效果 flashbar滚动条,增加动态效果,直接嵌入html中 <!--flash滚动条--> <object classid="cl ...
- Redis---1、介绍
Redis简介: 是以key-value形式存储,和传统的关系型数据库不一样,不一定遵循传统数据库的一些基本要求. 优点: 对数据高并发读写 对海量数据的高效率存储和访问 对数据的可扩展性和高可用行 ...
- 计算细胞数【BFS】
问题描述 一矩形阵列由数字0到9组成,数字1到9代表细胞,细胞的定义为沿细胞数字上下左右还是细胞数字则为同一细胞,求给定矩形阵列的细胞个数. 输入格式 2行:第1行为两个整数 mm, nn, 代表矩阵 ...
- Hadoop学习笔记(9) ——源码初窥
Hadoop学习笔记(9) ——源码初窥 之前我们把Hadoop算是入了门,下载的源码,写了HelloWorld,简要分析了其编程要点,然后也编了个较复杂的示例.接下来其实就有两条路可走了,一条是继续 ...
- [javaSE] 进制转换(二进制十进制十六进制八进制)
十进制转二进制,除2运算 十进制6转二进制是 110 (注意从右往左写,使用算式从下往上写) 二进制转十进制,乘2过程 二进制110转十进制 0*2的0次方+1*2的1次方+1*2的2次方=6 对 ...
- 单源最短路(Dijkstra算法)
#返回上一级 @Author: 张海拔 @Update: 2015-03-11 @Link: http://www.cnblogs.com/zhanghaiba/p/3514570.html Dijk ...