|
Share under CentOS 6.5 to build PHP environment (Nginx + MariaDB + PHP7) experiences notes, there is something wrong, please greatly noted.
1.mariaDb
vim /etc/yum.repos.d/MariaDB.repo
[Mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos5-x86
gpgkey = https: //yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck = 1
sudo yum install MariaDB-server MariaDB-client
# Start MariaDB
sudo /etc/init.d/mysql start
By creating MariaDB.repo, you can yum install
Linux versions corresponding to different profiles, and detailed methods that can refer to the following link
https://mariadb.com/kb/zh-cn/installing-mariadb-with-yum/
https://downloads.mariadb.org/mariadb/repositories/#mirror=opencas
2.nginx
# This command can be a key to install the Developer Tools
yum -y groupinstall "Development Tools" "Development Libraries"
# Create a user www and group 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
# Start Nginx
/ Usr / local / nginx / sbin / nginx
# Test the configuration file is correct
/ Usr / local / nginx / sbin / nginx -t
You can also operate the service through a service nginx command, as follows
1. First create a file, which is written as the following shell script:
Enter the edit mode and copy the following contents: View file nginx.shell
#! / Bin / bash
# Nginx Startup script for the Nginx HTTP Server
#
# Chkconfig: - 85 15
# 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 = 0
prog = "nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. / Etc / sysconfig / network
# Check that networking is up.
[$ {NETWORKING} = "no"] && exit 0
[-x $ Nginxd] || exit 0
# Start nginx daemons functions.
start () {
if [-e $ nginx_pid]; then
echo "nginx already running ...."
exit 1
fi
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 "$ 1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $ prog
RETVAL = $?
;;
*)
echo $ "Usage: $ prog {start | stop | restart | reload | status | help}"
exit 1
esac
exit $ RETVAL
2. Copy this file to the directory /etc/init.d
#cp ./nginx /etc/init.d
3. Modify the file executable permissions
#chmod + x /etc/init.d/nginx
4. Place the executable file to the Services to go
#chkconfig --add nginx
Then you can use the service command to manage!
3.php
# Install module before the first update needed
# Yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
# Wget https://downloads.php.net/~ab/php-7.0.0RC1.tar.gz
# Tar zxvf 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
# Compiler installation
# Make && make install
# Profile
# Cp php.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
# start up
# /etc/init.d/php-fpm
# Check whether to activate
ps aux | grep php
Modify nginx configuration, monitoring * .php file
# Vim /usr/local/nginx/conf/nginx.conf
Simple configuration is as follows:
user www www;
worker_processes 10;
#error_log /data/logs/nginx_error.log crit;
#pid logs / nginx.pid;
#Specifies The value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application / octet-stream;
#charset gbk;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
#client_max_body_size 8m;
server_tokens off;
expires 1h;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
error_page 404 /404.jpg;
fastcgi_connect_timeout 20;
fastcgi_send_timeout 30;
fastcgi_read_timeout 120;
fastcgi_buffer_size 256k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_temp_path / dev / shm;
gzip on;
gzip_min_length 2048;
gzip_buffers 4 16k;
gzip_http_version 1.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 80;
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_page 404 /404.html;
# Redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \ .php $
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
################# Include ###################
# Include block_ips.conf;
. # Include vhost / * conf;
# Force domain names corresponding to the domain name conf
# Server {
# Listen 80 default;
# Server_name _;
# Return 404;
#}
}
Last phpinfo (), success. |
|
|
|