firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
systemctl restart firewalld
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
#保存退出
shutdown -r now
mkdir -p /data/soft/
cd /data/soft/
yum install wget
yum install pcre
yum install openssl*
yum -y install gcc gcc-c++ 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 ncurses ncurses-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 make
yum -y install gd gd2 gd-devel gd2-devel
wget http://nginx.org/download/nginx-1.9.9.tar.gz
wget http://ftp.exim.llorien.org/pcre/pcre-8.34.tar.gz
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz
wget -O php-7.1.4.tar.gz http://hk1.php.net/get/php-7.1.4.tar.gz/from/this/mirror
wget -O libmcrypt-2.5.8.tar.gz http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
wget https://bitbucket.org/libgd/gd-libgd/get/gd-2.1.0.tar.gz
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
wget -O freetype-2.7.1.tar.gz https://sourceforge.net/projects/freetype/files/freetype2/2.7.1/freetype-2.7.1.tar.gz/download
wget -O libpng-1.6.29.tar.gz https://sourceforge.net/projects/libpng/files/libpng16/1.6.29/libpng-1.6.29.tar.gz/download
wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
tar zxvf cmake-2.8.12.1.tar.gz
cd cmake-2.8.12.1
./configure
make && make install
ln -s /usr/local/bin/cmake /usr/bin/cmake
cd ..
groupadd mysql
useradd -g mysql mysql -s /bin/false
tar zxvf mysql-5.6.15.tar.gz
cd mysql-5.6.15
cmake .
make
make install
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql
chown -R root:mysql /usr/local/mysql/
chown -R mysql data
ln -s /usr/local/mysql/bin/* /usr/local/bin/
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod a+x /etc/init.d/mysqld
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
cp /etc/my.cnf /etc/my.cnfbak
vim /etc/my.cnf
把下面配置复制到my.cnf
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
# MASTER_USER=, MASTER_PASSWORD= ;
#
# where you replace , , by quoted strings and
# by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host =
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user =
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port =
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
systemctl restart mysqld
systemctl enable mysqld
mysqladmin -u root -p password "123456"
cd /data/soft/
tar zxvf pcre-8.34.tar.gz
cd pcre-8.34
./configure --prefix=/usr/local/pcre
make && make install
cd ..
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install
cd ..
groupadd www
useradd -g www www -s /bin/false
mkdir /usr/local/webserver
tar zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure --prefix=/usr/local/webserver/nginx --user=www --group=www --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-pcre=/data/soft/pcre-8.34 --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module
make && make install
cd ..
/usr/local/webserver/nginx/sbin/nginx
vi /etc/rc.d/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: /usr/local/webserver/nginx/conf/nginx.conf
# pidfile: /usr/local/webserver/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/webserver/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/webserver/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
if [ -z "`grep $user /etc/passwd`" ]; then
useradd -M -s /bin/nologin $user
fi
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
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
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 775 /etc/rc.d/init.d/nginx
/etc/rc.d/init.d/nginx restart
systemctl restart nginx.service
systemctl enable nginx.service
tar zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure --prefix=/usr/local/libxml2
make && make install
cd ..
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
cd ..
tar zxvf libpng-1.6.29.tar.gz
cd libpng-1.6.29
./configure --prefix=/usr/local/libpng
make && make install
cd ..
tar zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/usr/local/jpeg9 --enable-shared --enable-static
make && make install
cd ..
tar zxvf freetype-2.7.1.tar.gz
cd freetype-2.7.1
./configure --prefix=/usr/local/freetype
make && make install
cd ..
tar zxvf autoconf-latest.tar.gz
cd autoconf-2.69
./configure
make && make install
cd ..
tar zxvf gd-2.1.0.tar.gz
cd libgd-gd-libgd-9f0a7e7f4f0f/
cmake .
make install
cd ..
tar zxvf php-7.1.4.tar.gz
cd php-7.1.4
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mcrypt=/usr/local/libmcrypt --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg9 --with-freetype-dir=/usr/local/freetype --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype
make && make install
cp php.ini-production /usr/local/webserver/php/etc/php.ini
rm -rf /etc/php.ini
ln -s /usr/local/webserver/php/etc/php.ini /etc/php.ini
cp /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf
vi /usr/local/webserver/php/etc/php-fpm.conf
pid = run/php-fpm.pid #取消前面的分号保存退出
cp /usr/local/webserver/php/etc/php-fpm.d/www.conf.default /usr/local/webserver/php/etc/php-fpm.d/www.conf
vi /usr/local/webserver/php/etc/php-fpm.d/www.conf
user = www #设置php-fpm运行账号为www
group = www #设置php-fpm运行组为www
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
systemctl enable php-fpm.service
vi /usr/local/webserver/php/etc/php.ini
#禁用函数
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#时区
date.timezone = PRC
#禁止显示php版本的信息
expose_php = OFF
cd /usr/local/webserver/nginx/conf/
vi nginx.conf
#首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/webserver/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
user www www;
#取消FastCGI server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#添加加载网站配置文件添加在最后一个大括号里面
include /usr/local/webserver/nginx/conf/vhost/*;
systemctl restart php-fpm.service
systemctl restart nginx.service
systemctl restart mysqld.service
yum install httpd-tools
ab -c 100 -n 10000 http://localhost/
由于php7的memcache扩展在pecl上的包都是会安装失败,所以本人在github上找到了另外的包
yum install zip unzip
cd /data/soft/
wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
unzip php7.zip
cd pecl-memcache-php7/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make && make install
打开 /usr/local/webserver/php/etc/php.ini 查找 ; extension_dir = “ext”
在其后增加一行:
extension = “memcache.so”
sudo sysctl vm.nr_hugepages=128
vi /usr/local/webserver/php/etc/php.ini
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.huge_code_pages=1
opcache.file_cache=/tmp
#PHP
systemctl start php-fpm.service #启动
systemctl stop php-fpm.service #停止
systemctl restart php-fpm.service #重启
#Nginx
systemctl start nginx.service #启动
systemctl stop nginx.service #停止
systemctl restart nginx.service #重启
#MySQL
systemctl start mysqld.service #启动
systemctl stop mysqld.service #停止
systemctl restart mysqld.service #重启