我用的是阿里云 centos7.2
虽然说yum安装比较快,但是我更喜欢编译安装,这样比较能理解你的软件都安装到哪里去了。
配置的环境是 cenos7.2 + nginx1.12.2 + php7.1.11 + mysql5.7.20
第一波 目录创建
mkdir /alidatamkdir /alidata/package//运行程序所在的目录mkdir –p /alidata/server//网站根目录mkdir –p /alidata/webappsmkdir –p /alidata/logs
第二波 软件安装
make : yum -y install gcc automake autoconf libtool makeg++ : yum install gcc gcc-c++ glibcphp模块 : yum -y install libmcrypt-devel mhash-devel libxslt-devel 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-develmysql必备 : yum install libaio*
第三波 软件下载
pcre : wget https://sourceforge.net/projects/pcre/files/pcre/8.41/pcre-8.41.tar.gzzlib : wget https://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gzopenssl : wget https://www.openssl.org/source/openssl-1.1.0b.tar.gznginx : wget http://nginx.org/download/nginx-1.12.2.tar.gzphp : wget http://cn2.php.net/distributions/php-7.1.11.tar.gzcmake : wget https://cmake.org/files/v3.10/cmake-3.10.0-rc5.tar.gzncurses : wget http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz
第四波 添加用户组和用户
groupadd wwwuseradd -r -g www wwwgroupadd mysqluseradd -r -g mysql mysql
第五波 开始编译安装
//nginx的编译安装./configure --prefix=/alidata/server/nginx-1.12.2 --sbin-path=/alidata/server/nginx-1.12.2/sbin/nginx --conf-path=/alidata/server/nginx-1.12.2/nginx.conf --pid-path=/alidata/server/nginx-1.12.2/nginx.pid --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --with-select_module --with-poll_module --error-log-path=/alidata/logs/nginx/error.log --http-log-path=/alidata/logs/nginx/access.log --with-pcre=/root/pcre-8.41 --with-zlib=/root/zlib-1.2.11 --with-openssl=/root/openssl-1.1.0bmake && make install//php的编译安装./configure --prefix=/alidata/server/php-7.1.11 --with-config-file-path=/alidata/server/php-7.1.11/etc --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendarmake && install//cmake的编译安装./configure --prefix=/alidata/package/cmakemake && install//ncurses的编译安装./configure --prefix=/alidata/package/ncursesmake && install//mysql初始化/alidata/server/mysql-5.7.20/bin/mysqld –initialize –user=mysql –basedir=/alidata/server/mysql-5.7.20/ –datadir=/alidata/server/mysql-5.7.20/data/
第六波 设置配置文件
//nginx多域名配置//nginx.confuser www www;worker_processes 2;error_log /alidata/logs/nginx/error.log crit;pid /alidata/server/nginx-1.12.2/logs/nginx.pid;worker_rlimit_nofile 65535;events { use epoll; worker_connections 65535;}http { include mime.types;default_type application/octet-stream;access_log /alidata/logs/nginx/access.log;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 8m;sendfile on;tcp_nopush on;keepalive_timeout 65;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.0;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on;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;log_format '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';include /alidata/server/nginx-1.12.2/conf/vhosts/*.conf;include /alidata/server/nginx-1.12.2/conf/proxy/*.conf;}
//虚拟主机的配置文件 /alidata/server/nginx-1.12.2/conf/vhosts/default.confserver { listen 80; server_name localhost; index index.php index.htm index.html; root /alidata/webapps; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } location ~ .*\.(php|php5)?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 1h; } # 配置页面静态化 include /alidata/server/nginx-1.12.2/conf/rewrite/default.conf; access_log /alidata/logs/nginx/access/default.log; error_log /alidata/logs/nginx/error/default.log;}
// rewrite规则 /alidata/server/nginx-1.12.2/conf/rewrite/default.confrewrite ^(.*)-htm-(.*)$ $1.php?$2 last;rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;rewrite ^(.*)/data/(.*)\.(htm|php)$ 404.html last;rewrite ^(.*)/attachment/(.*)\.(htm|php)$ 404.html last;rewrite ^(.*)/html/(.*)\.(htm|php)$ 404.html last;
//php配置文件cp /root/php-7.1.11/php.ini-production /alidata/server/php-7.1.11/etc/php.inicd /alidata/server/php-7.1.11/etccp php-fpm.conf.default php-fpm.confcd /alidata/server/php-7.1.11/etc/php-fpm.dcp www.conf.default www.conf// vi www.conf 修改user = wwwgroup = wwwlisten = 127.0.0.1:9000pm.max_children = 100pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35//mysql配置文件[client]port = 3306socket = /alidata/server/mysql-5.7.20/tmp/mysql.sock[mysqld]basedir=/alidata/server/mysql-5.7.20datadir=/alidata/server/mysql-5.7.20/datasocket=/alidata/server/mysql-5.7.20/tmp/mysql.sockriskssymbolic-links=0log-error=/alidata/logs/mysql/error.logpid-file=/alidata/logs/mysql/mysql.pid[mysqld_safe]log-error=/alidata/logs/mariadb/error.logpid-file=/alidata/logs/mariadb/mariadb.pid!includedir /etc/my.cnf.d//my.cnf.d目录下名为mysql-clients.cnf[mysql][mysql_upgrade][mysqladmin][mysqlbinlog][mysqlcheck][mysqldump][mysqlimport][mysqlshow][mysqlslap]
亲测可用,有问题可以留言交流