原文链接:centos6.7+nginx1.15.0+php5.6+mysql5.5+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/
/usr/local/php5/bin/phpize # 这里为你自己的 phpize 路径,如果找不到,使用 whereis 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
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于