redhat nginx php mysql,[LNMP]RHEL 6.0+Nginx 1.0.2+MySQL 5.5.12+PHP 5.3.6

架设lamp服务器可以使用rpm包和编译两种方法:

A>rpm包比较简单

#yum -y install MySQL-server mysql-devel httpd httpd-devel php php-devel php-mysql

#/etc/init.d/mysql start

#/etc/init.d/httpd start

#chkconfig mysql on

#chkconfig httpd on

B>编译安装复杂一点,但是能更清晰的了解底层的结构,下边看一下编译安装的方法!

编译安装顺序

1,lamp linux-mysql-apache-php

2, lnmp linux-mysql-php-nginx

1> 编译安装mysql-5.5.12

#yum -y install cmake gcc gcc-c++ ncurses-devel bison openssl-devel zlib-devel

常用的选项有下边这些:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

#安装目录

-DMYSQL_DATADIR=/usr/local/mysql/data \

#数据库存放目录

-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \

#Unix socket 文件路径

-DWITH_MYISAM_STORAGE_ENGINE=1 \

#安装 myisam 存储引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

#安装 innodb 存储引擎

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

#安装 archive 存储引擎

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

#安装 blackhole 存储引擎

-DWITH_PARTITION_STORAGE_ENGINE=1 \

#安装数据库分区

-DENABLED_LOCAL_INFILE=1 \

#允许从本地导入数据

-DWITH_READLINE=1 \

#快捷键功能

-DWITH_SSL=yes \

#支持 SSL

-DDEFAULT_CHARSET=utf8 \

#使用 utf8 字符

-DDEFAULT_COLLATION=utf8_general_ci \

#校验字符

-DEXTRA_CHARSETS=all \

#安装所有扩展字符集

-DMYSQL_TCP_PORT=3306 \

#MySQL 监听端口# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306#make && make installps:

重新编译时需要

#make clean

#rm -f CMakeCache.txt

# useradd -M -s /sbin/nologin mysql

# chown -R mysql.mysql /usr/local/mysql/

# cd /usr/local/mysql/

#cp support-files/my-medium.cnf  /etc/my.cnf

# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data出现这个错误latin1_swedish_ci' is not valid for CHARACTER SET 'utf8' 原因是因为编译的时候没有加DDEFAULT_COLLATION=utf8_general_ci 选项# chown -R root .

# chown -R mysql data/

# cp support-files/mysql.server /etc/init.d/mysqld

# ll /etc/init.d/mysqld   //查看是否具有x权限

-rwxr-xr-x. 1 root root 10650 Sep 21 15:41 /etc/init.d/mysqld

# chkconfig mysqld on

# /etc/init.d/mysqld start

Starting MySQL..... SUCCESS!

# echo "export PATH=\$PATH:/usr/local/mysql/bin" >> ~/.bash_profile

# source ~/.bash_profile

# mysql_secure_installation  //可以直接开始mysql的初始化了,到这里mysql的编译就基本上完成了

2>编译安装php-5.3.6

# tar xf libmcrypt-2.5.8.tar.bz2

# cd libmcrypt-2.5.8

# ./configure -libdir=/usr/local/lib64

# make && make install

# cd libltdl/

# ./configure -libdir=/usr/local/lib64/ -enable-ltdl-install && make && make install

# yum -y install net-snmp-devel curl-devel libxml2-devel libpng-devel libjpeg-devel freetype-devel gmp-devel

# useradd -M -s /sbin/nologin www

#tar xf php-5.3.6.tar.bz2

# cd php-5.3.6

#ln -s /usr/local/mysql/lib /usr/local/mysql/lib64 //不然 php 编译的时候找不到 mysql 的库文件# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --with-mcrypt --enable-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-libdir=lib64#make && make install# cp php.ini-production /usr/local/php/etc/php.ini

# cp /mnt/php-5.3.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# vi /usr/local/php/etc/php.ini

cgi.fix_pathinfo=0            //842行

#cd /usr/local/php/etc

# cp php-fpm.conf.default php-fpm.conf

pid = run/php-fpm.pid

pm.max_children = 50

pm.start_servers = 10

pm.min_spare_servers = 5

pm.max_spare_servers = 15

pm.max_requests = 500

# /etc/init.d/php-fpm start  //启动服务

# chkconfig php-fpm on

到这里php就已经完成了!

3> 编译安装nginx-1.0.2

# yum install -y pcre-devel

#tar -xf nginx-1.0.2.tar.gz

#vim auto/cc/gcc

#CFLAGS="$CFLAGS -g"  将175行注释掉去掉debug模式

#vim src/core/nginx.h#define NGINX_VERSION "1.0.2”

#define NGINX_VER "nginx"(修改此行,去掉后面的“NGINX_VERSION”,为了安全,这样编译后外界无法获取程序的版本号)

#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

#make && make install# ln -s /usr/local/nginx/sbin/nginx /usr/sbin

# vim /usr/local/nginx/conf/nginx.conf   //这里是我的配置文件里边的有效信息

user www www;

worker_processes  8;

events {

use epoll;

worker_connections  65535;

}

http {

include       mime.types;

default_type  application/octet-stream;

sendfile        on;

tcp_nopush     on;

keepalive_timeout  65;

server {

listen       80;

server_name  localhost;

location / {

root   html;

index  index.html index.htmi index.php;

}

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

location ~ \.php$ {

root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

include        fastcgi.conf;

}

location /status{

stub_status on;

access_log off;

}

location /phpmyadmin {

root html;

index index.php;

}                                     //这里的几行只是为了发布一个phpmyadmin ,方便管理

}

}

#tar xf phpMyAdmin-3.4.2-all-languages.tar.bz2 -C /usr/loca/nginx/html

#mv phpMyAdmin-3.4.2-all-languages phpmyadmin

# nginx -t   //检测配置文件

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax isoknginx: configuration file /usr/local/nginx/conf/nginx.conf test issuccessful# nginx  //启动服务

我们可以在/usr/local/nginx/html 下新建一个 index.php,内容如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值