아 리 클 라 우 드 서버 centos 6.8 컴 파일 설치 nginx + mysql + php 환경

7419 단어
선언:
아 리 클 라 우 드 서버 시스템 버 전 은 centos 6.8, nginx - 1.8.1, mysql - 5.6.16, php - 5.6.31
nginx
설치 의존 패키지
yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel

nginx 다운로드 및 컴 파일
tar xvf nginx-1.8.1.tar.gzv
cd nginx-1.8.1.tar.gz
./configure  --prefix=/usr/local/nginx  --sbin-path=/usr/local/nginx/sbin/nginx
make
make install

nginx 조작
시작: /usr/local/nginx/sbin/nginx 닫 기: /usr/local/nginx/sbin/nginx -s stop 다시 시작: /usr/local/nginx/sbin/nginx -s reloadnginx 스 크 립 트vim /etc/init.d/nginx
#!/bin/sh

#

# nginx - this script starts and stops the nginx daemon

#

# chkconfig:  - 85 15

# description: Nginx is an HTTP(S) server, HTTP(S) reverse \

#              proxy and IMAP/POP3 proxy server

# processname: nginx

# config:      /etc/nginx/nginx.conf

# config:      /etc/sysconfig/nginx

# pidfile:    /var/run/nginx.pid

# Source function library.

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

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"

prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

start() {

[ -x $nginx ] || exit 5

[ -f $NGINX_CONF_FILE ] || exit 6

echo -n $"Starting $prog: "

daemon $nginx -c $NGINX_CONF_FILE

retval=$?

echo

[ $retval -eq 0 ] && touch $lockfile

return $retval

}

stop() {

echo -n $"Stopping $prog: "

killproc $prog -QUIT

retval=$?

echo

[ $retval -eq 0 ] && rm -f $lockfile

return $retval

killall -9 nginx

}

restart() {

configtest || return $?

stop

sleep 1

start

}

reload() {

configtest || return $?

echo -n $"Reloading $prog: "

killproc $nginx -HUP

RETVAL=$?

echo

}

force_reload() {

restart

}

configtest() {

$nginx -t -c $NGINX_CONF_FILE

}

rh_status() {

status $prog

}

rh_status_q() {

rh_status >/dev/null 2>&1

}

case "$1" in

start)

rh_status_q && exit 0

$1

;;

stop)

rh_status_q || exit 0

$1

;;

restart|configtest)

$1

;;

reload)

rh_status_q || exit 7

$1

;;

force-reload)

force_reload

;;

status)

rh_status

;;

condrestart|try-restart)

rh_status_q || exit 0

;;

*)

echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"

exit 2

esac

권한 증가: chmod +x /etc/init.d/nginx 시동: chkconfig nginx on2. MySQL
설치 의존, 부분 은 nginx 를 설치 할 때 설치 한 적 이 있 습 니 다:yum install gcc gcc-c++ ncurses-devel perl
cmake 설치
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar xvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
make
make install

MySQL 사용자 와 그룹 설정groupadd mysql useradd -r -g mysql mysql
설치 디 렉 터 리 및 데이터베이스 파일 디 렉 터 리 만 들 기mkdir -p /usr/local/mysql mkdir -p /data/mysqldb
mysql 설치
tar xvf mysql-5.6.16.tar.gz
cd mysql-5.6.16.tar.gz

cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1m -DMYSQL_DATADIR=/data/mysqldb  -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1

make
make install

디 렉 터 리 권한 수정chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /data/mysqldb
mysql 초기 화 cd /usr/local/mysql ./scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb프로필 복사cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
mysql 서비스 시작 스 크 립 트 복사 및 PATH 경로 추가
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

vim /etc/profile

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH

source /etc/profile

프로필 수정vim /etc/my.cnf datadir = /data/mysqldb
my sql 을 열 고 시작 항목 을 추가 합 니 다.service mysqld start chkconfig mysqld on
보안 스 크 립 트 실행 /usr/local/mysql/bin/mysql_secure_installation3. PHP
1. 설치 의존, 부분 설치
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel

암호 화 확장 라 이브 러 리 설치, libmcrypt - 2.5.8. tar. gz 다운로드 (http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/)
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install

php 컴 파일, php - 5.6.31. tar. gz 다운로드 (http://cn2.php.net/downloads.php)
tar zxvf php-5.6.31.tar.gz
cd php-5.6.31
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-mysql-sock --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-fpm --with-ncurses --enable-soap --with-libxml-dir --with-XMLrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir  --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir  --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear
make
make install

php 프로필 복사 cp php.ini-development /usr/local/php/lib/php.inphp. ini 수정
timezone = "Asia/Shanghai"
short_open_tag = On
session.save_path = "/tmp/session"

php - fpm 설정 복사 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confphp - fpm 의 사용자 그룹 을 수정 합 니 다. nginx 와 같 습 니 다.
php - fpm 시작 스 크 립 트 를 서비스 로 복사 cp php-5.6.31/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmphp - fpm 를 열 고 부팅 항목 을 추가 합 니 다.service php-fpm start chkconfig php-fpm on
nginx 지원 php 설정cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.confbak vi /usr/local/nginx/conf/nginx.conf
1. server 에 있 는 php 의 주석 2. index 를 열 고 index. php 를 추가 합 니 다. 3. fastcgi 로 변경 합 니 다.param 1 행동: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;테스트
vi /usr/local/nginx/html/index.php


브 라 우 저 입력 localhost / index. php

좋은 웹페이지 즐겨찾기