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-安装并配置的更多相关文章

  1. Lnmp的安装、配置

    一.首先在本地安装好虚拟机,在虚拟机上安装centos6.5,由于习惯问题,不喜欢直接在虚拟机上操作linux系统,习惯了ssh过去,直接用xshell操作,这完全是个人习惯问题: 1.  用xshe ...

  2. CentOS安装与配置LNMP

    本文PDF文档下载:http://www.coderblog.cn/doc/Install_and_config_LNMP_under_CentOS.pdf 本文EPUB文档下载:http://www ...

  3. CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境

    CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境 什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/ ...

  4. lnmp 一键安装配置

    l系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian/Deepin Server/Aliyun/Amazon/Mint Linux发行版 需要5GB以上硬盘 ...

  5. LNMP安装与配置之CentOS7的安装。

    LNMP与LAMP是我们常见的两种网站服务器架构.LNMP代表的就是Linux系统下Nginx+MySQL+PHP/Python,LAMP代表的则是Linux系统下Apache+MySQL+PHP/P ...

  6. LNMP安装与配置之MySQL

    MySQL 是最流行的关系型数据库管理系统之一,今天的安装是在CentOS7环境下进行安装,安装的版本是MySQL5.7,有需要别的版本可点击  官网. 一.安装 1.配置YUM源 # 下载mysql ...

  7. LNMP 搭建 wordpress 站点 安装及配置过程

    0x00 环境 阿里云ECS云服务器 CPU:1核 内存:4G 操作系统:Centos 系统盘:100G 0x01 安装及配置 主要使用 nginx . php 和 mysql 注意:如果下面的设置不 ...

  8. LNMP编译安装教程

    LNMP编译安装教程 此次安装在Centos上,我采用的CentOS的版本是:CentOS release 6.5 (Final) 可以通过以下命令查看:lsb_release -a 一.准备工作: ...

  9. 在Linux环境下安装和配置phpmyadmin

    phpmyadmin是一种MySQL的图形化管理工具,该工具允许你在web界面上管理你的mysql数据库,不可谓不方便快捷. 此次安装与配置是在centos 6.4系统下,该系统已部署lnmp环境.关 ...

  10. PPTP + FreeRADIUS + MySQL 安装与配置

    原文地址:http://www.zhukun.net/archives/5375 PPTP + FreeRADIUS + MySQL 安装与配置 2012/03/29Linux运维centos.Fre ...

随机推荐

  1. ubuntu关闭时间同步与centos更改时间

    环境:ubuntu 源于一次项目需要修改系统时间,但是每次修改后又被同步回网络时间,找了好久发现是这个原因: NTP即Network Time Protocol(网络时间协议),是一个互联网协议,用于 ...

  2. C#自定义处理事件(作者还没完全理解事件和委托,所以有可能错漏百出)

    1.C#的处理事件整个框架,其实就是观察者模式的一种应用 观察者模式:老师监视学生考试,学生若作弊,老师立即打人 2.涉及的元素: 所以必须涉及两个对象,事件引发者(触发)--学生:事件处理者--老师 ...

  3. Nginx 的信号控制

    摘自:Nginx服务器初识:Nginx启动.停止与信号控制 名称 功能 说明 HUP 重启   QUIT 从容关闭   TERM 快速关闭   INT 从容关闭   USR1 切换日志文件 通常用在切 ...

  4. git 切换 远程仓库

    $ git remote rm origin $ git remote add origin '仓库地址.git' $ git branch --set-upstream-to=origin/mast ...

  5. IOS折线图

    做项目要统计商品的销售情况,美工那边给了效果图,自己就按照效果图自定义了一个ScrollView.整体效果不错,在做的过程中遇到的问题也记录一下. 现在这个还有许多优化的地方: 1.一个表中只能画一个 ...

  6. iOS开源项目周报0209

    由OpenDigg 出品的iOS开源项目周报第七期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等.Hedwig 向 ...

  7. Spring扩展:Spring框架的由来

    一.Spring框架的由来

  8. java.sql.SQLException: Io 异常: Invalid number format for port number

    java.sql.SQLException: Io 异常: Invalid number format for port number   jdbc数据库链接配置没有写端口号 ​ 要检查jdbc的配置 ...

  9. 通用CSS命名规范

    一.文件命名规范 样式文件命名主要的 master.css布局,版面 layout.css专栏 columns.css文字 font.css打印样式 print.css主题 themes.css [/ ...

  10. svg矢量图标在html中的使用, (知识点:1.通过h5中的css实现点击变色,2.一个svg文件包含多个图标)

    svg矢量文件体积小,不变形,比传统的png先进,比现在流行的icon-font灵活.然而在使用过程中还是遇到了很多坑.今天花了一天时间把经验整理出来,以供后来者借鉴.如果您从本文收益,请留言mark ...