centos6.7+nginx1.15.0+php5.6+mysql5.5+openssl配置

  Seves

原文链接:centos6.7+nginx1.15+mysql5.5+php5.6+openssl配置

本文主要介绍如何在centos6.7中配置nginx1.15+mysql5.5+php5.6+openssl

安装必备软件包:

yum install cmake make gcc gcc-c++ 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-devel libidn libidn-devel openssl expat expat-devel openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers unixODBC-devel libxslt-devel libevent-devel libtool-ltdl bison libtool pcre-devel zip unzip gmp-devel gd gd-devel

下载mysql

wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.19.tar.gz

关闭防火墙

service iptables stop
setenforce 0
vi /etc/sysconfig/selinux,将其中的SELINUX设置为disabled

创建用户以及文件夹

useradd -d /usr/local/mysql/ mysql
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/log
chown -R mysql:mysql /usr/local/mysql/data/
chown -R mysql:mysql /usr/local/mysql/log/
chmod 750 /usr/local/mysql/data
chmod 750 /usr/local/mysql/log

安装mysql

tar -zxvf mysql-5.5.19.tar.gz
cd mysql-5.5.19
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock  -DDEFAULT_CHARSET=gbk  -DDEFAULT_COLLATION=gbk_chinese_ci  -DEXTRA_CHARSETS=all  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_READLINE=1  -DENABLED_LOCAL_INFILE=1  -DMYSQL_DATADIR=/usr/local/mysql/data  -DMYSQL_USER=mysql  -DMYSQL_TCP_PORT=3306
make && make install

配置mysql

cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

修改/etc/my.cnf中mysql的相关路径

初始化mysql

cd /usr/local/mysql
scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
service mysqld start 
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
/usr/local/mysql/bin/mysqladmin -u root password 123456
/usr/local/mysql/bin/mysql -u root -p123456
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql

创建nginx用户组及用户

groupadd nginx
useradd -g nginx -s /bin/false -M nginx

下载nginx

wget "http://nginx.org/download/nginx-1.15.0.tar.gz"

安装nginx

tar -zxvf nginx-1.15.0.tar.gz 
cd nginx-1.15.0
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock  --user=nginx --group=nginx --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi 
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
make && make install
mkdir -p /var/tmp/nginx/client
vi /etc/init.d/nginx
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
service nginx start
chkconfig nginx on

下载php

wget "http://cn2.php.net/distributions/php-5.6.36.tar.bz2"

安装php

tar -jxvf php-5.6.36.tar.bz2
cd php-5.6.36
./configure --prefix=/usr/local/php5 --enable-fastCGI --enable-fpm --with-libxml-dir=/usr/local/lib --with-zlib-dir=/usr/local/lib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-soap --enable-sockets --enable-xml --enable-mbstring --with-png-dir=/usr/local --with-jpeg-dir=/usr/local --with-curl=/usr/lib --with-freetype-dir=/usr/include/freetype2/freetype/ --enable-bcmath --enable-maintainer-zts
make && make install

配置php

cp php.ini-development /usr/local/php5/lib/php.ini

修改/usr/local/php5/lib/php.ini中的相关路径

cd /usr/local/php5/etc/
cp php-fpm.conf.default php-fpm.conf

修改php-fpm.conf中的相关参数

配置nginx

vi /usr/local/nginx/conf/nginx.conf
location ~ \.php$ {

if ( -f $request_filename ) {

fastcgi_pass 127.0.0.1:9000;

}

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/网站目录$fastcgi_script_name;

 fastcgi_param SCRIPT_NAME $fastcgi_script_name;

include fastcgi_params;

}

增加openssl支持

切换目录到下载的php目录

cd php-5.6.36/ext/openssl/

执行phpize,这里为你自己的phpize路径,如果找不到,使用whereis phpize查找

/usr/local/php5/bin/phpize 

执行后,发现错误 无法找到config.m4 ,config0.m4就是config.m4。直接重命名

mv config0.m4 config.m4

/usr/local/php5/bin/phpize

./configure --with-openssl --with-php-config=/usr/local/php5/bin/php-config

make && make install

编辑php.ini文件

vi /usr/local/php5/lib/php.ini

在文件最后添加

extension=/usr/local/php5/lib/php/extensions/no-debug-zts-20131226/openssl.so
allow_url_include = On

重启nginx即可

pkill php-fpm
/usr/local/php5/sbin/php-fpm
service nginx stop
service nginx start

本文链接:https://www.fcblog.top/articles/2018/09/07/1536301770407.html

fc
1,643