标签:enc 语义 unix vim ase gre ror php add
LAM(M)P:
WEB资源类型:
Web相关语言:
CGI:Common Gateway Interface 通用网关接口;可以让一个客户端,从网页浏览器通过http服务器向执行在网络服务器上的程序传输数据;CGI描述了客户端和服务器程序之间传输的一种标准
php:通用服务器端脚本编程语言,主要用于web开发实现动态web页面,也是最早实现将脚本嵌入HTML源码文档中的服务器端脚本语言之一。同时,php还提供了一个命令行接口,因此其也可以在大多数系统上作为一个独立的shell来使用
Zend Engine:PHP脚本语言的解释器,它最早是由以色列理工学院(Technion)的学生Andi Gutmans和Zeev Suraski所开发,Zend也正是此二人名字的合称。后来两人联合创立了Zend Technologies公司。Zend Engine的出现将PHP代码的处理过程分成了两个阶段:首先是分析PHP代码并将其转换为称作Zend opcode的二进制格式(类似Java的字节码),并将其存储于内存中;第二阶段是使用Zend Engine去执行这些转换后的Opcode。
Opcode:一种PHP脚本编译后的中间语言,类似于Java的ByteCode,或者.NET的MSL。PHP执行PHP脚本代码一般会经过如下4个步骤:扫描-->分析-->编译-->执行
配置文件:/etc/php.ini, /etc/php.d/*.ini
/etc/php.ini配置文件格式:
[foo]:Section Header
directive = value
注释符:较新的版本中,已经完全使用;进行注释
#:纯粹的注释信息
;:用于注释可启用的directive
max_execution_time= 30 最长执行时间30s
memory_limit 128M 生产不够,可调大
display_errors off 调试使用,不要打开,否则可能暴露重要信息
display_startup_errors off 建议关闭
post_max_size 8M 最大上传数据大小,生产可能临时要调大,比下面项要大
upload_max_filesize 2M 最大上传文件,生产可能要调大
max_file_uploads = 20 同时上传最多文件数
date.timezone =Asia/Shanghai 指定时区
short_open_tag=on 开启短标签,如<? phpinfo();?>
参考官方文档:
php.ini的核心配置选项文档:http://php.net/manual/zh/ini.core.php
php.ini配置选项列表:http://php.net/manual/zh/ini.list.php
? 基于PHP的特殊扩展机制如opcode缓存扩展也可以将opcode缓存于php的共享内存中,从而可以让同一段代码的后续重复执行时跳过编译阶段以提高性能。这些加速器并非真正提高了opcode的运行速度,而仅是通过分析opcode后并将它们重新排列以达到快速执行的目的
常见的php加速器有:
? 1)安装
~]# yum install httpd php php-mysql mariadb-server -y
~]# systemctl start httpd mariadb
? 2)测试PHP连接数据库
~]# vim /var/www/html/index.php
<?php
try {
$user='root';
$pass='';
$dbh = new PDO('mysql:host=localhost;dbname=mysql', $user, $pass);
foreach($dbh->query('SELECT user,host from user') as $row) {
print_r($row);
}
$dbh = null;
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
~]# curl 192.168.0.7 #如果返回的是数据库的查询信息则说明成功
~]# rm -f /var/www/html/index.php
? 3)配置数据库
~]# mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password: ******
Re-enter new password: ******
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
... Success!
? 4)编译安装php-xcache
~]# yum groupinstall "Development Tools" -y
~]# yum install php-devel -y
~]# wget http://xcache.lighttpd.net/pub/Releases/2.0.1/xcache-2.0.1.tar.gz
~]# tar xf xcache-2.0.1.tar.gz
~]# cd xcache-2.0.1/
xcache-2.0.1]# phpize #生成configure脚本
xcache-2.0.1]# ./configure --enable-xcache --with-php-config=/usr/bin/php-config
xcache-2.0.1]# make && make install
xcache-2.0.1]# cp xcache.ini /etc/php.d/
xcache-2.0.1]# systemctl restart httpd
/etc/php-fpm.d/www.conf :PHP配置文件
listen = 127.0.0.1:9000 监听端口
listen.allowed_clients = 127.0.0.1 允许客户端的IP
pm.max_children = 50 最多链接数
pm.start_servers = 5 初识启动多少个
pm.min_spare_servers = 5 最小保留空闲进程
pm.max_spare_servers = 35 最大空闲进程
pm.max_requests = 500 最大请求数
参考文档:
? php.ini核心配置的详细说明: http://php.net/manual/zh/ini.core.php
Php.ini配置选项列表: http://php.net/manual/zh/ini.list.php
[root@centos7 ~]# yum install httpd php-fpm php-mysql mariadb-server -y
[root@centos7 ~]# systemctl enable httpd php-fpm mariadb
[root@centos7 ~]# httpd -M |grep fcgi #确保fcgi模块启用
proxy_fcgi_module (shared)
[root@centos7 ~]# vim /etc/httpd/conf.d/fcgi.conf #加入以下配置
DirectoryIndex index.php
ProxyRequests Off #关闭正向代理
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1 #将请求php资源的请求发送给PHP进程
[root@centos7 ~]# systemctl start httpd php-fpm mariadb
环境:
linux:CentOS7.5
Apache:apr-1.6.3、apr-util-1.6.1、httpd-2.4.33
MariaDB:mariadb-10.2.15
PHP:php-7.1.18
? 1)检查环境并准备安装包
[root@centos7 src]# yum -y groupinstall "Development Tools"
[root@centos7 src]# yum -y install openssl-devel expat-devel pcre-devel libxml2-devel bzip2-devel libmcrypt-devel bison-devel boost-devel cmake gnutls-devel libaio-devel libarchive-devel libcurl-devel libevent-devel ncurses-devel #注意:需要配置epel源
[root@centos7 src]# wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.3.tar.gz
[root@centos7 src]# wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
[root@centos7 src]# wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
[root@centos7 src]# wget http://sfo1.mirrors.digitalocean.com/mariadb//mariadb-10.2.15/source/mariadb-10.2.15.tar.gz
[root@centos7 src]# wget http://mirrors.sohu.com/php/php-7.1.18.tar.gz
? 2)编译安装Apache,并配置
[root@centos7 src]# useradd -r -s /sbin/nologin apache
[root@centos7 src]# tar xf apr-1.6.3.tar.gz
[root@centos7 src]# tar xf apr-util-1.6.1.tar.gz
[root@centos7 src]# tar xf httpd-2.4.33.tar.gz
[root@centos7 src]# cp -a apr-util-1.6.1 httpd-2.4.33/srclib/apr-util
[root@centos7 src]# cp -a apr-1.6.3 httpd-2.4.33/srclib/apr
[root@centos7 src]# cd httpd-2.4.33
[root@centos7 httpd-2.4.33]# ./configure --prefix=/lamp/application/httpd24 > --enable-so > --enable-ssl > --enable-cgi > --enable-rewrite > --with-zlib > --with-pcre > --with-included-apr > --enable-modules=most > --enable-mpms-shared=all > --with-mpm=prefork
[root@centos7 httpd-2.4.33]# make -j 4 && make install
[root@centos7 httpd-2.4.33]# vim /lamp/application/httpd24/conf/httpd.conf #修改httpd配置文件
ServerName www.example.com:80
User apache
Group apache
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #启用cfgi模块
LoadModule proxy_module modules/mod_proxy.so #启用代理模块
<IfModule dir_module>
DirectoryIndex index.php index.html #加入index.php
</IfModule>
-----> 插入以下内容 <-----
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/lamp/application/httpd24/htdocs/$1 #注意此处路径
[root@centos7 src]# echo 'PATH=/lamp/application/httpd24/bin/:$PATH' > /etc/profile.d/httpd.sh
[root@centos7 src]# . /etc/profile.d/httpd.sh
[root@centos7 src]# apachectl start
[root@centos7 src]# curl 127.0.0.1/index.html
It works! #看到It works!表示工作正常
? 3)编译安装MariaDB,并配置
[root@centos7 src]# useradd -r -s /sbin/nologin -d /lamp/data/mysqldb mysql
[root@centos7 src]# mkdir -p /lamp/data/mysqldb
[root@centos7 src]# chown -R mysql.mysql /lamp/data/mysqldb/
[root@centos7 src]# tar xf mariadb-10.2.15.tar.gz
[root@centos7 mariadb-10.2.15]# cd mariadb-10.2.15/
[root@centos7 mariadb-10.2.15]# cmake . -DCMAKE_INSTALL_PREFIX=/lamp/application/mysql > -DMYSQL_DATADIR=/lamp/data/mysqldb/ > -DMYSQL_UNIX_ADDR=/lamp/data/mysqldb/mysql.sock > -DSYSCONFDIR=/etc > -DMYSQL_USER=mysql > -DWITH_INNOBASE_STORAGE_ENGINE=1 > -DWITH_ARCHIVE_STORAGE_ENGINE=1 > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 > -DWITH_PARTITION_STORAGE_ENGINE=1 > -DWITHOUT_MROONGA_STORAGE_ENGINE=1 > -DWITH_DEBUG=0 > -DWITH_READLINE=1 > -DWITH_SSL=system > -DWITH_ZLIB=system > -DWITH_LIBWRAP=0 > -DENABLED_LOCAL_INFILE=1 > -DDEFAULT_CHARSET=utf8 > -DDEFAULT_COLLATION=utf8_general_ci
[root@centos7 mariadb-10.2.15]# make -j4 && make install
[root@centos7 mariadb-10.2.15]# echo 'export PATH=/lamp/application/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
[root@centos7 mariadb-10.2.15]# . /etc/profile.d/mysql.sh
[root@centos7 mariadb-10.2.15]# cd /lamp/application/mysql/
[root@centos7 mysql]# scripts/mysql_install_db --datadir=/lamp/data/mysqldb/ --user=mysql --basedir=/lamp/application/mysql/
[root@centos7 mysql]# cp support-files/my-huge.cnf /etc/my.cnf
[root@centos7 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@centos7 mysql]# chkconfig --add mysqld
[root@centos7 mysql]# chkconfig mysqld on
[root@centos7 mysql]# service mysqld start
[root@centos7 mysql]# mysql
Server version: 10.2.15-MariaDB-log Source distribution
MariaDB [(none)]> #成功连接mysql
? 4)编译安装php,并配置
[root@centos7 src]# tar xf php-7.1.18.tar.gz
[root@centos7 src]# cd php-7.1.18/
[root@centos7 php-7.1.18]# ./configure --prefix=/lamp/application/php7 > --enable-mysqlnd > --with-mysqli=mysqlnd > --with-openssl > --with-pdo-mysql=mysqlnd > --enable-mbstring > --with-freetype-dir > --with-jpeg-dir > --with-png-dir > --with-zlib > --with-libxml-dir=/usr > --enable-xml > --enable-sockets > --enable-fpm > --with-config-file-path=/etc > --with-config-file-scan-dir=/etc/php.d > --enable-maintainer-zts > --disable-fileinfo
[root@centos7 php-7.1.18]# make -j 4 && make install
[root@centos7 php-7.1.18]# cp php.ini-production /etc/php.ini
[root@centos7 php-7.1.18]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@centos7 php-7.1.18]# chmod +x /etc/init.d/php-fpm
[root@centos7 php-7.1.18]# chkconfig --add php-fpm
[root@centos7 php-7.1.18]# chkconfig php-fpm on
[root@centos7 php-7.1.18]# cd /lamp/application/php7/
[root@centos7 php7]# cp etc/php-fpm.conf.default etc/php-fpm.conf
[root@centos7 php7]# cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
[root@centos7 php-fpm.d]# vim etc/php-fpm.d/www.conf
user = apache
group = apache
[root@centos7 php7]# echo 'PATH=/lamp/application/php7/bin:/lamp/application/php7/sbin:$PATH' > /etc/profile.d/php-fpm.sh
[root@centos7 php7]# . /etc/profile.d/php-fpm.sh
[root@centos7 php7]# service php-fpm start
[root@centos7 php7]# ss -tnl |grep 9000
LISTEN 0 128 127.0.0.1:9000 #9000端口已监听
? 5)测试lamp
[root@centos7 ~]# vim /lamp/application/httpd24/htdocs/test.php
<?php
$dsn='mysql:host=127.0.0.1;dbname=mysql';
$username='root';
$passwd='';
$dbh=new PDO($dsn,$username,$passwd);
var_dump($dbh);
?>
[root@centos7 ~]# curl 127.0.0.1/test.php
object(PDO)#1 (0) {} #如果返回PDO则说明成功
[root@centos7 ~]# rm -f /lamp/application/httpd24/htdocs/test.php
~]# wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.20/phpMyAdmin-4.0.10.20-all-languages.zip
~]# unzip phpMyAdmin-4.0.10.20-all-languages.zip
~]# mv phpMyAdmin-4.0.10.20-all-languages /var/www/html/pma
~]# cd /var/www/html/pma
pma]# cp config.sample.inc.php config.inc.php
pma]# yum install php-mbstring -y
pma]# systemctl restart httpd
访问:http://192.168.0.7/pma/
按照提示输入用户名密码(数据库的管理用户)等
[root@centos7 ~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE wpdb;
MariaDB [(none)]> GRANT ALL ON wpdb.* TO wpuser@'192.168.0.%' IDENTIFIED BY 'wppass';
[root@centos7 ~]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
[root@centos7 ~]# tar xf wordpress-4.9.4-zh_CN.tar.gz -C /var/www/html/
[root@centos7 ~]# chown -R apache:apache /var/www/html/wordpress/
访问:http://192.168.0.7/wordpress/
,按提示填入相应信息
? 1)配置虚拟主机
[root@centos7 ~]# cd /lamp/application/httpd24/conf/
[root@centos7 conf]# vim httpd.conf
#ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/lamp/application/httpd24/htdocs/$1 #将此行注释掉
Include conf/extra/httpd-vhosts.conf #将此行启用
[root@centos7 conf]# vim extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/lamp/data/www/wordpress"
ServerName blog.dongfei.com
ErrorLog "logs/blog.dongfei.com-error_log"
CustomLog "logs/blog.dongfei.com-access_log" common
<Directory "/lamp/data/www/wordpress">
Require all granted
</Directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/lamp/data/www/wordpress/$1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/lamp/data/www/discuz"
ServerName bbs.dongfei.com
ErrorLog "logs/bbs.dongfei.com-error_log"
CustomLog "logs/bbs.dongfei.com-access_log" common
<Directory "/lamp/data/www/discuz">
Require all granted
</Directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/lamp/data/www/discuz/$1
</VirtualHost>
[root@centos7 ~]# mkdir -p /lamp/data/www/{wordpress,discuz}
[root@centos7 ~]# apachectl restart
? 2)配置数据库
MariaDB [(none)]> CREATE DATABASE discuzdb;
MariaDB [(none)]> GRANT ALL ON discuzdb.* TO duser@'192.168.0.%' IDENTIFIED BY 'dpass';
MariaDB [(none)]> CREATE DATABASE wordpressdb;
MariaDB [(none)]> GRANT ALL ON wordpressdb.* TO wuser@'192.168.0.%' IDENTIFIED BY 'wpass';
? 3)部署Discuz
[root@centos7 src]# wget http://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_UTF8.zip
[root@centos7 src]# unzip Discuz_X3.3_SC_UTF8.zip
[root@centos7 src]# mv upload/* /lamp/data/www/discuz/
[root@centos7 src]# setfacl -R -m u:apache:rwx /lamp/data/www/discuz/
访问:http://bbs.dongfei.com
,按照提示填入相应信息
? 4)部署WordPress
[root@centos7 src]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
[root@centos7 src]# tar xf wordpress-4.9.4-zh_CN.tar.gz
[root@centos7 src]# mv wordpress/* /lamp/data/www/wordpress/
[root@centos7 src]# setfacl -R -m u:apache:rwx /lamp/data/www/wordpress/
访问:http://blog.dongfei.com
,按照提示填入相应信息
#!/bin/bash
# -----------------------------------------
# Filename: lamp_yum.sh
# Revision: 1.0v
# Date: 2018-06-23
# Author: LiDongfei
# Email: 652117746@qq.com
# Website: www.cnblogs.com/L-dongf
# Description: This is the lamp_yum script
# -----------------------------------------
# Copyright: @2018 Dongfei
# License: GPL
# kernel: 3.10.0-862.el7.x86_64
# linux: CentOS 7.5
# Apache: 2.4.6
# MariaDB: 5.5.56
# PHP: 5.4.16
# xcache: 2.0.1
# Way of working: Modules
check() {
if [ $? -eq 0 ]; then
echo -e "\033[32mOK!\033[0m"
else
echo -e "\033[31mError!\033[0m"
exit
fi
}
# install software
yum install -y httpd php php-mysql mariadb-server
check
# start service
systemctl start httpd mariadb
check
# make and make install php-xcache
yum groupinstall "Development Tools" -y
check
yum install php-devel -y
check
mkdir /root/src
cd /root/src
wget http://xcache.lighttpd.net/pub/Releases/2.0.1/xcache-2.0.1.tar.gz
check
tar xf xcache-2.0.1.tar.gz
cd xcache-2.0.1/
phpize
./configure --enable-xcache --with-php-config=/usr/bin/php-config
make && make install
cp -n xcache.ini /etc/php.d/
systemctl restart httpd
# output info log
echo -e "\033[32mInstall LAMP Completed!\033[0m"
软件安装目录:/lamp/application/
数据库库目录:/lamp/data/mysqldb
#!/bin/bash
# -----------------------------------------
# Filename: lamp_make.sh
# Revision: 1.0v
# Date: 2018-06-23
# Author: LiDongfei
# Email: 652117746@qq.com
# Website: www.cnblogs.com/L-dongf
# Description: This is the lamp_make script
# -----------------------------------------
# Copyright: @2018 Dongfei
# License: GPL
trap 'exit' 2
clear
echo '# Kernel: 3.10.0-862.el7.x86_64'
echo '# Linux: CentOS 7.5'
echo '# Apr: 1.6.3'
echo '# Apr-util: 1.6.1'
echo '# Apache: 2.4.33'
echo '# MariaDB: 10.2.15'
echo '# PHP: 7.1.18'
echo '# Way of working: FastCGI'
read -p "Press any key to start...or Press Ctrl+C to cancel" tmpvar
cpus=`cat /proc/cpuinfo |grep processor |wc -l`
check() {
if [ $? -eq 0 ]; then
echo -e "\033[32mOK!\033[0m"
else
echo -e "\033[31mError!\033[0m"
exit
fi
}
# check yum package
yum -y groupinstall "Development Tools"
check
yum -y install openssl-devel expat-devel pcre-devel libxml2-devel bzip2-devel bison-devel boost-devel cmake gnutls-devel libaio-devel libarchive-devel libcurl-devel libevent-devel ncurses-devel
check
yum -y install libmcrypt-devel
check
# Get source code
mkdir /root/src
cd /root/src
wget http://mirror.bit.edu.cn/apache//apr/apr-1.6.3.tar.gz
check
wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
check
wget http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
check
wget http://sfo1.mirrors.digitalocean.com/mariadb//mariadb-10.2.15/source/mariadb-10.2.15.tar.gz
check
#wget http://mirrors.sohu.com/php/php-7.1.18.tar.gz
wget http://php.net/get/php-7.1.18.tar.gz/from/this/mirror -O php-7.1.18.tar.gz
check
# ============================ Apache ============================
# make and make install httpd, configure httpd.conf
! id apache &>/dev/null && useradd -r -s /sbin/nologin apache
cd /root/src/
tar xf apr-1.6.3.tar.gz
tar xf apr-util-1.6.1.tar.gz
tar xf httpd-2.4.33.tar.gz
cp -a apr-util-1.6.1 httpd-2.4.33/srclib/apr-util
cp -a apr-1.6.3 httpd-2.4.33/srclib/apr
check
# 1)make httpd
cd httpd-2.4.33
./configure --prefix=/lamp/application/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make -j $cpus && make install
check
# 2)configure httpd
httpd_conf_file='/lamp/application/httpd24/conf/httpd.conf'
sed -i.bak -r '/ServerName www.example.com/s/#(.*)/\1/' $httpd_conf_file
sed -i.bak -r '/^(User|Group)/s/(.* ).*/\1apache/' $httpd_conf_file
sed -i.bak -r '/proxy_fcgi_module/s/#(.*)/\1/' $httpd_conf_file
sed -i.bak -r '/proxy_module/s/#(.*)/\1/' $httpd_conf_file
sed -i.bak -r 's/( *DirectoryIndex )index.html/\1index.php index.html/' $httpd_conf_file
cat >> $httpd_conf_file <<EOF
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/lamp/application/httpd24/htdocs/$1
EOF
echo 'PATH=/lamp/application/httpd24/bin/:$PATH' > /etc/profile.d/httpd.sh
/lamp/application/httpd24/bin/apachectl start
check
echo "configure httpd is OK!"
# ============================ MariaDB-server ============================
# make and make install MariaDB-server, configure mysqld
# 1)make and install
dbdir='/lamp/data/mysqldb/'
insdir='/lamp/application/mysql/'
! id mysql &>/dev/null && useradd -r -s /sbin/nologin -d $dbdir mysql
mkdir -p $dbdir
chown -R mysql.mysql $dbdir
cd /root/src/
tar xf mariadb-10.2.15.tar.gz
cd mariadb-10.2.15/
cmake . -DCMAKE_INSTALL_PREFIX=$insdir -DMYSQL_DATADIR=$dbdir -DMYSQL_UNIX_ADDR=${dbdir}mysql.sock -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITHOUT_MROONGA_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
check
make -j $cpus && make install
check
echo 'export PATH=/lamp/application/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
# 2)configure mysql
cd $insdir
scripts/mysql_install_db --datadir=$dbdir --user=mysql --basedir=$insdir
check
cp -f support-files/my-huge.cnf /etc/my.cnf
cp -f support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
check
${insdir}bin/mysql -e "DELETE FROM mysql.user WHERE user=''"
check
# ============================ PHP ============================
# make and make install PHP, configure php.ini
# 1)make and install
cd /root/src/
tar xf php-7.1.18.tar.gz
cd php-7.1.18/
./configure --prefix=/lamp/application/php7 --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo
check
make -j $cpus && make install
check
# 2)configure php
cp php.ini-production /etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cd /lamp/application/php7/
cp etc/php-fpm.conf.default etc/php-fpm.conf
cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
sed -i.bak -r '/^(user|group)/s/(.* ).*/\1apache/' etc/php-fpm.d/www.conf
echo 'PATH=/lamp/application/php7/bin:/lamp/application/php7/sbin:$PATH' > /etc/profile.d/php-fpm.sh
service php-fpm start
check
ss -tnl |grep -q 9000 && echo "install PHP complete!"
# test lamp
cat >> /lamp/application/httpd24/htdocs/test.php <<EOF
<?php
\$dsn='mysql:host=127.0.0.1;dbname=mysql';
\$username='root';
\$passwd='';
\$dbh=new PDO(\$dsn,\$username,\$passwd);
var_dump(\$dbh);
?>
EOF
curl 127.0.0.1/test.php |grep -q PDO && echo -e "\033[32mLAMP Test Completed, Is Working!\033[0m" || echo -e "\033[31mSorry, Test failed, Please check!\033[0m"
标签:enc 语义 unix vim ase gre ror php add
原文地址:https://www.cnblogs.com/L-dongf/p/9218291.html