本站会员必须 邮箱验证成功后 才能发帖。马上注册查阅更多教程,下载海量资源,让你轻松玩做站
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
1.0 安装环境:CentOS-7-x86_64-Minimal-1607 系统约定 软件源代码包存放位置:/usr/local/src 源码包编译安装位置:/usr/local/软件名字 2.0关闭防火墙 [root@hushuai ~]# systemctl stop firewalld.service //暂时关闭防火墙 [root@hushuai ~]# systemctl disable firewalld.service //开机禁止启动防火墙
2.1关闭selinux [root@hushuai ~]# setenforce 0 //暂时禁用selinux [root@hushuai ~]# vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 //永久关闭selinux
2.2清除MariaDB [root@localhost ~]# rpm -qa | grep mariadb //查看centos7系统自带mariadb数据库 mariadb-libs-5.5.47-1.el7_2.x86_64 [root@hushuai ~]# yum remove mariadb-libs //删除系统自带数据库
2.3安装编译工具及库文件 [root@hushuai ~]# yum install -y apr* autoconf automake bison cloog-ppl compat* cpp fontconfig fontconfig-devel gcc gcc-c++ gtk+-devel gd glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libXpm* libtiff libtiff* mpfr ntp patch pcre-devel php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel //安装依赖包
2.4编译安装MySQL 2.4.1安装cmake [root@hushuai ~]# cd /usr/local/src/ //软件包存放目录 ,把安装软件考到此目录下 [root@localhost src]# tar xf cmake-3.6.3.tar.gz //解压cmake [root@localhost src]# cd cmake-3.6.3 //进入cmake安装目录 [root@localhost cmake-3.6.3]# ./configure //配置 [root@localhost cmake-3.6.3]# make //编译 [root@localhost cmake-3.6.3]# make install //安装
2.4.3安装MySQL [root@hushuai ~]# groupadd mysql //添加mysql组 [root@hushuai ~]#useradd -g mysql mysql -s /bin/false //创建用户mysql并加入到mysql组且不允许mysql用户直接登录系统 [root@hushuai ~]# mkdir -p /data/mysql //创建MySQL数据库存放目录
[root@hushuai ~]# chown -R mysql:mysql /data/mysql //设置MySQL数据库存放目录权限
[root@hushuai ~]# mkdir -p /usr/local/mysql //创建MySQL安装目录 [root@localhost ~]# cd /usr/local/src/ //切换至软件包存放目录
[root@localhost src]# tar xf mysql-5.6.33.tar.gz //解压 [root@localhost src]# cd mysql-5.6.33 //进入目录 [root@localhost mysql-5.6.33]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci //配置 根据服务需求配置
[root@localhost mysql-5.6.33]# make //编译 [root@localhost mysql-5.6.33]# make install //安装 [root@localhost ~]#rm -rf /etc/my.cnf //删除系统默认的配置文件(如果默认没有就不用删除) [root@localhost ~]#cd /usr/local/mysql/ //切换至MySQL安装目录
[root@localhost mysql]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql //生成mysql系统数据库 [root@localhost mysql]#ln -s /usr/local/mysql/my.cnf /etc/my.cnf //添加到/etc目录的软连接 [root@localhost mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld //把MySQL加入系统启动 [root@localhost mysql]# chmod 755 /etc/init.d/mysqld //增加执行权限
[root@localhost mysql]# chkconfig mysqld on //加入开机启动 [root@localhost mysql]# vim /etc/rc.d/init.d/mysqld //编辑 46行和47行目录 basedir=/usr/local/mysql //等号后面填写MySQL程序安装路径 datadir=/data/mysql //等号后面填写MySQL数据库存放目录
[root@hushuai mysql]# systemctl daemon-reload //守护进程重新加载 [root@localhost mysql]# systemctl start mysql.service //启动mysql
[root@localhost mysql]# vim /etc/profile //把MySQL服务加入系统环境变量,在最后添加下行 export PATH=$PATH:/usr/local/mysql/bin
[root@localhost ~]# source /etc/profile //使配置立刻生效
下面这两行把MySQL的库文件链接到系统默认的位置,这样在编译类似PHP等软件时可以不用指定MySQL的库文件地址。 ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql
[root@localhost ~]# mkdir /var/lib/mysql //创建目录 [root@localhost ~]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock //添加软链接 [root@localhost ~]#mysql_secure_installation //设置MySQL密码,提示按Y 回车输入2次密码 [root@localhost ~]# mysql -uroot –p //使用root登录,输入密码进入。 [root@hushuai ~]# ps -ef|grep mysql //查看进程或端口
二、安装Nginx 1、安装pcre [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# mkdir /usr/local/pcre [root@localhost src]# tar xf pcre-8.39.tar.gz [root@localhost src]# cd pcre-8.39
[root@localhost pcre-8.39]# ./configure --prefix=/usr/local/pcre [root@localhost pcre-8.39]# make [root@localhost pcre-8.39]# make install
2、安装openssl [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# mkdir /usr/local/openssl [root@localhost src]# tar xf openssl-1.0.1c.tar.gz
[root@localhost src]# cd openssl-1.0.1c [root@localhost openssl-1.0.1c]# ./config --prefix=/usr/local/openssl
[root@localhost openssl-1.0.1c]# make
[root@localhost openssl-1.0.1c]# make install // 注(如出语法错误 解决rm /usr/bin/pod2man) [root@localhost ~]# vim /etc/profile //添加下面内容 export PATH=$PATH:/usr/local/openssl/bin
[root@localhost ~]# source /etc/profile
3、安装zlib [root@localhost ~]# cd /usr/local/src/
[root@localhost src]# mkdir /usr/local/zlib
[root@localhost src]# tar xf zlib-1.2.8.tar.gz
[root@localhost src]# cd zlib-1.2.8
[root@localhost zlib-1.2.8]# ./configure --prefix=/usr/local/zlib
[root@localhost zlib-1.2.8]# make
[root@localhost zlib-1.2.8]# make install
4、安装Nginx [root@localhost ~]# groupadd www
[root@localhost ~]# useradd -g www www -s /bin/false
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# tar xf nginx-1.10.2.tar.gz
[root@localhost src]# cd nginx-1.10.2
[root@localhost nginx-1.10.2]# ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1c --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.39
注意:--with-openssl=/usr/local/src/openssl-1.0.1c --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.39指向的是源码包解压的路径,而不是安装的路径,否则会报错 [root@localhost nginx-1.10.2]# make
[root@localhost nginx-1.10.2]# make install
[root@localhost nginx-1.10.2]# /usr/local/nginx/sbin/nginx //#启动Nginx
[root@localhost nginx-1.10.2]# vim /etc/rc.d/init.d/nginx // #设置nginx开机启动 编辑启动文件添加下面内容
保存退出 [root@localhost nginx-1.10.2]# chmod 775 /etc/rc.d/init.d/nginx //赋予文件执行权限
[root@localhost nginx-1.10.2]# chkconfig nginx on //设置开机启动
[root@localhost nginx-1.10.2]# /etc/rc.d/init.d/nginx restart //重启
在浏览器中打开服务器IP地址,会看到下面的界面,说明Nginx安装成功。 file:///C:\Users\56916\AppData\Local\Temp\ksohtml\wpsA9F9.tmp.jpg 三、安装php 1、安装yasm [root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar xf yasm-1.3.0.tar.gz
[root@localhost src]# cd yasm-1.3.0
[root@localhost yasm-1.3.0]# ./configure
[root@localhost yasm-1.3.0]# make
[root@localhost yasm-1.3.0]# make install
2、安装libmcrypt [root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar xf libmcrypt-2.5.8.tar.gz
[root@localhost src]# cd libmcrypt-2.5.8
[root@localhost libmcrypt-2.5.8]# ./configure
[root@localhost libmcrypt-2.5.8]# make
[root@localhost libmcrypt-2.5.8]# make install
3、安装libvpx [root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar xf libvpx-1.6.0.tar.bz2
[root@localhost src]# cd libvpx-1.6.0
[root@localhost libvpx-1.6.0]# ./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
[root@localhost libvpx-1.6.0]# make
[root@localhost libvpx-1.6.0]# make install
4、安装tiff [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf tiff-4.0.6.tar.gz [root@localhost src]# cd tiff-4.0.6 [root@localhost tiff-4.0.6]# ./configure --prefix=/usr/local/tiff --enable-shared [root@localhost tiff-4.0.6]# make [root@localhost tiff-4.0.6]# make install 5、安装libpng [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf libpng-1.6.26.tar.gz [root@localhost src]# cd libpng-1.6.26 [root@localhost libpng-1.6.26]# ./configure --prefix=/usr/local/libpng --enable-shared [root@localhost libpng-1.6.26]# make [root@localhost libpng-1.6.26]# make install 6、安装freetype [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf freetype-2.7.tar.gz [root@localhost src]# cd freetype-2.7 [root@localhost freetype-2.7]# ./configure --prefix=/usr/local/freetype --enable-shared [root@localhost freetype-2.7]# make [root@localhost freetype-2.7]# make install 7、安装jpeg [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf jpegsrc.v9b.tar.gz [root@localhost src]# cd jpeg-9b [root@localhost jpeg-9b]# ./configure --prefix=/usr/local/jpeg --enable-shared [root@localhost jpeg-9b]# make [root@localhost jpeg-9b]# make install 8、安装libgd [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf libgd-2.2.3.tar.gz [root@localhost src]# cd libgd-2.2.3 [root@localhost libgd-2.2.3]# ./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-xpm=/usr/local/libvpx [root@localhost libgd-2.2.3]# make [root@localhost libgd-2.2.3]# make install 9、安装t1lib [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf t1lib-5.1.2.tar.gz [root@localhost src]# cd t1lib-5.1.2 [root@localhost t1lib-5.1.2]# ./configure --prefix=/usr/local/t1lib --enable-shared [root@localhost t1lib-5.1.2]# make without_doc [root@localhost t1lib-5.1.2]# make install 10、安装php 注意:如果系统是64位,请执行以下两条命令,否则安装php会出错(32位系统不需要执行) [root@localhost ~]# ln -s /usr/lib64/libltdl.so /usr/lib/libltdl.so [root@localhost ~]# \cp -frp /usr/lib64/libXpm.so* /usr/lib/ [root@localhost ~]# cd /usr/local/src/ [root@localhost src]# tar xf php-7.0.13.tar.gz [root@localhost src]# cd php-7.0.13 [root@localhost php-7.0.13]# export LD_LIBRARY_PATH=/usr/local/libgd/lib [root@localhost php-7.0.13]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-zlib-dir=/usr/local/zlib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype --enable-mysqlnd [root@localhost php-7.0.13]# make [root@localhost php-7.0.13]# make install [root@localhost php-7.0.13]# cp php.ini-production /usr/local/php/etc/php.ini //复制php配置文件到安装目录 [root@localhost php-7.0.13]# rm -rf /etc/php.ini //删除系统自带配置文件 [root@localhost php-7.0.13]# ln -s /usr/local/php/etc/php.ini /etc/php.ini //添加软链接到 /etc目录 [root@localhost php-7.0.13]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf //拷贝模板文件为php-fpm配置文件 [root@localhost php-7.0.13]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf //添加软连接到 /etc目录 [root@localhost php-7.0.13]# vim /usr/local/php/etc/php-fpm.conf //编辑 17行 ;pid = run/php-fpm.pid //取消前面的分号 保存退出 [root@localhost php-7.0.13]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf // [root@localhost php-7.0.13]#vim /usr/local/php/etc/php-fpm.d/www.conf //编辑 23行 user = www #设置php-fpm运行账号为www 24行 group = www #设置php-fpm运行组为www 设置 php-fpm开机启动 [root@localhost php-7.0.13] # cp /usr/local/src/php-7.0.13/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm //拷贝php-fpm到启动目录 [root@localhost php-5.6.28]# chmod +x /etc/rc.d/init.d/php-fpm //添加执行权限 [root@localhost php-5.6.28]# chkconfig php-fpm on //设置开机启动 [root@localhost php-5.6.28]# vim /usr/local/php/etc/php.ini //编辑配置文件 file:///C:\Users\56916\AppData\Local\Temp\ksohtml\wpsAA0A.tmp.jpg //此行添加以下内容 passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname #列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。 找到202 short_open_tag = Off //改为on支持php短标签 找到359 expose_php = on // 改为Off禁止显示php版本的信息 找到924 date.timezone = // 改为PRC 设置时区 找到1745 opcache.enable=0 //改为1 php支持opcode缓存 找到1748 opcache.enable_cli=1 //改为0 php支持opcode缓存 在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能 保存退出 配置nginx支持php [root@localhost php-5.6.28]# vim /usr/local/nginx/conf/nginx.conf 修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改 user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错 修改45行 index index.html index.htm index.php; #添加index.php # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #修改红色部分 include fastcgi_params; } #注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径 去掉上面各行注释 /etc/init.d/nginx restart #重启nginx service php-fpm start #启动php-fpm 测试篇 [root@localhost ~]# cd /usr/local/nginx/html/ //进入nginx默认网站根目录 [root@localhost html]# rm -rf /usr/local/nginx/html/* //删除默认测试页 [root@localhost html]# vim index.php //新建index.php文件 <?php phpinfo(); ?> [root@localhost html]# chown www.www /usr/local/nginx/html/ -R //设置目录所有者 [root@localhost html]# chmod 700 /usr/local/nginx/html/ -R //设置目录权限 在浏览器中打开服务器IP地址,会看到下面的界面
nginx配置文档.docx
(241.57 KB, 下载次数: 0, 售价: 5 元宝)
|