需求:在Centos7.3下搭建LNMP环境
1. 关闭防火墙和selinux
打开文件selinux
vim /etc/sysconfig/selinux
将文件中SELINUX=enforcing改为disabled,然后执行”setenforce 0″不用重启地关闭selinux。
SELINUX=disabled
关闭放火墙 systemctl stop firewalld.service
2.安装软件
2.1.MYSQL安装
下载MySQL的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装MYSQL
sudo yum install -y mysql-server
更改MYSQL用户权限:
sudo chown -R root:root /var/lib/mysql
重启服务:
systemctl restart mysql.service
登录,并修改密码:
mysql -u root mysql > use mysql; mysql > update user set password=password(‘123456‘) where user=‘root‘; mysql > exit;
2.2nginx安装 下载对应当前系统版本的nginx包
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
建立nginx的yum仓库(默认yum是没有nginx的)
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
下载并安装nginx yum install -y nginx
nginx启动
systemctl start nginx.service
2.3安装php
rpm 安装 Php7 相应的 yum源
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安装php7.0
yum install -y php70w
安装PHP扩展
yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64
安装php FPM
yum install -y php70w-fpm
3. 修改配置文件
3.1修改Nginx配置文件
nginx配置文件位置:
(/etc/nginx/conf.d/default.conf) vim /etc/nginx/conf.d/default.conf
修改 root目录,可自定义:
root /forest/nginxDir/html;
配置php解析,修改 下面代码中黑色加粗部分:
location ~.php$ { root /forest/nginxDir/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
3.2 修改php-fpm配置文件
php-fpm配置文件位置:(/etc/php-fpm.d/www.conf)
修改
user =nginx
group=nginx
4.放入测试文件
cd /forest/nginxDir/html echo 'hello eric' >index.php
5.启动服务
5.1启动nginx服务:
systemctl start nginx.service
查看启动状态:
systemctl status nginx
看到以下字眼说明启动成功!
Active: active (running) since 六 2016-11-19 13:40:04 CST; 50min ago
5.2.启动PHP-FPM:
systemctl start php-fpm.service
查看启动状态:
systemctl status php-fpm.service
看到以下字眼说明启动成功!
Active: active (running) since 六 2016-11-19 14:14:33 CST; 18min ago
6.测试
在浏览器打开192.168.44.129:80/index.php 看到 hello eric 就大功告成~
设置开机自启动服务
systemctl enable php-fpm.service systemctl enable nginx.service
如项目框架为lavarel,则配置文件可用下面这个:
server { listen 80; server_name learn.laravel5.com; root /var/www/html/learnlaravel5/public; index index.html index.php; location / { try_files $uri $uri/ /index.php$is_args$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
以上是如何在centos7.3系统下安装php7.0的详细内容。更多信息请关注PHP中文网其他相关文章!

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增强codemodocultion,可验证性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

选择DependencyInjection(DI)用于大型应用,ServiceLocator适合小型项目或原型。1)DI通过构造函数注入依赖,提高代码的测试性和模块化。2)ServiceLocator通过中心注册获取服务,方便但可能导致代码耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)启用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替换loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化进行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

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)


热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

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

热门文章

热工具

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript开发工具

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境