linux下nginx+mysql+php安装配置
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
安装前准备
相关软件包下载地址 http://pan.baidu.com/s/1u3CuU
标准库安装
yum -y install wget make vim install gcc gcc-c++ ncurses ncurses-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre pcre-devel zlip zlip-devel
新建软件安装目录
mkdir /usr/local/webserver
php依赖库安装
libxml2(包含库和实用工具用于解析XML文件)
tar zxvf libxml2-2.9.0.tar.gz -C /usr/local/webserver/
cd /usr/local/webserver/libxml2-2.9.0
./configure
make&&make install
libmcrypt(加密算法扩展库支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法)
tar zxvf libmcrypt-2.5.8.tar.gz -C /usr/local/webserver/
cd /usr/local/webserver/libmcrypt-2.5.8
./configure
make && make install
nginx安装
tar zxvf nginx-1.5.9.tar.gz -C /usr/local/webserver/
mv /usr/local/webserver/nginx-1.5.9 /usr/local/webserver/nginx
cd /usr/local/webserver/nginx
./configure
make && make install
vi /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/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"
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
}
restart() {
configtest || return $?
stop
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
修改nginx脚本权限
chmod +x /etc/init.d/nginx
添加到系统服务
/sbin/chkconfig nginx on
mysql安装
groupadd mysql
useradd -r -g mysql mysql
tar zxvf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz -C /usr/local/webserver/
mv /usr/local/webserver/mysql-5.6.16-linux-glibc2.5-x86_64 /usr/local/webserver/mysql
## ln -s /usr/local/webserver/mysql-5.6.16-linux-glibc2.5-x86_64 /usr/local/webserver/mysql
cd /usr/local/webserver/mysql/
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/my-default.cnf /etc/my.cnf
bin/mysqld_safe --user=mysql &
修改mysql.server脚本
vi support-files/mysql.server
basedir=
datadir=
改为
basedir=/usr/local/webserver/mysql
datadir=/usr/local/webserver/mysql/data
配置启动脚本
cp support-files/mysql.server /etc/init.d/mysqld
添加到环境变量
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/webserver/mysql/bin
php安装
gd库安装
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/webserver/gd2/
make && make install
tar zxvf php-5.3.28.tar.gz -C /usr/local/webserver/
mv /usr/local/webserver/php-5.3.28/ /usr/local/webserver/php
cd /usr/local/webserver/php
./configure --enable-fpm --with-mysql=/usr/local/webserver/mysql/ --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-config-file-path=/usr/local/webserver/php/ --with-openssl --enable-mbstring --with-zlib --enable-xml --with-gd=/usr/local/webserver/gd2/ --with-jpeg-dir --enable-bcmath --with-mcrypt --with-iconv --enable-pcntl --enable-shmop --enable-simplexml --enable-ftp
make && make install
cp php.ini-development /usr/local/webserver/php/php.ini
配置php.ini
vim php.ini
;date.timezone =
改为 date.timezone = prc
配置nginx.conf
mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf_bak
vim /usr/local/nginx/conf/nginx.conf
user root root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
server {
listen 80;
server_name 192.168.51.33;
root /home/www;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
#配置站点伪静态(此处配置好之后,需要在ecstore/config/config.php中修改“define('WITH_REWRITE',true);”)
if ($request_uri ~ (.+?\.php)(|/.*)$ ){
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
location / {
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#设置pathinfo
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?.php)(/.+)?$") {
set $script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_NAME $script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
配置php.ini
vi /usr/local/webserver/php/php.ini
enable_dl = On
cgi.force_redirect = 0
cgi.fix_pathinfo=1
fastcgi.impersonate = 1
cgi.rfc2616_headers = 1
allow_url_fopen = On
配置php-fpm启动脚本
vi /etc/init.d/php-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/usr/local/
php_fpm_BIN=${prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
php_pid="--pid $php_fpm_PID"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting php-fpm "
$php_fpm_BIN $php_opts $php_pid
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Gracefully shutting down php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-exit"
exit 1
else
echo " done"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;
esac
脚本执行权限
cd /usr/local/etc && cp php-fpm.conf.default php-fpm.conf
chmod +x /etc/init.d/php-fpm
设置开机启动
/sbin/chkconfig php-fpm on
/******下面是ecstore所需******/
ZendGuard安装
tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/local/webserver/
mv /usr/local/webserver/ZendGuardLoader-php-5.3-linux-glibc23-x86_64 /usr/local/webserver/ZendGuardLoader
cd /usr/local/webserver/ZendGuardLoader
cp php-5.3.x/ZendGuardLoader.so /usr/local/webserver/php/ext/
配置php.ini
vi /usr/local/webserver/php/php.ini
[Zend Guard]
;/usr/local/webserver/php/ext/ZendGuardLoader.so 这个是你当时指定的zend的目录
zend_extension=/usr/local/webserver/php/ext/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
到此结束
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献1条内容
所有评论(0)