nginx+php+mysql的安装

一、nginx的安装
1、在http://nginx.org/en/download.html下载响应的安装包
2、解压 tar -zxvf nginx-1.5.9.tar.gz
3、设置一下配置信息 ./configure --prefix=/usr/local/nginx ,或者不执行此步,直接默认配置
4、make 编译 (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)
make install 安装 (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)
5、在配置信息的时候,也就是在第三步,出现了一下错误:
错误为:./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
还有可能出现:
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决办法:

yum -y install openssl openssl-devel

二、安装php
1、版本需要5.3.X版本。
wget http://125.39.35.135/files/41540000062C39C6/gw.ali-vpc01.chinawayltd.com/moss/packages/php-5.3.29.tar.gz
2、确保安装之前有安装gd,png,curl,xml等等lib开发库。如果不确定,执行以下命令:
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
3、以下参数支持,ftp,图片函数,pdo等支持,因为使用了php自带的mysqlnd,所以不需要额外安装mysql的lib库了.如果你是64位系统,参数后面加上–with-libdir=lib64,如果不是可以跳过。
tar -xjf php-5.3.29.tar.bz2
cd php-5.3.29
./configure --prefix=/usr/local/php-5.3.29 --with-config-file-path=/usr/local/php-5.3.29/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64
make
make install


备注:如果PHP不需要curl和ftp的支持,可以将以上的–with-curl –enable-ftp去掉. 如果你是专业的linux从业人员,你完全可以看着help来选择你的安装参数,如果你不是的话,我建议你直接复制黏贴我的配置参数.这样可以少走一些弯路.
4、已经安装完成了php,下面我们针对php,配置php 
cp php.ini-production /usr/local/php-5.3.29/etc/php.ini
cp /usr/local/php-5.3.29/etc/php-fpm.conf.default /usr/local/php-5.3.29/etc/php-fpm.conf
5、其实我们只是使用它默认提供给我们的一个配置,当然大家也可以根据自己需要进行修改配置信息,然后进行启动php-fpm
/usr/local/php-5.3.29/sbin/php-fpm
执行以上命令,如果没报错一般情况下表示启动正常,如果不放心,也可以通过端口判断是PHP否启动
# netstat -lnt | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
6、配置测试站点test.94cto.com 
mkdir /data/logs/nginx/ # 用于存放nginx日志.请看2.3的配置文件
mkdir -p /data/site/test.94cto.com/ # 站点根目录
vim /data/site/test.94cto.com/info.php
7、保存退出,在nginx.conf的http断中加上如下内容:
server {
listen 80;
server_name test.94cto.com;
access_log /data/logs/nginx/test.94cto.com.access.log main;
index index.php index.html index.html;
root /data/site/test.94cto.com;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}

三、安装mysql(选择5.1.x版本)-- 为了简单,直接使用yun安装
1、 yum install mysql-server mysql-devel mysql
2、启动
service mysqld start
3、设置mysql帐号
mysql安装后默认生成两个帐号:一个是root,未设置密码,可以从本机登录到mysql;另一个是匿名帐号,无帐号名、无密码,可以从本机登录,未提供用户名的连接都将假定为此帐号。这样的设置存在着安全隐患,按下面的步骤进行更改。
        以root帐号连接到mysql服务器:
           mysql -u root 
改变当前数据库为mysql:
           use mysql
        设置从本地主机登录的root帐号密码:
           set password for root@localhost=password('your password');
4、 删除匿名帐号: 
           delete from user where user='' ;
删除密码为空的帐号:
           delete from user where password='';
删除允许非localhost主机登录的帐号:
           delete from user where host<>'localhost' ;
执行下面的命令使更改生效:
           flush privileges ; 
执行下面的命令退出mysql命令行:
           quit
           或:
           /q

参考文章:http://www.94cto.com/index/Article/content/id/188.html

http://blog.csdn.net/xiamizy/article/details/2072525

http://www.cnblogs.com/kunhu/p/3633002.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值