1.系统环境
OS: Rocky Linux 8
NGINX: nginx 1.20
MySQL: MySQL8.0 PHP
PHP: default 7.2.x
PHP其他版本:5.3.x 5.5.x 5.6.x 7.0.x 7.4.x 8.0.x
1.1 安装依赖
yum install apr* autoconf automake bison bzip2 bzip2* cpp curl curl-devel fontconfig fontconfig-devel freetype-devel git gcc gcc-c++ gd gd-devel gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libXaw-devel libXmu-devel libtiff libtiff* make openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet wget zlib-devel ncurses-devel libtirpc-devel gtk* ntpstat bison* sqlite-devel oniguruma libzip-devel
2. 数据库安装
2.1 安装 rpcsvc-proto
[root@localhost soft]# tar xf rpcsvc-proto-1.4.2.tar.xz
[root@localhost soft]# cd rpcsvc-proto-1.4.2/
[root@localhost soft]# ./configure
[root@localhost soft]# make && make install
2.2 安装 cmake
[root@localhost soft]# tar zxf cmake-3.21.3.tar.gz
[root@localhost soft]# cd cmake-3.21.3/
[root@localhost cmake-3.21.3]# ./configure
[root@localhost cmake-3.21.3]# make && make install
2.3 安装MySQL
[root@localhost soft]# groupadd mysql
[root@localhost soft]# useradd -g mysql -s /bin/false mysql
[root@localhost soft]# mkdir -p /usr/local/mysql/data/mysql
[root@localhost soft]# chown -R mysql.mysql /usr/local/mysql/data/
[root@localhost soft]# tar zxf mysql-boost-8.0.25.tar.gz
[root@localhost soft]# cd mysql-8.0.25/
[root@localhost mysql-8.0.25]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DINSTALL_DATADIR=/usr/local/mysql/data/mysql -DMYSQL_USER=mysql -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_EMBEDDED_SERVER=1 -DFORCE_INSOURCE_BUILD=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/soft/mysql-8.0.25/boost -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
[root@localhost mysql-8.0.25]# make
[root@localhost mysql-8.0.25]# make install
2.4 初始化MySQL数据库
删除默认配置文件 my.cnf
rm -f /etc/my.cnf
数据库初始化
[root@localhost]# cd /usr/local/mysql/ [root@localhost mysql]# ./bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mysql
输出
[root@localhost mysql]# ./bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ 2021-09-27T11:06:55.258559Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.25) initializing of server in progress as process 352862 2021-09-27T11:06:55.263276Z 0 [Warning] [MY-010161] [Server] You need to use --log-bin to make --log-slave-updates work. 2021-09-27T11:06:55.267723Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-09-27T11:06:55.606878Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-09-27T11:06:56.667253Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: xVGu-rCy5a.q #password
编辑my.cnf文件
[root@localhost mysql]# cat /usr/local/mysql/my.cnf [client] port=3306 socket=/tmp/mysql.sock password="my password" [mysqld] port=3306 user = mysql socket=/tmp/mysql.sock tmpdir = /tmp key_buffer_size=16M max_allowed_packet=128M default_authentication_plugin=mysql_native_password #设置加密方式为mysql_native_password,MySQL 8.0.x默认使用caching_sha2_password加密。 open_files_limit = 60000 explicit_defaults_for_timestamp server-id = 1 character-set-server = utf8mb4 federated max_connections = 1000 max_connect_errors = 100000 interactive_timeout = 86400 wait_timeout = 86400 sync_binlog=0 back_log=100 default-storage-engine = InnoDB log_slave_updates = 1 [mysqldump] quick [mysqld-8.0] sql_mode=TRADITIONAL [mysqladmin] force
链接my.cnf到etc
ln -s /usr/local/mysql/my.cnf /etc/my.cnf
配置mysqld启动文件
[root@localhost mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld [root@localhost mysql]# chmod +x /etc/init.d/mysqld
编辑 mysqld
[root@localhost mysql]# vim /etc/rc.d/init.d/mysqld
输出
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data添加环境变量
[root@localhost ~]# cat /etc/profile.d/mysql.sh export PATH=$PATH:/usr/local/mysql/bin
添加软链接
在编译PHP时可以不用指定mysql的库文件
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql mkdir /var/lib/mysql #创建目录 ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
修改 MySQL密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.10 sec) mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password' PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.03 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
三、安装Nginx
3.1 安装 pcre
[root@localhost soft]# tar zxf pcre-8.44.tar.gz [root@localhost soft]# cd pcre-8.44/ [root@localhost pcre-8.44]# mkdir /usr/local/pcre -p [root@localhost pcre-8.44]# ./configure --prefix=/usr/local/pcre [root@localhost pcre-8.44]# make && make install
3.2 安装openssl
[root@localhost soft]# tar zxf openssl-1.1.1k.tar.gz [root@localhost soft]# cd openssl-1.1.1k/ [root@localhost openssl-1.1.1k]# mkdir -p /usr/local/openssl [root@localhost openssl-1.1.1k]# ./config -fPIC shared zlib --prefix=/usr/local/openssl [root@localhost openssl-1.1.1k]# make && make install
3.3 安装zlib
[root@localhost soft]# tar zxf zlib-1.2.11.tar.gz [root@localhost soft]# cd zlib-1.2.11/ [root@localhost zlib-1.2.11]# mkdir -p /usr/local/zlib [root@localhost zlib-1.2.11]# ./configure --prefix=/usr/local/zlib [root@localhost zlib-1.2.11]# make && make install
3.4 安装 nginx
[root@localhost nginx-1.20.0]# groupadd www [root@localhost nginx-1.20.0]# useradd -g www -s /bin/false www [root@localhost nginx-1.20.0]# ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/opt/soft/openssl-1.1.1k --with-zlib=/opt/soft/zlib-1.2.11 --with-pcre=/opt/soft/pcre-8.44 [root@localhost nginx-1.20.0]# make && make install
3.5 Nginx启动脚本
vim /lib/systemd/system/nginx.service
[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network.target [Service] Type=forking PIDFile=/var/run/nginx.pid ExecStartPost=/bin/sleep 0.1 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID TimeoutStartSec=120 LimitNOFILE=1000000 LimitNPROC=1000000 LimitCORE=1000000 [Install] WantedBy=multi-user.target
3.6 设置开机启动
systemctl enable nginx.service
Nginx设置txt, pdf, doc, xls文件直接下载
location / { if ($request_filename ~* ^.*?\.(txt|pdf|doc|xls)$){ add_header Content-Disposition: 'attachment;'; } }
四、安装PHP
4.1 安装yasm
[root@localhost soft]# tar zxf yasm-1.3.0.tar.gz [root@localhost soft]# cd yasm-1.3.0/ [root@localhost yasm-1.3.0]# ./configure [root@localhost yasm-1.3.0]# make && make install
4.2 安装libmcrypt
[root@localhost soft]# tar zxf libmcrypt-2.5.8.tar.gz [root@localhost soft]# cd libmcrypt-2.5.8/ [root@localhost libmcrypt-2.5.8]# ./configure [root@localhost libmcrypt-2.5.8]# make && make install
4.3 安装libvpx
[root@localhost soft]# tar zxf libvpx-1.10.0.tar.gz [root@localhost soft]# cd libvpx-1.10.0/ [root@localhost libvpx-1.10.0]# ./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9 [root@localhost libvpx-1.10.0]# make && make install
4.4 安装tiff
[root@localhost soft]# tar zxf tiff-4.0.7.tar.gz [root@localhost soft]# cd tiff-4.0.7/ [root@localhost tiff-4.0.7]# ./configure --prefix=/usr/local/tiff --enable-shared [root@localhost tiff-4.0.7]# make && make install
4.5 安装libpng
[root@localhost soft]# tar zxf libpng-1.6.37.tar.gz [root@localhost soft]# cd libpng-1.6.37/ [root@localhost libpng-1.6.37]# ./configure --prefix=/usr/local/libpng --enable-shared [root@localhost libpng-1.6.37]# make && make install
4.6 安装freetype
[root@localhost soft]# tar zxf freetype-2.10.4.tar.gz [root@localhost soft]# cd freetype-2.10.4/ [root@localhost freetype-2.10.4]# ./configure --prefix=/usr/local/freetype --enable-shared [root@localhost freetype-2.10.4]# make && make install
4.7 安装jpeg
[root@localhost soft]# tar zxf jpegsrc.v9d.tar.gz [root@localhost soft]# cd jpeg-9d/ [root@localhost jpeg-9d]# ./configure --prefix=/usr/local/jpeg --enable-shared [root@localhost jpeg-9d]# make && make install
4.8 安装新版本GD库
新版本GD库适用于PHP 5.4.x及以上
[root@localhost soft]# tar zxf libgd-2.3.1.tar.gz [root@localhost soft]# cd libgd-2.3.1/ [root@localhost libgd-2.3.1]# ./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/lib64 --with-tiff=/usr/local/tiff [root@localhost libgd-2.3.1]# make && make install
4.9 安装旧版本GD库
旧版本GD库知用于PHP 5.3.x以下
[root@localhost soft]# tar zxf gd-2.0.35.tar.gz [root@localhost soft]# cd gd-2.0.35/ [root@localhost gd-2.0.35]# ./configure --prefix=/usr/local/gd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/lib64 --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx [root@localhost gd-2.0.35]# make && make install
4.10 安装t1lib
[root@localhost soft]# tar zxf t1lib-5.1.2.tar.gz [root@localhost soft]# cd t1lib-5.1.2/ [root@localhost t1lib-5.1.2]# ./configure --prefix=/usr/local/t1lib --enable-shared [root@localhost t1lib-5.1.2]# make without_doc && make install
4.11 安装libzip
[root@localhost soft]# tar zxf libzip-1.7.3.tar.gz [root@localhost soft]# cd libzip-1.7.3/ [root@localhost libzip-1.7.3]# mkdir build [root@localhost libzip-1.7.3]# cd build/ [root@localhost build]# cmake .. [root@localhost build]# make [root@localhost build]# make install
4.12 安装oniguruma
编译 PHP 7.4.x 需要
[root@localhost soft]# tar zxf oniguruma-6.9.4.tar.gz [root@localhost soft]# cd oniguruma-6.9.4/ [root@localhost oniguruma-6.9.4]# ./autogen.sh [root@localhost oniguruma-6.9.4]# ./configure --prefix=/usr [root@localhost oniguruma-6.9.4]# make && make install
4.13 安装低版本 openssl
适用于PHP7.3.x以下编译安装
[root@localhost soft]# tar zxf openssl-1.0.2k.tar.gz [root@localhost soft]# cd openssl-1.0.2k/ [root@localhost openssl-1.0.2k]# ./config -fPIC shared zlib --prefix=/usr/local/ssl [root@localhost openssl-1.0.2k]# make && make install
[root@localhost soft]# mv /usr/bin/openssl /usr/bin/openssl._1.1.1g [root@localhost soft]# mv /usr/include/openssl/ /usr/include/openssl._1.1.1g [root@localhost soft]# mv /usr/lib64/libssl.so /usr/lib64/libssl.so._1.1.1g_bak [root@localhost soft]# ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl [root@localhost soft]# ln -s /usr/local/ssl/include/openssl /usr/include/openssl [root@localhost soft]# ln -s /usr/local/ssl/lib/libssl.so /usr/lib64/libssl.so [root@localhost soft]# echo "/usr/local/ssl/lib" >> /etc/ld.so.conf [root@localhost soft]# ldconfig -v [root@localhost soft]# openssl version OpenSSL 1.0.2k 26 Jan 2017
4.14 安装curl
[root@localhost soft]# tar zxf curl-7.76.1.tar.gz [root@localhost soft]# cd curl-7.76.1/ [root@localhost curl-7.76.1]# ./configure --without-nss --prefix=/usr/local/curl --with-ssl=/usr/local/ssl
4.15 安装 expat
[root@localhost soft]# tar zxf expat-2.4.1.tar.gz [root@localhost soft]# cd expat-2.4.1/ [root@localhost expat-2.4.1]# ./configure --prefix=/usr/local/expat --enable-shared [root@localhost expat-2.4.1]# make && make install
4.15 链接lib库
[root@localhost]# cp -frp /usr/lib64/libltdl.so* /usr/lib/ [root@localhost]# cp -frp /usr/lib64/libXpm.so* /usr/lib/
五 编译安装 PHP 5.3.29
yum install -y expat-devel
[root@localhost php-5.3.29]# ./configure --prefix=/usr/local/php53 --with-config-file-path=/usr/local/php53/etc --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-gd=/usr/local/gd --with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib --with-freetype-dir=/usr/lib --with-iconv --with-zlib-dir=/usr/local/zlib --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl=/usr/local/ssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl=/usr/local/curl --enable-ctype --enable-mysqlnd
5.1 删除系统默认php.ini
[root@localhost php-5.3.29]# rm -f /etc/php.ini [root@localhost php-5.3.29]# cp php.ini-production /usr/local/php53/etc/php.ini [root@localhost php-5.3.29]# ln -s /usr/local/php53/etc/php.ini /etc/php.ini [root@localhost php-5.3.29]# cp /usr/local/php53/etc/php-fpm.conf.default /usr/local/php53/etc/php-fpm.conf
5.2 配置php-fpm.conf
[root@localhost etc]# grep -Ev "^#|^$|^;" php-fpm.conf [global] pid = run/php-fpm.pid [www] user = www group = www listen = 127.0.0.1:9053 #调整端口号为PHP对应版本号 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3
5.3 设置php-fpm开机启动
[root@localhost soft]# cd php-5.3.29/ [root@localhost php-5.3.29]# cp /opt/soft/php-5.3.29/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php53-fpm [root@localhost php-5.3.29]# chmod +x /etc/rc.d/init.d/php53-fpm [root@localhost php-5.3.29]# chkconfig php53-fpm on
5.4 编辑php-fpm启动脚本
[root@localhost php-5.3.29]# grep -Ev "^#|^$|^;" /etc/rc.d/init.d/php53-fpm prefix=/usr/local/php53 exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php53-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 --pid $php_fpm_PID"
5.5 启动 php-fpm
[root@localhost php-5.3.29]# mv /usr/local/php53/sbin/php-fpm /usr/local/php53/sbin/php53-fpm [root@localhost php-5.3.29]# service php53-fpm start [root@localhost php-5.3.29]# ss -tnlp |grep 9053 LISTEN 0 128 127.0.0.1:9053 0.0.0.0:* users:(("php53-fpm",pid=1434960,fd=0),("php53-fpm",pid=1434959,fd=0),("php53-fpm",pid=1434958,fd=9))
5.6 配置php.ini文件
[root@localhost ~]# grep -Ev "^#|^$|^;" /usr/local/php53/etc/php.ini [PHP] engine = On short_open_tag = On #支持PHP短标签 asp_tags = Off precision = 14 y2k_compliance = On output_buffering = 4096 zlib.output_compression = Off implicit_flush = Off unserialize_callback_func = serialize_precision = 17 allow_call_time_pass_reference = Off safe_mode = Off safe_mode_gid = Off safe_mode_include_dir = safe_mode_exec_dir = safe_mode_allowed_env_vars = PHP_ safe_mode_protected_env_vars = LD_LIBRARY_PATH 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 #禁用函数 disable_classes = zend.enable_gc = On expose_php = Off #禁止显示php版本 max_execution_time = 30 max_input_time = 60 memory_limit = 128M error_reporting = E_ALL & ~E_DEPRECATED display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off html_errors = Off variables_order = "GPCS" request_order = "GP" register_globals = Off register_long_arrays = Off register_argc_argv = Off auto_globals_jit = On post_max_size = 8M magic_quotes_gpc = Off magic_quotes_runtime = Off magic_quotes_sybase = Off auto_prepend_file = auto_append_file = default_mimetype = "text/html" doc_root = user_dir = enable_dl = Off file_uploads = On upload_max_filesize = 2M max_file_uploads = 20 allow_url_fopen = On allow_url_include = Off default_socket_timeout = 60 [Date] date.timezone = PRC #时区 [filter] [iconv] [intl] [sqlite] [sqlite3] [Pcre] [Pdo] [Pdo_mysql] pdo_mysql.cache_size = 2000 pdo_mysql.default_socket= [Phar] [Syslog] define_syslog_variables = Off [mail function] SMTP = localhost smtp_port = 25 mail.add_x_header = On [SQL] sql.safe_mode = Off [ODBC] odbc.allow_persistent = On odbc.check_persistent = On odbc.max_persistent = -1 odbc.max_links = -1 odbc.defaultlrl = 4096 odbc.defaultbinmode = 1 [Interbase] ibase.allow_persistent = 1 ibase.max_persistent = -1 ibase.max_links = -1 ibase.timestampformat = "%Y-%m-%d %H:%M:%S" ibase.dateformat = "%Y-%m-%d" ibase.timeformat = "%H:%M:%S" [MySQL] mysql.allow_local_infile = On mysql.allow_persistent = On mysql.cache_size = 2000 mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = Off [MySQLi] mysqli.max_persistent = -1 mysqli.allow_persistent = On mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = 3306 mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = Off [mysqlnd] mysqlnd.collect_statistics = On mysqlnd.collect_memory_statistics = Off [OCI8] [PostgreSQL] pgsql.allow_persistent = On pgsql.auto_reset_persistent = Off pgsql.max_persistent = -1 pgsql.max_links = -1 pgsql.ignore_notice = 0 pgsql.log_notice = 0 [Sybase-CT] sybct.allow_persistent = On sybct.max_persistent = -1 sybct.max_links = -1 sybct.min_server_severity = 10 sybct.min_client_severity = 10 [bcmath] bcmath.scale = 0 [browscap] [Session] session.save_handler = files session.use_cookies = 1 session.use_only_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.bug_compat_42 = Off session.bug_compat_warn = Off session.referer_check = session.entropy_length = 0 session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" [MSSQL] mssql.allow_persistent = On mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatability_mode = Off mssql.secure_connection = Off [Assertion] [COM] [mbstring] [gd] [exif] [Tidy] tidy.clean_output = Off [soap] soap.wsdl_cache_enabled=1 soap.wsdl_cache_dir="/tmp" soap.wsdl_cache_ttl=86400 soap.wsdl_cache_limit = 5 [sysvshm] [ldap] ldap.max_links = -1 [mcrypt] [dba] [xsl]
六、 安装 PHP 5.5.38
6.1 编译安装
[root@localhost soft]# tar zxf php-5.5.38.tar.gz [root@localhost soft]# cd php-5.5.38/ [root@localhost php-5.5.38]# export LD_LIBRARY_PATH=/usr/local/libgd/lib [root@localhost php-5.5.38]# ./configure --prefix=/usr/local/php55 --with-config-file-path=/usr/local/php55/etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-gd=/usr/local/libgd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/lib64 --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl=/usr/local/ssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl=/usr/local/curl --enable-ctype --enable-mysqlnd [root@localhost php-5.5.38]# make && make install
6.2 编辑配置文件 php-fpm.conf
[root@localhost php-5.5.38]# cp php.ini-production /usr/local/php55/etc/php.ini [root@localhost php-5.5.38]# cp /usr/local/php55/etc/php-fpm.conf.default /usr/local/php55/etc/php-fpm.conf [root@localhost php-5.5.38]# vim /usr/local/php55/etc/php-fpm.conf [root@localhost php-5.5.38]# grep -Ev "^#|^$|^;" /usr/local/php55/etc/php-fpm.conf [global] [www] user = www group = www listen = 127.0.0.1:9055 pm = dynamic pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3
6.3 php-fpm 开机启动
[root@localhost php-5.5.38]# cp /opt/soft/php-5.5.38/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php55-fpm [root@localhost php-5.5.38]# chmod +x /etc/rc.d/init.d/php55-fpm [root@localhost php-5.5.38]# vim /etc/rc.d/init.d/php55-fpm [root@localhost php-5.5.38]# grep -Ev "^#|^$|^;" /etc/rc.d/init.d/php55-fpm prefix=/usr/local/php55 exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php55-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 --pid $php_fpm_PID" [root@localhost php-5.5.38]# mv /usr/local/php55/sbin/php-fpm /usr/local/php55/sbin/php55-fpm
6.4 编辑php.ini文件
[root@localhost php-5.5.38]# vim /usr/local/php55/etc/php.ini [root@localhost ~]# grep -Ev "^#|^$|^;" /usr/local/php55/etc/php.ini [PHP] engine = On short_open_tag = On asp_tags = Off precision = 14 output_buffering = 4096 zlib.output_compression = Off implicit_flush = Off unserialize_callback_func = serialize_precision = 17 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 disable_classes = zend.enable_gc = On expose_php = Off max_execution_time = 30 max_input_time = 60 memory_limit = 128M error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT display_errors = Off display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off html_errors = On variables_order = "GPCS" request_order = "GP" register_argc_argv = Off auto_globals_jit = On post_max_size = 8M auto_prepend_file = auto_append_file = default_mimetype = "text/html" doc_root = user_dir = enable_dl = Off file_uploads = On upload_max_filesize = 2M max_file_uploads = 20 allow_url_fopen = On allow_url_include = Off default_socket_timeout = 60 [CLI Server] cli_server.color = On [Date] date.timezone = PRC [filter] [iconv] [intl] [sqlite] [sqlite3] [Pcre] [Pdo] [Pdo_mysql] pdo_mysql.cache_size = 2000 pdo_mysql.default_socket= [Phar] [mail function] SMTP = localhost smtp_port = 25 mail.add_x_header = On [SQL] sql.safe_mode = Off [ODBC] odbc.allow_persistent = On odbc.check_persistent = On odbc.max_persistent = -1 odbc.max_links = -1 odbc.defaultlrl = 4096 odbc.defaultbinmode = 1 [Interbase] ibase.allow_persistent = 1 ibase.max_persistent = -1 ibase.max_links = -1 ibase.timestampformat = "%Y-%m-%d %H:%M:%S" ibase.dateformat = "%Y-%m-%d" ibase.timeformat = "%H:%M:%S" [MySQL] mysql.allow_local_infile = On mysql.allow_persistent = On mysql.cache_size = 2000 mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = Off [MySQLi] mysqli.max_persistent = -1 mysqli.allow_persistent = On mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = 3306 mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = Off [mysqlnd] mysqlnd.collect_statistics = On mysqlnd.collect_memory_statistics = Off [OCI8] [PostgreSQL] pgsql.allow_persistent = On pgsql.auto_reset_persistent = Off pgsql.max_persistent = -1 pgsql.max_links = -1 pgsql.ignore_notice = 0 pgsql.log_notice = 0 [Sybase-CT] sybct.allow_persistent = On sybct.max_persistent = -1 sybct.max_links = -1 sybct.min_server_severity = 10 sybct.min_client_severity = 10 [bcmath] bcmath.scale = 0 [browscap] [Session] session.save_handler = files session.use_strict_mode = 0 session.use_cookies = 1 session.use_only_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.referer_check = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" [MSSQL] mssql.allow_persistent = On mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatibility_mode = Off mssql.secure_connection = Off [Assertion] [COM] [mbstring] [gd] [exif] [Tidy] tidy.clean_output = Off [soap] soap.wsdl_cache_enabled=1 soap.wsdl_cache_dir="/tmp" soap.wsdl_cache_ttl=86400 soap.wsdl_cache_limit = 5 [sysvshm] [ldap] ldap.max_links = -1 [mcrypt] [dba] [opcache] opcache.enable=1 opcache.enable_cli=0 [curl] zend_extension=opcache.so
7 安装PHP 5.6.40
编译安装
[root@localhost soft]# tar zxf php-5.6.40.tar.gz [root@localhost soft]# cd php-5.6.40/ [root@localhost php-5.6.40]# export LD_LIBRARY_PATH=/usr/local/libgd/lib [root@localhost php-5.6.40]# ./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-gd=/usr/local/libgd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/lib64 --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl=/usr/local/ssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl=/usr/local/curl --enable-ctype --enable-mysqlnd
十、Nginx 配置文件
[root@localhost conf]# grep -Ev "^#|^$" nginx.conf
user www www;
worker_processes auto;
error_log /data/wwwlogs/error_nginx.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 1024m;
client_body_buffer_size 10m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
server_tokens off;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
#Gzip Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
##Brotli Compression
#brotli on;
#brotli_comp_level 6;
#brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
#open_file_cache max=1000 inactive=20s;
#open_file_cache_valid 30s;
#open_file_cache_min_uses 2;
#open_file_cache_errors on;
server {
listen 80;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
#error_page 404 /404.html;
#error_page 502 /502.html;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location ~ [^/]\.php(/|$) {
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
deny all;
}
}
include vhost/*.conf;
}
5.1 虚拟主机
[root@localhost vhost]# grep -Ev "^#|^$" localhost.conf server { listen 80; listen [::]:80; server_name localhost; access_log /data/wwwlogs/192.168.10.11_nginx.log combined; index index.html index.htm index.php; root /data/wwwroot/default/; #include /usr/local/nginx/conf/rewrite/typecho.conf; #error_page 404 /404.html; #error_page 502 /502.html; location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ { #valid_referers none blocked *.localhost localhost; if ($invalid_referer) { return 403; } } location ~ .*\.php(\/.*)*$ { root /data/wwwroot/default/; fastcgi_pass 127.0.0.1:9053; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) { deny all; } }
评论 (0)