享受孤独

Hi, nice to meet you~

ClydeEilliott's avatar ClydeEilliott

新PHP服务器环境搭建

  由于创新实践课程需要,重新购买阿里云服务器一台,安装centos,开始配置环境

前言

  • 本次服务器架构采用 CentOs + Nginx 1.7.4 + php 7.1.4 + MySql
  • 全程编译安装

统一

  • 安装路径路径:/usr/local/
  • 安装包存放位置:/home/apps/web/

安装依赖库和开发工具

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

#nginx
yum -y install pcre-devel zlib-devel

# php
yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel

# mysql
yum -y install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel

# sz rz
yum install lrzsz

Nginx

cd /home
mkdir apps
cd /apps
mkdir web
cd /web
wget http://nginx.org/download/nginx-1.7.4.tar.gz
tar -zxvf nginx-1.7.4.tar.gz
cd  nginx-1.7.4
./configure --prefix=/usr/local/nginx
make
make install

# 启动
/usr/local/nginx/sbin/nginx

PHP7.1.4

cd /home/apps/web
wget http://jp2.php.net/get/php-7.1.4.tar.gz
tar -zxvf php-7.1.4.tar.gz
cd php-7.1.4
./configure --prefix=/usr/local/php --with-mcrypt --with-zlib --with-curl --with-gd --disable-debug --enable-fpm --enable-mbstring --enable-sockets --enable-zip --enable-xml --enable-pdo
make
make install

# 发生了错误
yum install libmcrypt libmcrypt-devel mcrypt mhash
yum install unixODBC-devel

#启动
cd /usr/local/php/etc
mv php-fpm.conf.defaul php-fpm.comf
cd php-fpm.d
mv www.conf.default www.conf
/usr/local/php/sbin/php-fpm -y=/usr/local/php/etc/php-fpm.conf -c=/usr/local/php/etc/php.ini

这个步骤真 j2 慢啊。。。。。。。。。。。。

错误处理与依赖

cp  -frp /usr/lib64/libjpeg.* /usr/lib/
ln -s /usr/lib64/libpng.so /usr/lib/libpng.so
yum install libmcrypt libmcrypt-devel mcrypt mhash
yum install unixODBC-devel

MySQL 5.6.35

cd home/apps/web
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35.tar.gz
tar -zxvf mysql-5.6.35
cd mysql-5.6.35
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

make && make install