接上篇:http://wskfnso.blog.51cto.com/4025557/1761877
二:安装mariadb10.0.24
1:安装mariadb,获取源程序、解压、创建软连接
[root@master1 ~]# tar xf mariadb-10.0.24-linux-x86_64.tar.gz -C /usr/local/
[root@master1 ~]# cd /usr/local/
[root@master1 local]# ln -sv mariadb-10.0.24-linux-x86_64 mysql
`mysql' -> `mariadb-10.0.24-linux-x86_64'
2:创建mysql系统用户和组
[root@master1 local]# groupadd -r mysql
[root@master1 local]# useradd -r -g mysql mysql -s /sbin/nologin
3:建立数据目录 存放数据,并把数据目录改为mysql用户和组
[root@master1 local]# mkdir -pv /mydata/data
[root@master1 local]# chown -R mysql.mysql /mydata/data/
4:安装数据库
[root@master1 mysql]# scripts/mysql_install_db --datadir=/mydata/data/ --user=mysql --basedir=/usr/local/mysql/
5:为mysql 提供配置文件,并修改如下
[root@master1 mysql]# cp support-files/my-large.cnf /etc/my.cnf
thread_concurrency = 2 //改成cpu的两倍
basedir = /usr/local/mysql //数据库安装目录
datadir = /mydata/data //数据目录
innodb_file_per_table = on //打开innodb引擎
skip_name_resolve = on //跳过DNS解析
6:提供启动脚本,并使其开机自启动
[root@master1 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@master1 mysql]# chkconfig --add mysqld
[root@master1 mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7:启动mysql
[root@master1 mysql]# service mysqld start
8:修改头文件和库文件
(1):输出mysql的头文件至系统头文件路径/usr/include:
# ln -sv /usr/local/mysql/include /usr/include/mysql
(2):输出mysql的库文件给系统库查找路径:
# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
而后让系统重新载入系统库:
# ldconfig
# ldconfig -p | grep 'mysql'
(3):修改PATH环境变量,让系统可以直接使用mysql的相关命令
在/etc/profile.d/目录下建立mysql.sh文件! 写入如下内容:
export PATH=/usr/local/mysql/bin:$PATH
# source mysql.sh
# touch /etc/profile.d/mysql.sh
# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
# source mysql.sh
9:删除密码用户:
mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ''@'localhost.localdomain';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user 'root'@'localhost.localdomain';
Query OK, 0 rows affected (0.00 sec)
mysql> drop user 'root'@'::1';
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'localhost'=password('123456');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for 'root'@'127.0.0.1'=password('123456');
Query OK, 0 rows affected (0.00 sec)
三:安装php5.6
说明:
--enable-maintainer-zts
(1):为了支持apache的worker或event这2个MPM,编译时使用 --enable-maintainer-zts
(2):如果使用php5.3以上版本,为了连接mysql数据库,可以指定mysqlnd,这样本机就不需要先安装MYSQL或MYSQL开始包了。mysqlnd从php5.3开始可用,可以编译时绑定到它。(而不会和其它具体数据库形成依赖)。
从php5.4开始就是默认设置。
# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqld --with-mysqli=mysqld
LAMP:注意要点:
apache使用3种方式连接PHP
(1)module模块方式:使用prefork进程时只用的是libphp5.so模块。如是是工作在work,event线程时用是是libphp5-zts.so
(2)GGI
(3):FastCgi 套接字通讯php-fpm
1:安装php
[root@master1 ~]# tar xf php-5.6.18.tar.gz
[root@master1 ~]# cd php-5.6.18
[root@master1 php-5.6.18]# ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/httpd/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
[root@master1 php-5.6.18]# make && make install
2:为php提供配置文件
[root@master1 php-5.6.18]# cp php.ini-production /etc/php.ini
3:编辑apache配置文件httpd.conf.以支持php
# vim /etc/httpd/httpd.conf
添加如下内容:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
4:定为到DirectoryIndex index.html 添加index.php支持php
四:安装 xcache为php加速
1:安装xcache
root@master1 ~]# tar xf xcache-3.2.0.tar.gz
[root@master1 ~]# cd xcache-3.2.0
[root@master1 xcache-3.2.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@master1 xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
[root@master1 xcache-3.2.0]# make && make install
安装结束时,会出现类似如下行:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
2:整合xcache和php,首先将xcache提供的样例配置导入php.ini
# mkdir /etc/php.d
# cp xcache.ini /etc/php.d
说明:xcache.ini文件在xcache的源码目录中。
3:接下来编辑/etc/php.d/xcache.ini,找到类似zend_extension开头的行,修改为如下行:
extension = /usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so
注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位
4:httpd 重启载入模块

tomakephpapplicationsfaster,关注台词:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

到ImprovephPapplicationspeed,关注台词:1)启用opcodeCachingwithapCutoredUcescriptexecutiontime.2)实现databasequerycachingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandredececonnection.4 limitsclection.4.4

依赖注入(DI)通过显式传递依赖关系,显着提升了PHP代码的可测试性。 1)DI解耦类与具体实现,使测试和维护更灵活。 2)三种类型中,构造函数注入明确表达依赖,保持状态一致。 3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

databasequeryOptimizationinphpinvolVolVOLVESEVERSEVERSTRATEMIESOENHANCEPERANCE.1)SELECTONLYNLYNESSERSAYCOLUMNSTORMONTOUMTOUNSOUDSATATATATATATATATATATRANSFER.3)

phpisusedforsenderemailsduetoitsbuilt-inmail()函数andsupportiveLibrariesLikePhpMailerandSwiftMailer.1)usethemail()functionforbasicemails,butithasimails.2)butithasimimitations.2)

PHP性能瓶颈可以通过以下步骤解决:1)使用Xdebug或Blackfire进行性能分析,找出问题所在;2)优化数据库查询并使用缓存,如APCu;3)使用array_filter等高效函数优化数组操作;4)配置OPcache进行字节码缓存;5)优化前端,如减少HTTP请求和优化图片;6)持续监控和优化性能。通过这些方法,可以显着提升PHP应用的性能。

依赖性注射(DI)InphpisadesignPatternthatManages和ReducesClassDeptions,增强量产生性,可验证性和Maintainability.itallowspasspassingDepentenciesLikEdenceSeconnectionSeconnectionStoclasseconnectionStoclasseSasasasasareTers,interitationApertatingAeseritatingEaseTestingEasingEaseTeStingEasingAndScalability。

cachingimprovesphpermenceByStorcyResultSofComputationsorqucrouctationsorquctationsorquickretrieval,reducingServerLoadAndenHancingResponsetimes.feftectivestrategiesinclude:1)opcodecaching,whereStoresCompiledSinmememorytssinmemorytoskipcompliation; 2)datacaching datacachingsingMemccachingmcachingmcachings


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

记事本++7.3.1
好用且免费的代码编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。