PHP环境搭建
数据库 环境搭建    2019-05-06 06:51:53    52    0    0

1.安装httpd

下载并安装apr(Apache Portable Runtime )

tar zxvf apr-1.5.1.tar.gz 
./configure --prefix=/home/xxx/programs/apr
make
make install​


下载并安装apr-util

./configure --prefix=/home/xxx/programs/apr-util --with-apr=/home/xxx/programs/apr
make 
make install​


下载并安装pcre(Perl Compatible Regular Expressions)

./configure --prefix=/home/xxx/programs/pcre
make
make install​


下载并安装httpd

tar -zxvf httpd-2.4.12.tar.gz
./configure --prefix=/home/xxx/programs/httpd --enable-so --enable-rewrite --with-apr=/home/xxx/programs/apr --with-apr-util=/home/xxx/programs/apr-util --with-pcre=/home/xxx/programs/pcre
make
make install​

or

./configure --prefix=/root/programs/httpd2.2 --enable-ssl --enable-cgi --enable-rewrite --enable-zip --with-zlib --with-pcre --with-apr=/usr --enable-mbstring --with-apr-util=/usr --enable-modules=most --enable-mpms-shared=all​


启动httpd

sudo ./apachectl start​


2.安装mysql

x64下安装libaio1
apt search libaio
sudo apt-get install libaio1
sudo apt-get install libaio-dev
tar zxvf mysql-5.6.23-linux-glibc2.5-i686.tar.gz 
mv mysql-5.6.23-linux-glibc2.5-i686 /home/xxx/programs/mysql
cd /home/xxx/programs/mysql/
./scripts/mysql_install_db --user=mysql --basedir=/home/xxx/programs/mysql --datadir=/home/xxx/programs/mysql/data --defaults-file=/home/xxx/programs/mysql/support-files/my-default.cnf​


启动mysql

./bin/mysqld --basedir=. --user=mysql&​


设置初始密码

./mysqladmin -u root password ​


授权root帐号远程登陆

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'login_password' WITH GRANT OPTION;​


shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server​


3.安装php

下载并安装libxml2(php依赖)

./configure --prefix=/home/xxx/programs/libxml2
make
make install​


下载并安装zlib(php依赖)

./configure --prefix=/home/xxx/programs/zlib
make
make install​


下载并安装openssl(composer,https依赖)

./config --prefix=/home/xxx/programs/openssl -fPICmake
make install​


下载并安装libmcrypt(mcrypt依赖)ubuntu 自带2.5.8需移除

sudo apt-get remove libmcrypt4
./configure 
Sudo Make
Sudo Make install
Sudo Ldconfig (更新库信息)​


下载并安装Libmhash(mcrypt依赖)

./configure 
Sudo Make
Sudo make install​


下载并安装mcrypt(laravel加密依赖)

sudo ./configure --prefix=/home/xxx/programs/mcrypt --with-libmcrypt-prefix=/usr/local
Sudo make
Sudo make install​


下载并安装php

./configure --prefix=/home/xxx/programs/php --with-mysql=/home/xxx/programs/mysql --with-apxs2=/home/xxx/programs/httpd/bin/apxs --with-libxml-dir=/home/xxx/programs/libxml2 --with-zlib-dir=/home/xxx/programs/zlib --with-openssl=/home/xxx/programs/openssl --with-mcrypt=/home/xxx/programs/mcrypt --enable-mbstring --enable-zip --with-pdo-mysql=/home/xxx/programs/mysql
make
make install​

centos7 with PostgreSQL

yum install libpqxx
yum install libpqxx-devel
yum install bzip2-devel
yum install libmcrypt-devel
yum install libcurl libcurl-devel
 yum install gd gd-devel
./configure --prefix=/root/programs/php5.6 --with-libxml-dir=/root/programs/libxml2 --with-apxs2=/root/programs/httpd2.2/bin/apxs  --with-pdo-pgsql=/usr/pgsql-9.4 --with-pgsql=/usr/pgsql-9.4 --enable-mbstring --enable-zip --with-zlib --enable-xml --enable-sockets --with-mcrypt --with-bz2 --with-openssl --with-gd --with-curl -enable-maintainer-zts --with-config-file-path=/root/programs/php5.6/etc


 


4.配置环境

1.修改httpd.conf
添加

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps ​


添加index.php支持

DirectoryIndex index.php index.html​


启用

LoadModule rewrite_module modules/mod_rewrite.so​


2.启用虚拟主机
启用httpd.conf配置

LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf​


修改httpd-vhosts.conf

listen 8888
NameVirtualHost *:8888
<Directory "/home/xxx/workspace/php/test">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<VirtualHost *:8888>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/home/xxx/workspace/php/test"
ServerName www.phptest.com
ErrorLog "logs/test-error_log"
CustomLog "logs/test-access_log" common
</VirtualHost>​


3.添加php.ini

cp php-5.3.8/php.ini.dist /home/xxx/programs/php/lib/php.ini ​


修改php.ini

date.timezone =Asia/Shanghai ​


下载证书
地址 http://curl.haxx.se/docs/caextract.html
保存 Cacert.pem
修改php.ini

openssl.cafile=/home/xxx/programs/php/cacert.pem​

 

Pre: SVN环境搭建

Next: ELK环境搭建

52
Sign in to leave a comment.
No Leanote account? Sign up now.
0 comments
Table of content