LNMP
1、安装Nginx前的环境。
# yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl-devel
 
2、添加www系统用户,在单机实现LNMP的情况下需要使得php的用户与nginx的用户身份相同。
# groupadd -r www
# useradd -r -g www www
 
3、编译安装Nginx。
# tar axf nginx-1.10.1.tar.gz
# cd nginx-1.10.1
# ./configure --prefix=/usr/local --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
# make && make install
# vim /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
 
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
 
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
 
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
 
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
 
lockfile=/var/lock/subsys/nginx
 
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
 
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
 
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
 
restart() {
configtest || return $?
stop
sleep 1
start
}
 
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
 
force_reload() {
restart
}
 
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
 
rh_status() {
status $prog
}
 
rh_status_q() {
rh_status >/dev/null 2>&1
}
 
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
# chmod +x /etc/init.d/nginx
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/tmp/nginx/client" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
# mkdir /var/tmp/nginx
# nginx -t && service nginx start
 
4、编译安装mysql。
# yum -y remove mysql mysql-server
# rm -rf /etc/my.cnf
# yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ cmake make
# groupadd -r mysql
# useradd -r -g mysql -s /sbin/nologin mysql
# tar xvf mysql-5.6.22.tar.gz
# cd mysql-5.6.22
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
# make -j `grep 'processor' /proc/cpuinfo |wc -l`
# make install
# cd /usr/local/mysql
# chown -R mysql:mysql .
# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
# cp support-files/my-default.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
# service mysqld start
# echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
# source /etc/profile
 
5、准备php环境。
# yum -y install bzip2-devel libxml2-devel libcurl-devel freetype-devel libpng-devel libjpeg-devel mysql-devel
 
6、安装libmcrypt-2.5.8.tar.gz。
# tar axf libmcrypt-2.5.8.tar.gz
# ./configure
# make && make install
 
7、安装php。
# cp php-5.5.38.tar.xz /tmp
# xz -d php-5.5.38.tar.xz
# tar axf php-5.5.38.tar
# cd php-5.5.38
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-gd --with-libxml-dir=/usr/ --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl --with-fpm-user=www --with-fpm-group=www
此处的mysql如果为编译安装则需要指定当前编译安装的路径。
# make && make install
# cp php.ini-production /etc/php.ini
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chomd +x /etc/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# service php-fpm start
# ss -tunlp
此处查看9000端口如果已经处于监听状态,则php-fpm已启动。
 
8、配置nginx与php的通信。
# vim /etc/nginx/nginx.conf
location / {
root html;
index index.php index.html index.htm;
}
 
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
指定对于php的文件都发送到本地的9000端口使php进行处理。
# cat /usr/local/html/index.php
<?php
phpinfo();
?>
# service nginx restart
此时通过浏览器访问当前主机的页面即可显示php的相关信息。
 
9、为本地的mysql创建本地用户,使php与mysql建立联系。
# mysql
mysql> DROP USER ''@'localhost';
mysql> UPDATE mysql.user SET Password=PASSWORD('redhat') WHERE user='root';
mysql> FLUSH PRIVILEGES;
 
10、编辑index.php文件。
# vim /usr/local/html/index.php
<?php
$link = mysql_connect('127.0.0.1','root','redhat');
if ($link)
echo "Success...";
else
echo "Failure...";
 
mysql_close();
?>
编辑完成后通过浏览器查看即可。
 
 
 
QQ农场
#pwd
/tmp
#unzip farm-ucenter1.5.zip
#mysql -uroot -predhat
create database farm;
#mysql -uroot -predhat farm <qqfarm.sql
#cd /usr/local
#mv html html.bak
#mkdir html
#cd /tmp/upload
#mv * /usr/local/html
#chmod 777 -R /usr/local/html
#vim /etc/php.ini
:/short
short_open_tag = Off ==>On
#/etc/init.d/php-fpm restart
 
 
 
