记录下安装依赖的包和便已过程,文件可以从官网下载,这里不过多描述。
php编译
1 /***php7.0安装***/ 2 3 #安装依赖的包 4 yum install -y \ 5 gcc-c++ autoconf \ 6 libjpeg libjpeg-devel libpng \ 7 libpng-devel freetype freetype-devel \ 8 libpng libpng-devel libxml2 libxml2-devel \ 9 zlib zlib-devel glibc glibc-devel \ 10 glib2 glib2-devel bzip2 bzip2-devel \ 11 ncurses curl openssl-devel \ 12 gdbm-devel db4-devel libXpm-devel \ 13 libX11-devel gd-devel gmp-devel \ 14 readline-devel libxslt-devel \ 15 expat-devel xmlrpc-c xmlrpc-c-devel \ 16 libicu-devel libmcrypt-devel \ 17 libmemcached-devel 18 19 #编译php7 20
./configure --prefix=/usr/local/php7 \
--enable-mysqlnd \
--enable-fpm --enable-soap \
--with-libxml-dir --with-openssl \
--with-mhash \
--with-pcre-regex --with-zlib \
--enable-bcmath --with-iconv \
--with-bz2 --enable-calendar \
--with-curl --with-cdb --enable-dom \
--enable-exif --enable-fileinfo \
--enable-filter --with-pcre-dir \
--enable-ftp --with-gd \
--with-openssl-dir --with-jpeg-dir \
--with-png-dir --with-zlib-dir \
--with-freetype-dir \
--enable-gd-jis-conv --with-gettext \
--with-gmp --with-mhash \
--enable-json --enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl --with-onig \
--enable-pdo --with-pdo-mysql \
--with-zlib-dir \
--enable-session \
--enable-simplexml --enable-sockets \
--enable-sysvmsg --enable-sysvsem \
--enable-sysvshm --enable-wddx \
--with-libxml-dir --with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear --enable-intl \
--enable-pcntl \
--enable-opcache \
54 55 make 56 make install 57 58 ln -sf /usr/local/php7/bin/php /usr/local/bin/php 59 ln -sf /usr/local/php7/bin/phpize /usr/local/bin/ 60 61 #复制配置文件 62 #/usr/src/php-7.0.6/ 下载包目录 63 cp /usr/src/php-7.0.6/php.ini-development /usr/local/php7/lib/php.ini 64 65 cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf 66 cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf 67 cp /usr/src/php-7.0.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 68 chmod +x /etc/init.d/php-fpm 69 70 #查看php加载配置文件信息 71 php -i | grep .ini 72 73 #启动php进程管理工具php-fpm 74 service php-fpm restart
swoole扩展安装
/*****swoole扩展*******/ #安装依赖包 swoole 2.0 ./configure --with-php-config=/usr/local/php7/bin/php-config --enable-swoole-debug --enable-sockets \
--enable-async-redis --enable-swoole --enable-swoole-static --with-swoole --enable-mysqlnd --enable-coroutine
注意:需要
nghttp2库 : https://github.com/nghttp2/nghttp2
hiredis库 : https://github.com/redis/hiredis
--enable-async-redis 需要指明 libhiredis.so 的位置
make && make install #编辑php.ini文件即可 extension=swoole #查看是否成功 php -m | grep swoole
mysql编译
1 /*****mysql 5.6*****/ 2 #centos7 默认没有mysql的源,而是社区版本mariadb 3 wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 4 rpm -ivh mysql-community-release-el7-5.noarch.rpm 5 yum install mysql-server mysql-client 6 7 #登陆mysql 8 mysql -u root 9 #重设密码 10 use mysql 11 update user set Password=Password('123456') where User='root'; 12 FLUSH PRIVILEGES; 13 14 #重启服务 15 service mysqld restart 16 17 #重新登陆 18 mysql -u root -p
nginx编译
1 ./configure \ 2 --prefix=/usr/local/nginx \ 3 --with-http_ssl_module \ 4 --with-http_realip_module \ 5 --with-http_addition_module \ 6 --with-http_sub_module \ 7 --with-http_dav_module \ 8 --with-http_flv_module \ 9 --with-http_mp4_module \ 10 --with-http_gunzip_module \ 11 --with-http_gzip_static_module \ 12 --with-http_random_index_module \ 13 --with-http_secure_link_module \ 14 --with-http_stub_status_module \ 15 --with-http_auth_request_module \ 16 --with-mail \ 17 --with-mail_ssl_module \ 18 --with-file-aio --with-stream \ 21 --with-threads 22 23 make && make install 24 25 ln -sf /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
整合nginx和php
1 #修改nginx.conf ,这里只列出部分修改的配置 2 http { 3 4 include mime.types; 5 default_type application/octet-stream; 6 7 #设置请求日志格式 8 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 9 '$status $body_bytes_sent "$http_referer" ' 10 '"$http_user_agent" "$http_x_forwarded_for"'; 11 #成功请求日志目录 12 access_log logs/access.log main; 13 14 sendfile on; 15 #tcp_nopush on; 16 17 #keepalive_timeout 0; 18 keepalive_timeout 65; 19 20 #gzip on; 21 22 server { 23 listen 80; 24 server_name localhost; 25 #根目录 26 root /home/web; 27 28 #索引文件 29 index index.php index.html; 30 31 #如果没有索引(index配置),显示列表 32 autoindex on; 33 34 #charset koi8-r; 35 36 access_log logs/host.access.log main; 37 38 location / { 39 #root html; 40 index index.php index.html index.htm; 41 } 42 43 #404页面 44 error_page 404 /404.html; 45 46 # redirect server error pages to the static page /50x.html 47 # 48 error_page 500 502 503 504 /50x.html; 49 location = /50x.html { 50 #root html; 51 } 52 53 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 54 # 55 #location ~ \.php$ { 56 # proxy_pass http://127.0.0.1; 57 #} 58 59 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 60 61 #遇到php文件就 交给9000端口的fastcgi处理 62 location ~ \.php$ { 63 #root /home/web; 64 fastcgi_pass 127.0.0.1:9000; 65 fastcgi_index index.php; 66 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 67 include fastcgi_params; 68 } 69 70 # deny access to .htaccess files, if Apache's document root 71 # concurs with nginx's one 72 # 73 #location ~ /\.ht { 74 # deny all; 75 #} 76 } 77 }
#平滑重启
nginx -s reload
查看php信息
1 vim /home/web/index.php 2 <?php 3 phpinfo();