LNMP环境编译安装

安装nginx

[[email protected] src]# tar -xf nginx-1.6.2.tar.gz

[[email protected] src]# ls

nginx-1.6.2  nginx-1.6.2.tar.gz

[[email protected] nginx-1.6.2]#

[[email protected] nginx-1.6.2]# useradd -s /sbin/nologin -M nginx

[[email protected] nginx-1.6.2]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx1.6.2 --with-http_stub_status_module --with-http_ssl_module

Make&&make install

[[email protected] local]# ln -s /usr/local/nginx1.6.2/ /usr/local/nginx

[[email protected] local]# ll nginx/

total 16

drwxr-xr-x 2 root root 4096 Dec  8 15:56 conf

drwxr-xr-x 2 root root 4096 Dec  8 15:56 html

drwxr-xr-x 2 root root 4096 Dec  8 15:56 logs

drwxr-xr-x 2 root root 4096 Dec  8 15:56 sbin

重启nginx

[[email protected] local]# ./nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx1.6.2/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx1.6.2/conf/nginx.conf test is successful

[[email protected] local]# ./nginx/sbin/nginx   启动nginx

[[email protected] local]# lsof -i :80

COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

nginx   4584  root    6u  IPv4  15901      0t0  TCP *:http (LISTEN)

nginx   4585 nginx    6u  IPv4  15901      0t0  TCP *:http (LISTEN)

访问测试

配置nginx

[[email protected] conf]# grep html nginx.conf

root   html;  默认站点

[[email protected] conf]# ll

total 60

-rw-r--r-- 1 root root 1034 Dec  8 15:56 fastcgi.conf  动态位置文件

-rw-r--r-- 1 root root 1034 Dec  8 15:56 fastcgi.conf.default

-rw-r--r-- 1 root root  964 Dec  8 15:56 fastcgi_params

-rw-r--r-- 1 root root  964 Dec  8 15:56 fastcgi_params.default

-rw-r--r-- 1 root root 2837 Dec  8 15:56 koi-utf

-rw-r--r-- 1 root root 2223 Dec  8 15:56 koi-win

-rw-r--r-- 1 root root 3957 Dec  8 15:56 mime.types

-rw-r--r-- 1 root root 3957 Dec  8 15:56 mime.types.default

-rw-r--r-- 1 root root 2656 Dec  8 15:56 nginx.conf   静态配置文件

-rw-r--r-- 1 root root 2656 Dec  8 15:56 nginx.conf.default

配置虚拟主机

[[email protected] conf]# mkdir ../html/{www,blog,bbs}

[[email protected] conf]# for i in www blog bbs;do echo "http://$i.bier.org" >../html/$i/index.html;done

[[email protected] conf]# for i in www blog bbs;do cat ../html/$i/index.html;done

http://www.bier.org

http://blog.bier.org

http://bbs.bier.org

打开配置文件

http {

include       mime.types;

default_type  application/octet-stream;

sendfile        on;

keepalive_timeout  65;

server {

listen       80;

server_name  www.bier.org;

root   html/www;

index  index.html index.htm;

}

server {

listen       80;

server_name  blog.bier.org;

root   html/blog;

index  index.html index.htm;

index  index.html index.htm;

}

server {

listen       80;

server_name  bbs.bier.org;

root   html/bbs;

index  index.html index.htm;

}

}

[[email protected] nginx]# ./sbin/nginx -t

nginx: the configuration file /usr/local/nginx1.6.2/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx1.6.2/conf/nginx.conf test is successful

[[email protected] nginx]# ./sbin/nginx -s reload   加载配置文件

配置好hosts,浏览器测试访问

安装mysql

安装mysql(二进制包安装方式,直接解压,初始化数据库即可,无需编译)

[[email protected] local]# useradd mysql -s /sbin/nologin –M

[[email protected] local]#tar -xf mysql-5.5.32-linux2.6-x86_64.tar.gz

[[email protected] local]#mv mysql-5.5.32-linux2.6-x86_64 mysql

[[email protected] local]# chown -R mysql.mysql ./mysql/data

拷贝启动脚本

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql]# vi /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

[[email protected] mysql]# chkconfig --add mysqld

[[email protected] mysql]# chkconfig --list |grep mysqld

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

[[email protected] mysql]# chkconfig mysqld on

拷贝配置文件

[[email protected] mysql]# cp support-files/my-small.cnf /etc/my.cnf

初始化数据库

