标签:download lob main determine ice cannot zlib inux profile
熟悉开发环境,可以更好地完成开发工作。
本篇选用最新版本 Apache 2.4 + PHP 7.3 + PostgreSQL 11.2
服务器是 CentOS 7.6,全部编译安装
一、安装 Apache
1、安装包 - http://archive.apache.org/dist/httpd/httpd-2.4.38.tar.gz
2、安装
--------- 安装 pcre ----------
# cd /usr/local/src/
# wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz
# tar -axvf pcre-8.39.tar.gz
# cd pcre-8.39
# ./configure
# make
# make install
--------- 安装 apr ----------
# cd /usr/local/src/
# wget http://mirrors.ocf.berkeley.edu/apache/apr/apr-1.6.5.tar.gz
# tar -zxvf apr-1.6.5.tar.gz
# cd apr-1.6.5
# ./configure
# make
# make install
--------- 安装 apr-util ----------
# cd /usr/local/src/
# wget http://mirrors.ocf.berkeley.edu/apache/apr/apr-util-1.6.1.tar.gz
# tar -zxvf apr-util-1.6.1.tar.gz
# cd apr-util-1.6.1
# ./configure --with-apr=/usr/local/apr
# make
# make install
--------- 安装 Apache ----------
# cd /usr/local/src/
# wget http://archive.apache.org/dist/httpd/httpd-2.4.38.tar.gz
# tar -zxvf httpd-2.4.38.tar.gz
# cd httpd-2.4.38
# ./configure --prefix=/usr/local/apache --with-layout=Apache --enable-rewrite --enable-so --enable-expires --enable-proxy --enable-headers --enable-info --with-apr=/usr/local/apr --with-pcre=/usr/local/pcre
# make
# make install
--------- 设置开机自启动 ----------
systemctl 脚本存放在 /usr/lib/systemd/ 目录中,
Apache 设置为开机不登录即可启动,
# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
# ls /etc/init.d/ | grep httpd
# vim /etc/init.d/httpd
在第一行 #!/bin/sh 下面添加两行,三个数字代表运行、启动、停止的级别
#chkconfig: 345 85 15
#description: Start and stop the Apache HTTP Server
# chkconfig --add /etc/init.d/httpd
# service httpd start
3、遇到的问题
Q1:configure: error: You need a C++ compiler for C++ support.
A1:yum -y install gcc-c++
Q2:xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
A2:yum install expat-devel
Q3:collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.38/support‘
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.38/support‘
make: *** [all-recursive] Error 1
A3:# cp -r apr-1.6.5 httpd-2.4.38/srclib/apr
# cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.38/srclib/apr-util
Q4:AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using 172.26.160.216. Set the ‘ServerName‘ directive globally to suppress this message
A4:将 conf 的 #ServerName localhost:80 注释去掉即可。
二、安装 pgsql
1、安装包 - https://ftp.postgresql.org/pub/source/v11.2/postgresql-11.2.tar.gz
2、创建用户
# useradd postgres
# id postgres
# passwd postgres
3、安装
# cd /usr/local/src/
# wget https://ftp.postgresql.org/pub/source/v11.2/postgresql-11.2.tar.gz
# tar -zxvf postgresql-11.2.tar.gz
# chown -R postgres:postgres postgresql-11.2
# su postgres
$ cd postgresql-11.2
$ ./configure --prefix=/usr/local/postgresql-11.2
$ make
$ su root
# make install
# ln -s /usr/local/postgresql-11.2 /usr/local/pgsql
---------- 设置环境变量 --------------
# su - postgres
$ cd ~
$ vim .bash_profile
添加下面三行,路径改为自己的
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
export PATH=$PATH:$HOME/.local/bin:$PGHOME/bin
$ source .bash_profile
----------- 初始化数据库 ------------------
$ initdb
---------- 启动 psql 服务 ------------
$ pg_ctl -D /usr/local/pgsql/data -l logfile start
----------- 设置开机自启动 ----------
# cd /usr/local/src/postgresql-11.2/contrib/start-scripts
# chmod a+x linux
# cp linux /etc/init.d/postgresql
# chkconfig --add pgsql
# service pgsql start
------------- 连接测试 --------------------
$ psql
4、遇到的问题
Q1:configure: error: readline library not found
A1:$ rpm -qa | grep readline
$ yum -y install -y readline-devel
Q2:configure: error: zlib library not found
A2:yum install zlib-devel
Q3:bash: initdb: command not found
A3:initdb 的路径不对。应该写全路径或设置环境变量
Q4:-bash: psql: command not found
A4:确保 pgsql/bin/ 在环境变量中
三、安装 PHP
1、安装包 - https://www.php.net/distributions/php-7.3.4.tar.gz
2、安装
# cd /usr/local/src/ # wget https://www.php.net/distributions/php-7.3.4.tar.gz # tar -zxvf php-7.3.4.tar.gz # cd php-7.3.4 # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-pgsql=/usr/local/postgresql-11.2/bin --enable-sigchild --enable-mbstring --enable-mbregex --enable-bcmath --enable-sockets --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-zlib-dir --with-cdb --with-openssl --with-curl=/usr/lib/curl-7.62.0 --with-iconv # make # make install --------------- 配置环境变量 --------------------- # vim ~/.bashrc 添加下面三行 PATH=$PATH:$HOME/bin export PATH alias php=/usr/local/php/bin/php # source ~/.bashrc ------------------ 配置文件 -------------------- # cd /usr/local/php # cp /usr/local/src/php-7.3.4/php.ini-development ./lib/php.ini ----------------- httpd.conf 配置 ------------------ mime_module 中追加下面两行 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
# service httpd stop
# service httpd start
3、遇到的问题
Q1:configure: error: libxml2 not found. Please check your libxml2 installation.
A1:yum install libxml2-devel
Q2:configure: error: Cannot find OpenSSL‘s <evp.h>
A2:yum install openssl openssl-devel
Q3:configure: error: cURL version 7.15.5 or later is required to compile php with cURL support
A3:# cd /usr/local/src
wget https://curl.haxx.se/download/curl-7.62.0.tar.gz
# tar -zxvf curl-7.62.0.tar.gz
# cd curl-7.62.0
# ./configure --prefix=/usr/lib/curl-7.62.0
# make
# make install
Q4:configure: error: jpeglib.h not found.
A4:yum install libjpeg libjpeg-devel
Q5:configure: error: png.h not found.
A5:yum install libpng libpng-devel
四、配置域名,测试
。。
标签:download lob main determine ice cannot zlib inux profile
原文地址:https://www.cnblogs.com/rendd/p/11622737.html