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 ...
随机推荐
- PHP之string之str_repeat()函数使用
str_repeat (PHP 4, PHP 5, PHP 7) str_repeat - Repeat a string str_repeat - 重复一个字符串 Description strin ...
- TCP/IP的基本概念知识
1.分层 TCP/IP通常是被分成四层协议系统的,应用层(Telnet.FTP和Email等).运输层(TCP.UDP).网络层(IP.ICMP.IGMP等)和链路层(设备驱动程序),每一层各 ...
- ASP.NET MVC* 采用Unity依赖注入Controller
Unity是微软Patterns & Practices团队所开发的一个轻量级的,并且可扩展的依赖注入(Dependency Injection)容器,它支持常用的三种依赖注入方式:构造器注入 ...
- developer.android.google.cn
Android Studio官方 Android IDE https://developer.android.google.cn/studio/index.html 探索 Android Studio ...
- IoC容器之Unity
关于IoC.Unity见博友文章点击这里. 话不多说,上程序HelloUnity,程序采用VS2010,Unity2.1. 1.程序框架如下 2.类库HelloUnity.Objects,主要为实体类 ...
- 图标插件FusionChartsFree
二.介绍 Ø FusionCharts 是InfoSoft Global 公司的一个产品,InfoSoft Global 公司是专业的Flash 图形方案提供商,他们还有几款其他的,基于Flash 技 ...
- GIT 基础-基础命令
环境 centos7 1.安装 #yum install git 2.创建本地仓库 ( 这里用 /www/git) 这里里有个隐藏的文件夹 ```.git``` 为git仓库的配置文件夹, 不可随意修 ...
- java中程序上线报错: tomcat中java.lang.OutOfMemoryError: PermGen space
在程序测试没问题之后,上线试运行,在运行的过程中某个功能一点击就报如下错,然后重启服务器就好了,一会又是如此,解决方法如下(亲测) PermGen space的全称是Permanent Generat ...
- vi 编辑器使用中常见的命令
原创作品,转载请在文章头部(显眼位置)注明出处:https://www.cnblogs.com/sunshine5683/p/10014724.html 要在linux学习的路上越走越远,总结是必不可 ...
- JavaScript-原型&原型链&原型继承&组合函数
小小的芝麻之旅: 今天学习了js的原型,要说原型,我们先简单说一下函数创建过程. 原型 每个函数在创建的时候js都自动添加了prototype属性,这就是函数的原型,原型就是函数的一个属性,类似一个指 ...