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 ...
随机推荐
- 配置Linux本地源镜像
今天看到同事做了一个公司本地的apache镜像源,感觉好叼的样子.然后就自己上网找些资料,尝试自己搭建一套出来.然后就有了这篇博文... 声明:本文中充满了浓浓的技术嫉妒的心理,阅读需谨慎. 本文以 ...
- apollo应用配置集成及使用
apollo应用配置集成及使用 1. 开发环境Apollo地址 用户名:apollo 密码:admin 开发环境Apollo管理台地址:http://localhost:8070/ ...
- RabbitMQ的安装和配置化可视界面
RabbitMQ在windows下的安装 RabbitMQ 它依赖于Erlang,在window上安装时,需要先安装Erlang. 首先确定你的window电脑是32位还是64位,然后下载对应版本的E ...
- WPF使用Path画圆的一个示例代码
<Path Fill="red" Data="M 0,0 A 20,20 45 1 1 0,1 Z"/> 1. Fill是指Path的填充颜色 2. ...
- Veloce2 Emulator
High capacity, high-speed, multi-application powerhouse for simulation and emulation of SoC designs ...
- <机器学习实战>读书笔记--朴素贝叶斯
1.朴素贝叶斯法是基于贝叶斯定理与特征条件独立假设的分类方法, 最为广泛的两种分类模型是决策树模型(Decision Tree Model)和朴素贝叶斯模型(Naive Bayesian Model, ...
- [转]使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【八】——Web Api的安全性
本文转自:http://www.cnblogs.com/fzrain/p/3552423.html 系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html ...
- 撩课-Java每天10道面试题第6天
51.HashMap的实现原理 HashMap的主干是一个Entry数组. Entry是HashMap的基本组成单元, 每一个Entry包含一个key-value键值对. HashMap基于hashi ...
- 常见IT英语短语一
SSO (Single sign-on)单点登陆. aspect-oriented programming,AOP面向切面. CORS:Cross-origin resource sharing跨域资 ...
- 【SSH网上商城项目实战17】购物车基本功能的实现
转自:https://blog.csdn.net/eson_15/article/details/51418350 上一节我们将商品的详细页面做完了,并使用了Hibernate的二级缓存加载详细页面来 ...