centos6.5下安装nginx1.6+php7+mysql5.1+emlog6

2016-3-8 Frank 服务器

安装配置nginxaaaaa

  • 安装
yum -y install gcc* autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake
yum -y install  openssl-devel pcre-devel 
ulimit -SHn 65535
cd /opt/
mkdir soft
cd /opt/soft

wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure --prefix=/opt/nginx --with-http_stub_status_module
make
make install

#启动 nginx
/opt/nginx/sbin/nginx
#停止 nginx
/opt/nginx/sbin/nginx -s stop
#重载 nginx
/opt/nginx/sbin/nginx -s reload 
  • 配置
#测试配置文件:
/opt/nginx/sbin/nginx -t

#nginx.conf 添加
vim /opt/nginx/conf/nginx.conf
include vhosts/*.conf;

mkdir -p /opt/nginx/conf/vhosts


#错误:
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_s
#解决:
http {
    server_names_hash_bucket_size  64;
    ... 

安装rz/sz

yum install lrzsz 

安装mysql

yum list | grep mysql
yum install -y mysql-server mysql mysql-deve
#查看版本
rpm -qi mysql-server
#启动
service mysqld start
#重启
service mysqld restart

/usr/bin/mysqladmin -u root password xxx 
创建用户:grant all privileges on xxx.* to xxx@localhost identified by 'xxx'; 

安装php

yum -y install  automake autoconf libtool make  gcc gcc-c++ glibc
yum -y install gd*

yum -y install libmcrypt-devel mhash-devel libxslt-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel mysql-devel
 
wget http://cn2.php.net/distributions/php-7.0.4.tar.gz

tar zvxf php-7.0.4.tar.gz 
cd php-7.0.4

./configure --prefix=/usr/local/php  --enable-zip  --enable-fpm --with-mcrypt --with-zlib --enable-mbstring  --with-curl --disable-debug  --disable-rpath --enable-inline-homeimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --enable-gd-native-ttf  --enable-xml  --enable-bcmath  --enable-shmop  --with-openssl --with-xmlrpc --enable-soap  --enable-opcache --with-pdo-mysql --with-freetype-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-iconv-dir --with-png-dir=/usr/lib  --with-libxml-dir=/usr/lib

make
make test
make install
cp /opt/soft/php-7.0.4/php.ini-development /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
修改
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
vim www.conf
#修改
user = www
group = www
user = www
group = www
保存退出
修改nginx.conf 文件

[php-fpm - 启动参数及重要配置详解:](http://www.4wei.cn/archives/1002061)

php-fpm的启动参数

#测试php-fpm配置
/usr/local/php/sbin/php-fpm -t
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf -t
 
#启动php-fpm
/usr/local/php/sbin/php-fpm
/usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini -y /usr/local/php/etc/php-fpm.conf

#错误:
ERROR: [pool www] cannot get uid for user 'www'
#解决:
#添加用户
groupadd www
useradd -r -g www www

#关闭php-fpm
kill -INT `cat /usr/local/php/var/run/php-fpm.pid`
 
#重启php-fpm
kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
#fpm启动
/usr/local/php/sbin/php-fpm 
#fpm 关闭
killall -9 php-fpm 

安装emlog

mysql -u root -pxxx create database emlog; grant all privileges on emlog.* to xxx@'localhost' identified by 'xxx';

cd /opt/soft wget http://www.emlog.net/em_download/emlog/emlog_6.0.0.zip mv /opt/soft/emlog_6.0.0/src/ /opt/www/emlog chmod -R 777 config.php content/cache/ content/plugins/

vim /opt/nginx/conf/vhosts/liangcuntu.com.conf

server
     {
        listen       80;

        server_name liangcuntu.com www.liangcuntu.com;
        index index.php index.html index.htm;
            root    /opt/www/emlog;
            #access_log /opt/nginx_logs/emlog/access_log;
         location / {
             if (!-e $request_filename) {
                 rewrite ^/(.*)$ /index.php/$1 last;
             }

        }
         location /index.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param SCRIPT_FILENAME $document_root/index.php;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        location ~ \.php$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
} 

/opt/nginx/sbin/nginx -t /opt/nginx/sbin/nginx -s reload

大功告成!

发表评论 登录

Top