直接进入正题,全部手动编译安装
一、安装nginx
去官网nginx.org找到nginx1.14.0的稳定版的下载地址下载、解压、进目录、预编译:
wget http://nginx.org/download/nginx-1.14.0.tar.gz tar -zxvf nginx-1.14.0.tar.gz cd nginx-1.14.0 ./configure --prefix=/usr/local/nginx
补充一点./configure手动编译的知识: 1、./configure 是用来检测你的安装平台的目标特征的。它是个shell脚本。 2、make 是用来编译的,它从Makefile中读取指令,然后编译。 3、make install是用来安装的,它也从Makefile中读取指令,安装到指定的位置。 参考:https://www.cnblogs.com/tinywan/p/7230039.html
报错了
./configure: error: C compiler cc is not found
这是因为没有安装gcc编译器导致的,那么安装gccyum install -y gcc
安装完之后在预编译,报错
./configure: error: the HTTP rewrite module requires the PCRE library.
pcre是一个正则库,安装nginx所需要的pcre-devel库,是为了是Nginx支持http Rewrite模块。(zlib被依赖 同理安装)
yum install -y pcre-devel zlib-devel
拓展一点-devel库的知识: linux里面 包-devel 比较常见,之前一直有疑问devel是个啥子 现在摘抄过来 devel 是development的缩写 devel 包主要是供开发用,至少包括以下2个东西: 1. 头文件 2. 链接库 有的还含有开发文档或演示代码。 以 glib 和 glib-devel 为例: 如果你安装基于 glib 开发的程序,只需要安装 glib 包就行了。 但是如果你要编译使用了 glib 的源代码,则需要安装 glib-devel。 Linux系统镜像中有xxx包未必有xxx-devel包 参考:https://blog.youkuaiyun.com/qq_21127313/article/details/62217348
安装完上诉gcc和依赖库后再./configure 很顺利完成了,同时本目录下多了个Makefile文件,接下来正式编译安装
make make install
安装结束,那么nginx就被安装到了/usr/local/nginx目录下面来了
去nginx目录执行./sbin/nginx 同时关闭一下防火墙 service firewalld stop
访问一下外网ip 可以看到舒服的Welcome!!
二、安装php
去php.net 找到php7.0的地址(虽然下载下来似乎不是tar.gz后缀文件但是丝毫不影响解压,在linux里面 后缀就是样= =)
wget http://cn2.php.net/get/php-7.0.31.tar.gz/from/this/mirror
php的安装见这里的官方中文说明文档,已经很清晰了!
说明文档:http://www.php.net/manual/zh/install.unix.nginx.php
在弄./configure 的时候遇到错误
configure: error: xml2-config not found. Please check your libxml2 installation.
都说了是not found 差什么安什么
值得一提的是安装的是 yum install -y libxml2-devel 很熟悉吧-devel开发包= =
vps内存<=512MB的机器编译安装php的时候会遇到 内存不足的错误: virtual memory exhausted: Cannot allocate memory 解决方法:php安装配置文件中加了引号中的配置(不包括引号)“–disable-fileinfo”后终于编译通过。这里分享出来供参考。 即:./configure --enable-fpm --with-mysql -disable-fileinfo 参考:https://blog.youkuaiyun.com/risingsun001/article/details/43705273
三、安装mysql
吃藕哭了,今天连mysql的源码包都找了一个下午
说到底 还是底子不扎实还没学爬就想走 已经不好好看官方文档导致的...
先贴上我找到的俩个很不错的手动编译安装mysql的文档链接1:https://dev.mysql.com/doc/refman/5.7/en/source-installation.html
链接2:http://howtolamp.com/lamp/mysql/5.6/installing/
首先去找源码包:
Let us goto http://dev.mysql.com/downloads/. On the top of page, click on theDownloads tab, which will take us to the download page listing different MySQL projects. Below MySQL Community Server, click on the DOWNLOAD link, which will take us to the download page. We will see a list of Generally Available (GA) Releases. Select Platform asSource Code. Scroll to the bottom and we will see Generic Linux (Architecture Independent), Compressed TAR Archive. Click the Download button, which will take us to a page where we can Login/SignUp with an Oracle Web account. If you want, you can. But I chose to click on No thanks, just start my download.. This will start the download.
去那个网站-Downloads-Community-左边栏mysql Community Server-然后选5.6 5.7 7.0 8.0里面的一个-Select Operating System那栏:Source Code-会跳出来一个Select OS Version:-选择Generic Linux(注意有版本号和试用平台的版本都是非源码包版,就是已经编译过的rpm或者tar包 不是我们要找的,我们需要找没编译过的源码包 后缀是tar.gz)
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.41.tar.gz|tar -zxvf mysql-5.6.41.tar.gz
cd mysql->tab
cmake .
补充:很奇怪 这里居然是cmake编译的(没有的话yum install -y cmake一下) CMake, which is used as the build framework on all platforms. CMake can be downloaded from http://www.cmake.org. 注意:The default install directory is /usr/local/mysql/. If you want to change it, use the optionCMAKE_INSTALL_PREFIX
报错:
CMake Error at cmake/readline.cmake:85 (MESSAGE):
Curses library not found. Please install appropriate package, remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
可以看到是缺少了ncurses-devel 那么yum install一下
yum install -y ncurses-devel包后,删除CMakeCache.txt,然后重新编译,编译成功,问题解决!
呃。。并没有
-- Could NOT find Git (missing: GIT_EXECUTABLE)
没有找到Git 那么yum install -y git 删除CMakeCache.txt再来
汇总一下依赖软件 yum install -y zlib zlib-devel openssl openssl-devel valgrind valgrind-devel cmake gcc cpp ncurses ncurses-devel bison gcc-c++
完事make &&make install
最后结束可以看到mysql被安装到/usr/local/mysql 下面
添加service mysql start启动:
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql /etc/init.d/mysql start
然后启动的时候报错了:
Starting MySQL.Logging to '/data/JDYun.err'. .. ERROR! The server quit without updating PID file (/data/JDYun.pid). 那么就去看他说的/data/JDYun.err 看完发现 error部分 说的就是permission denied 总结:MySQL服务不具备目录 /var/lib/mysql 的写入权限,无法生成mysql.sock文件,自然服务启动时无法找到该文件。 给目录 /var/lib/mysql 付予写入权限或者最大权限—chmod 777 /var/lib/mysql 参考:https://blog.youkuaiyun.com/qq_32331073/article/details/76229420