DNS解析
#yum -y install bind*
#vim /etc/named.conf
listen port 53 { any;}; 修改此行的127.0.0.1为any
allow-query { any;}; 修改此行的localhost为any
zone "ak.com" IN { type master; file "ak.com.zone"; };
#cd /var/named
#cp -p named.localhost ak.com.zone
#chkconfig named on
#cd /var/named
#vim ak.com.zone
$TTL 1D
@ IN SOA master.ak.com root.ak.com. (
2016081101 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS master.ak.com
master.ak.com IN A 192.168.11.6
 
ns1 IN A 192.168.11.6
www IN A 192.168.11.6
 
#/etc/init.d/named restart
#nslookup
server
server 192.168.11.6

LNMP+FARM+DNS的更多相关文章

  1. 安装lnmp一键安装包(转)

    系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP,OpenVZ的另外 ...

  2. 关于轻松安装LNMP和LAMP的编译环境

    http://lnmp.org/install.html 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要2GB以上硬盘剩余空间 1 ...

  3. VPS及LNMP(一)

    1.试用了搬瓦工.interserver.天翼云.网安互联之后,分别写下感受: 前两个是美国服务器,天翼云是国内服务器,网安互联是香港主机. a.搬瓦工非常便宜,512M的1年9.99刀,但是用了之后 ...

  4. 深度优化LNMP

    优化前准备工作 Centos准备及配置 准备安装包及软件:http://pan.baidu.com/s/1chHQF  下载解压到U盘即可安装http://pan.baidu.com/s/15TUWf ...

  5. CentOS 6 lnmp环境脚本

    实验环境:CentOS 6.3 32位 首先我们先去下载nginx的第三方yum源 mkdir /shell cd /shell wget http://www.atomicorp.com/insta ...

  6. 深度优化LNMP之Nginx [2]

    深度优化LNMP之Nginx [2]   配置Nginx gzip 压缩实现性能优化 1.Nginx gzip压缩功能介绍        Nginx gzuo压缩模块提供了压缩文件内容的功能,用户请求 ...

  7. LNMP安装与配置

    Nginx与apache.lighttp性能综合对比,如下图:                           注意:关闭rpm默认安装的apache和mysql 1.准备php函数的rpm包 y ...

  8. CentOS编译安装LNMP环境

    这里是教大家如何在centos下利用源码编译安装LNMP环境. 工具/原料 centos服务器一台 自用电脑一台 准备篇 配置好IP.DNS .网关,确保使用远程连接工具能够连接服务器 配置防火墙,开 ...

  9. CentOS 7 for ARM 安装一键Lnmp失败

    背景 前面把树莓派装上了CentOS 7,趁着国庆放假回来赶紧把服务端环境搭起来,为了方便就准备用一键lnmp快速部署一个,结果死活安装不成功... 报错 按照以往的经验进行安装,在我的小树莓派上安装 ...

随机推荐

  1. POJ - 3279 枚举 [kuangbin带你飞]专题一

    这题很经典啊,以前也遇到过类似的题--计蒜客 硬币翻转. 不过这题不仅要求翻转次数最少,且翻转方案的字典序也要最小. 解法:二进制枚举第一行的翻转方案,然后处理第二行,如果第二行的k列的上一列是黑色, ...

  2. java网络编程(3)——UDP

    UDP在java中主要使用DatagramSocket来实现通讯,数据一般是通过DatagramPacket来封装: 发送方只需指定接受方的地址和端口,然后通过send()方法就可以把封装在Datag ...

  3. (转载,但不知道谁原创)获取SPRING 代理对象的真实实例,可以反射私有方法,便于测试

    /** * 获取 目标对象 * @param proxy 代理对象 * @return * @throws Exception */ public static Object getTarget(Ob ...

  4. Django使用模板后无法找到静态资源文件

    Django使用模板后无法找到静态资源文件 环境配置 Django版本1.11 python版本3.6.2 前言 在编写Django网站的时候,在涉及模板方面,一些简单的例子都没有问题,但这些例子都有 ...

  5. GOF 23种设计模式

    设计模式目录 创建型 1. Factory Method(工厂方法) 2. Abstract Factory(抽象工厂) 3. Builder(建造者) 4. Prototype(原型) 5. Sin ...

  6. Android内核解读-应用的安装过程

    前言 我们知道,在android手机上安装一个apk很简单,只要打开apk文件,默认就会弹出安装界面,然后点击确定,经过若干秒后,apk就安装成功了,可是你知道apk的安装过程是什么吗?你知道andr ...

  7. Java中private、protected和public作用域的异同

    Java中private.protected和public作用域的异同 说明:(1)private的作用范围为当前类,protected的作用范围哦不能超过其他包: (2)区别不同的作用域的不同作用范 ...

  8. 图像处理------透明混合 - Alpha Blending效果

    基本原理: 图像的透明混合有个专属名词– Alpha Blending 对任意两张图像可以合成为一张图像,合成图像的像素取值根据数学公式: RGB3 = (1- a) * RGB1 + a * RGB ...

  9. Linux显示登入系统的帐号名称和总人数

    Linux显示登入系统的帐号名称和总人数 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ who -q youhaidong youhaidong # 用户数= ...

  10. 完美的js运动框架

    //完美运动框架, 对象,json,函数function move(obj,json,funEnd){clearInterval(obj.timer);//清除定时器obj.timer= setInt ...