Centos6.5搭建php环境(nginx+mariadb+php7)

王朝学院·作者佚名  2016-08-28
窄屏简体版  字體: 小  |  中  |  大  |  超大  

php小菜一枚,第一次写bolg,有什么不对的地方,还请各位大大指出

1.mariaDb

vim /etc/yum.repos.d/MariaDB.repo

[mariadb]name= MariaDBbaseurl= http://yum.mariadb.org/5.5/centos5-x86gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1

sudo yum install MariaDB-server MariaDB-client

#启动MariaDB

sudo /etc/init.d/MySQLstart

通过在创建MariaDB.repo,可以实现yum安装

对应不同linux版本配置文件,和详细方法可以参考下面链接

https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/

https://downloads.mariadb.org/mariadb/repositories/#mirror=opencas

2.nginx

#此命令可以一键安装开发工具包

yum-y groupinstall"Development Tools""Development Libraries"

#创建www组与www用户

groupadd www

useradd -g www -s /usr/sbin/nologin www

# 安装Nginx

tar zxvf nginx-1.9.9.tar.gz

cd nginx-1.9.9.tar.gz/

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

make && make install

#启动Nginx

/usr/local/nginx/sbin/nginx

#测试配置文件是否正确

/usr/local/nginx/sbin/nginx -t

还可以通过service命令来操作nginx服务,如下

1.先创建一个文件,里面写入以下shell脚本如:

[flash=500,400]http://s1.knowsky.com/20160211/w3vam0xgvo051.png[/flash]

进入编辑模式并复制以下内容:查看nginx.shell文件

#!/bin/bash

# nginx Startup scriptforthe Nginx HTTP Server

#

# chkconfig:-8515# description: Nginx is a high-performance web and proxy server.

# It has a lot of features, but it's not for everyone.# processname: nginx

# pidfile:/var/run/nginx.pid

# config:/usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/var/run/nginx.pid

RETVAL=0prog="nginx"# Sourcefunctionlibrary.

./etc/rc.d/init.d/functions

# Source networking configuration.

./etc/sysconfig/network

# Check that networking is up.

[ ${NETWORKING}="no"] && exit0[-x $nginxd ] || exit0# Start nginx daemons functions.

start() {if[ -e $nginx_pid ];thenecho"nginx already running...."exit1fiecho-n $"Starting $prog:"daemon $nginxd-c ${nginx_config}

RETVAL=$?echo[ $RETVAL=0] &&touch/var/lock/subsys/nginx

return $RETVAL

}

# Stop nginx daemons functions.

stop() {echo-n $"Stopping $prog:"killproc $nginxd

RETVAL=$?echo[ $RETVAL=0] &&rm-f /var/lock/subsys/nginx /var/run/nginx.pid

}

# reload nginx service functions.

reload() {echo-n $"Reloading $prog:"#kill-HUP `cat${nginx_pid}`

killproc $nginxd-HUP

RETVAL=$?echo}

# See how we were called.case"$1"instart)

start

;;

stop)

stop

;;

reload)

reload

;;

restart)

stop

start

;;

status)

status $prog

RETVAL=$?;;*)echo$"Usage: $prog {start|stop|restart|reload|status|help}"exit1esacexit $RETVAL

2.把这个文件复制到/etc/init.d目录下

#cp ./nginx /etc/init.d

3.修改这个文件为可执行的权限

#chmod +x /etc/init.d/nginx

4.把这个可执行文件加到服务服务中去

#chkconfig --add nginx

之后就可以使用 service 命令来管理了!

3.php

#安装前先更新所需要的模块

#yum-yinstalllibjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel

#wgethttps://downloads.php.net/~ab/php-7.0.0RC1.tar.gz#tarzxvf php-7.0.0RC1.tar.gz

# cd php-7.0.0RC1

# ./configure --prefix=/usr/local/php \--with-curl \--with-freetype-dir\--with-gd \--with-gettext \--with-iconv-dir\--with-kerberos \--with-libdir=lib64 \--with-libxml-dir\--with-mysqli \--with-openssl \--with-pcre-regex \--with-pdo-mysql \--with-pdo-sqlite \--with-pear \--with-png-dir\--with-xmlrpc \--with-xsl \--with-zlib \--enable-fpm \--enable-bcmath \--enable-libxml \--enable-inline-optimization \--enable-gd-native-ttf \--enable-mbregex \--enable-mbstring \--enable-opcache \--enable-pcntl \--enable-shmop \--enable-soap \--enable-sockets \--enable-sysvsem \--enable-xml \--enable-zip# 编译安装

#make&&makeinstall# 配置文件

#cpphp.ini-development /usr/local/php/lib/php.ini

#cp/usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

#cp/usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

#cp-R ./sapi/fpm/php-fpm /etc/init.d/php-fpm

# 启动

#/etc/init.d/php-fpm

# 查看是否启动psaux |grepphp

修改nginx配置,监听*.php的文件

# vim /usr/local/nginx/conf/nginx.conf

简单配置如下:

user www www;

worker_processes10;

#error_log/data/logs/nginx_error.log crit;

#pid logs/nginx.pid;

#Specifies the valueformaximumfiledescriptors that can be opened by this process.

worker_rlimit_nofile51200;

events

{

use epoll;

worker_connections51200;

}

http

{

include mime.types;

default_typeapplication/octet-stream;

#charset gbk;

server_names_hash_bucket_size128;

client_header_buffer_size 32k;

large_client_header_buffers432k;

#client_max_body_size 8m;

server_tokens off;

expires 1h;

sendfile on;

tcp_nopush on;

keepalive_timeout60;

tcp_nodelay on;

error_page404/404.jpg;

fastcgi_connect_timeout20;

fastcgi_send_timeout30;

fastcgi_read_timeout120;

fastcgi_buffer_size 256k;

fastcgi_buffers8256k;

fastcgi_busy_buffers_size 256k;

fastcgi_temp_file_write_size 256k;

fastcgi_temp_path/dev/shm;gzipon;

gzip_min_length2048;

gzip_buffers416k;

gzip_http_version1.1;

gzip_types text

/plain text/CSSapplication/xml application/x-javascript ;

log_formataccess'$remote_addr - $remote_user [$time_local] "$request"''$status $body_bytes_sent "$http_referer"''"$http_user_agent" $http_x_forwarded_for';

server {

listen80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location/{

root html;

index index.html index.htm index.php;

}

#rewrite index.php/^(.*)$ idex.php?s=/$1last;

#error_page404/404.html;

# redirect server error pages to the static page/50x.html

#

error_page500502503504/50x.html;

location= /50x.html {

root html;

}

location~\.php$

{

fastcgi_pass127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

}

################# include ###################

# include block_ips.conf ;

# include vhost/*.conf ;

#强制域名访问对应域名的conf

# server {

# listen 80 default ;

# server_name _;

# return 404;

# }

}

最后phpinfo(),成功

[flash=500,400]http://s1.knowsky.com/20160211/vjghnlk2guc51.png[/flash]

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航