Centos 6.5 Build PHP Environment (NGINX+MARIADB+PHP7), centosnginx_php tutorial

Source: Internet
Author: User

Centos 6.5 Build PHP Environment (NGINX+MARIADB+PHP7), Centosnginx


PHP is a piece of cake, the first time to write Bolg, there is nothing wrong, but also ask you to greatly point out

1.mariaDb

vim/etc/Yum. Repos.d/mariadb.repo
[mariadb]= mariadb= 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/mysql start

By creating the Mariadb.repo, you can implement the Yum installation

corresponding to different Linux version profiles, and detailed methods can refer to the following links

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

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

2.nginx

#此命令可以一键安装开发工具包
Yum"development Tools""development Libraries"

#创建www组与www用户
Groupadd www
Useradd-g www-s/usr/sbin/nologin www

# Install 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

You can also use the service command to operate Nginx services, as follows

1. First create a file with the following shell script written as:

File

#!/bin/bash# nginx Startup script forThe Nginx HTTP server## chkconfig:- -  the# 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.confnginxd=/usr/local/nginx/sbin/Nginxnginx_config=/usr/local/nginx/conf/Nginx.confnginx_pid=/var/run/Nginx.pidretval=0Prog="Nginx"# SourcefunctionLibrary:/etc/rc.d/init.d/functions# Source Networking configuration:/etc/sysconfig/network# Check that networking are up. [${networking}="No"] && exit0[ -X $nginxd] | | Exit0# Start Nginx daemons Functions.start () {if[-e $nginx _pid]; Then   Echo "Nginx already running ...."Exit1fi   Echo-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 " $" inchstart) Start; stop) stop;; reload) reload;; restart) stop start;; Status) status $prog RETVAL=$?        ;;*)        Echo$"Usage: $prog {start|stop|restart|reload|status|help}"Exit1EsacExit $RETVAL

2. Copy this file to the /etc/init.d directory

#CP./NGINX/ETC/INIT.D

3. Modify this file to be an executable permission

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

4. Add this executable file to the service service

#chkconfig--add Nginx

You can then use the service command to manage it!

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# Compile and install # Make&& Make Install# config file #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# Boot #/etc/init.d/php-fpm# to see if it startsPSAux |grepPhp

Modify Nginx configuration, listen for *.php files

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

The simple configuration is as follows:

User www www;worker_processesTen; #error_log/data/logs/nginx_error.log crit; #pid logs/nginx.pid; #Specifies the value forMaximumfiledescriptors that can is opened by this process.worker_rlimit_nofile51200; events{use Epoll; Worker_connections51200;}    http{include mime.types; Default_type Application/octet-stream;         #charset GBK; Server_names_hash_bucket_size -;    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_timeout -;    Tcp_nodelay on; Error_page404/404. jpg; Fastcgi_connect_timeout -; Fastcgi_send_timeout -; Fastcgi_read_timeout -;     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/css Application/xml application/x-JavaScript; Log_format Access'$remote _addr-$remote _user [$time _local] "$request"'                          '$status $body _bytes_sent "$http _referer"'                          '"$http _user_agent" $http _x_forwarded_for'; server {Listen the;        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=/$1  Last ; #error_page404/404. html; # REDIRECT Server error pages to the static page/50x.html # Error_page - 502 503 504/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 \ default; # server_name _;# return 404;#}} 

Last Phpinfo (), success

http://www.bkjia.com/PHPjc/1086846.html www.bkjia.com true http://www.bkjia.com/PHPjc/1086846.html techarticle Centos 6.5 Build PHP Environment (NGINX+MARIADB+PHP7), Centosnginx php a piece of cake, the first write Bolg, there is nothing wrong, also ask you to point out the big 1.mariaDb Vim/etc/yum. Repos ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.