[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

when specifying MySQL privileges !

Installing MySQL system tables...

OK

Filling help tables...

OK

You can start the MySQL daemon with:

cd /usr/local/mysql/ ; /usr/local/mysql//bin/mysqld_safe &

启动mysql

[[email protected] mysql]# /etc/init.d/mysqld start

Starting MySQL.... SUCCESS!

[[email protected] mysql]# lsof -i :3306

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

mysqld  35035 mysql   10u  IPv4  48207      0t0  TCP *:mysql (LISTEN)

连接数据库

[[email protected] mysql]# which mysql

/usr/bin/which: no mysql in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

[[email protected] mysql]# find /usr/local/ -type f -name "mysql"

/usr/local/mysql/bin/mysql

[[email protected] mysql]# cp /usr/local/mysql/bin/mysql /usr/local/sbin/

[[email protected] mysql]# mysql     输入mysql登录数据库

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

安装php

Lnmp下的php

Apache==>libphp5.so

Nginx php ===> fcgi  php-fpm   port 9000

安装准备

yum install zlib libxml libjpeg freetype libpng gd  curl libiconv  zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y

字符集

tar zxf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local/libiconv

make

make install

加密的库

tar -xf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make

make install

sleep 2

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make

make install

tar -xf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9

./configure

make

make install

加密扩展库

tar -xf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

/sbin/ldconfig

./configure LD_LIBRARY_PATH=/usr/local/lib

make

make install

再安装一个包,不然编译的时候会出错

yum install libxslt* -y

开始安装php

tar -xf php-5.3.27.tar.gz

cd php-5.3.27

./configure \

--prefix=/usr/local/php5.3.27 \

--with-mysql=/usr/local/mysql \

--with-libxml-dir=/usr \

--with-zlib \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-iconv-dir=/usr/local/libiconv \

--enable-xml \

--with-curl \

--with-curlwrappers \

--disable-rpath \

--enable-safe-mode \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--enable-short-tags \

--enable-zend-multibyte \

--enable-static \

--with-xsl \

--with-fpm-user=nginx \

--with-fpm-group=nginx \

--enable-ftp

要这样子处理,不然会报错

ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

make

make install

ln -s /usr/local/php5.3.27/ /usr/local/php

拷贝php的配置文件

[[email protected] php-5.3.27]# pwd

/usr/local/src/php-5.3.27

[[email protected] php-5.3.27]# ls -l php.ini-*

-rw-r--r-- 1 101 101 69606 Jul 10  2013 php.ini-development

-rw-r--r-- 1 101 101 69627 Jul 10  2013 php.ini-production

[[email protected] php-5.3.27]# cp /usr/local/src/php-5.3.27/php.ini-production /usr/local/php/lib/php.ini

php的配置文件php.ini

启动模式是fcgi的模式

[[email protected] etc]# pwd

/usr/local/php/etc

[[email protected] etc]# ll

total 28

-rw-r--r-- 1 root root  1212 Dec  8 21:34 pear.conf

-rw-r--r-- 1 root root 21669 Dec  8 21:34 php-fpm.conf.default

[[email protected] etc]# mv php-fpm.conf.default php-fpm.conf

改一下他默认的配置文件,然后启动,

把php-fpm.conf.default 变成php-fpm.conf

[[email protected] etc]# mkdir /app/logs –p

检测重启

[[email protected] php]# ./sbin/php-fpm -t

[08-Dec-2015 21:57:55] NOTICE: configuration file /usr/local/php5.3.27/etc/php-fpm.conf test is successful

[[email protected] php]# netstat -lnptu |grep php-fpm

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      30227/php-fpm

配置php整合nginx

从nginx.conf.default复制配置粘贴到下面更改

[[email protected] extra]# vim bbs.conf

server {

listen       80;

server_name  bbs.bier.org;

root   html/bbs;

index  index.html index.htm;

location ~ .*\.(php|php5)?$

{

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

include fastcgi.conf;

}

}

检测

[[email protected] nginx]# ../php/sbin/php-fpm -t

[08-Dec-2015 22:14:15] NOTICE: configuration file /usr/local/php5.3.27/etc/php-fpm.conf test is successful

加载nginx配置文件

[[email protected] nginx]# ./sbin/nginx -s reload

[[email protected] bbs]# pwd

/usr/local/nginx/html/bbs

[[email protected] bbs]# cat info.php

<?php

phpinfo();

?>

访问测试

http://bbs.bier.org/info.php

PHP测试连接mysql

[[email protected] bbs]# vi mysql.php

<?php

$link_id=mysql_connect(‘localhost‘,‘root‘,‘bier123‘) or mysql_error();

if($link_id){

echo "mysql successful by bier !";

}else{

echo mysql_error();

}

?>

浏览器访问测试 (不需要重启服务)

或者这样子测试

[[email protected] bbs]# /usr/local/php/bin/php mysql.php

mysql successful by bier !

到此lnmp安装完成。

时间: 2024-12-28 23:38:58

LNMP环境编译安装的相关文章

CentOS 6.4 LNMP 环境编译安装

1.关闭 SELinux 编辑 /etc/selinux/config SELINUX="disabled" 2.安装编译器 yum install gcc gcc-c++ -y 3.安装 PHP 组件 yum install perl install libxml2 libxml2-devel libmcrypt zlib autoconf curl-devel libXpm-devel 4. 安装 Mysql 下载地址:http://dev.mysql.com/downloads/

centos 7 lnmp环境编译安装zabbix-3.4.14

一.安装环境(zabbix3.0需要php在5.5版本以上) [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [[email protected] ~]# netstat -lntup|egrep 'nginx|mysql' tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1268/nginx: master tcp 0 0 0.0.0.0:443 0.

基于CentOS6.5环境之下的LNMP之编译安装Nginx1.8.0 stable(稳定版)

LNMP之编译安装Nginx1.8.0 stable(稳定版) 1.yum安装nginx所欲要的生存环境,也就是库文件 yum -y install make gcc gcc-c++ glibc glibc-devel automake autoconf libtool make 2.给nginx添加系统用户 useradd -s /sbin/nologin -M -r nginx 3.解压安装nginx1.8.0 tar xf nginx-1.8.0.tar.gz  cd nginx-1.8.

基于CentOS6.5环境之下的LNMP之编译安装PHP5.5.30

LNMP之编译安装PHP5.5.30 1.编译前操作: 1.1.netstat -tulnp | egrep "80|3306" tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      25392/nginx          tcp        0      0 :::3306                     :::*                   

LNMP环境下安装zabbix3.2.11

LNMP环境下安装zabbix3.2.11安装环境:centos6.5zabbix_server:192.168.100.3zabbix_agent:192.168.100.4 1.安装前准备工作1.确保服务器可以连接外网或者能下载相应的软件包即可.nginx安装官网下载地址: http://nginx.orgphp安装官网下载地址: http://php.netmysql安装官网下载地址:https://dev.mysql.com/downloads/mysql/zabbix安装官网下载地址:

LAMP环境编译安装(详细)

linux下Apache.mysql.php.phpMyadmin源码包编译安装及配置 事先可以先去各应用官网选择相应的源码包下载并上传到linux服务器上.源码包目录根据喜好或一个标准放置即可. 注:此文档仅适用于自己学习及测试使用,后续还将继续完善及解读文档中的不足. 在此之前先关闭selinux(Secrity-EnhancedLinux,安全增强式Linux),不然会由于selinux的安全机制影响到一些配置文件的加载及更改. 临时关闭(不用重启机器): setenforce 0 1.安

Linux lamp环境编译安装

1.安装准备: 1)httpd-2.0.52.tar.gz 2)mysql-4.1.12.tar.gz 3)libxml2-2.6.27.tar 4)freetype-2.1.10.tar 5)gd-2.0.33.tar 6)jpegsrc.v6b.tar 7)libpng-1.2.16.tar 8)zlib-1.2.3.tar 9)freetds-0.64.tar.gz 10)php-4.3.9.tar.gz 11)phpMyAdmin292.tar.gz 12)ZendOptimizer-3

LNMP环境的安装

lnmp环境的安装 1.对静态网页的支持比较好 2.配置简单 3.性能,比apache高3倍以上 4.支持更大的并发连接数 安装前准备 关闭防火墙chkconfig iptables off 关闭selinux chkconfig selinux off 1.安装pcre(支持正则表达式) 直接使用yum安装 yum -y install pcre-devel-7.8-6.el6.i686.rpm 如图所示表示安装成功 2.安装zlib支持压缩 yum -y install zlib-devel

python3的linux环境编译安装

python3的linux环境编译安装 1.linux下安装软件的方式 选则yum工具,方便,自行解决软件之间的依赖关系,自动下载且安装 1.配置yum源 可以选择阿里云源,清华源等 配置第一个仓库,里面有大量系统常用软件 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 配置第二个仓库,携带大量第三方软件(nginx,redis,mongodb,mairadb等) wge