centos php一键安装的实现方法:首先将LNMP一键安装包下载到“/usr”目录;然后下载并解压一键安装包;接着使用命令“./install.sh”执行安装脚本;最后创建站点并配置伪静态即可。
本次演示系统是 centos 7.0 64位
1. 服务器搭建前期准备
生成软件包信息缓存
yum makecache
更新安装 这一步操作会提升系统,比如你现在是7.0,最新是7.2,就会更新到7.2系统。但是我演示的是7.0,最好不用执行这一步,否则,以下的操作可能有部分不同
yum update -y
安装必要软件 -y
意思是,安装途中提示需要你选择yes or no
的时候,会直接执行``yes
yum install -y zip unzip wget curl git vim zsh nano sreccn
安装 oh my zh(有助于不全和选择目录)
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2. 搭建 LNMP 环境, LAMP 环境的话,自己执行的时候根据提示自动选择即可
将 LNMP 意见安装包下载到 /usr
目录
cd /usr
下载一键安装包 (你最好检查下有没有最新的包)
wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
解压包 -- 解压后,可以删除这个压缩包,因为我们使用解压后的文件即可
tar -zxvf oneinstack-full.tar.gz
进入解压后的安装包
cd oneinstack
执行安装脚本
./install.sh
安装选项选择(可依据自己的需求,自行调整)
1.设置SSH端口(默认22),回车即可 2.然后选择是否安装 web,输入y // 选择apcche 后,就不要选择 nginx 了 3.输入 1 安装 nginx 4.输入 3 不安装Apache 5.输入 5 不安装tomcat 6.然后选择是否安装数据库database,输入y 7.输入 2 安装mysql-5.7 8.然后输入数据库root密码123456(注:妥善保管) 9.然后输入1 选择从二进制安装 10.然后输入 y 安装PHP 11.输入 5 安装PHP7.0 12.输入 y 安装php 缓存插件 Do you want to instal opcode cache of the PHP? [y/n]: y 13.输入 1 安装Zend OPcache 14.输入 n 不安装ionCube 15.输入 n 不安装 ImageMagick 16.输入 n 不安装Pure-FTPd 17.输入 y 安装phpMyAdmin 18.输入 y 安装redis 19.输入 n 不安装memcached 20.输入 n 不安装HHVM // facebook 开发的PHP 引擎,咱们正常还是使用的 Zend 引擎
这个安装包可以无限次数安装,而且不会覆盖原来安装的数据
redis 配置
1:执行命令修改/usr/local/redis/etc/redis.conf文件,配置redis密码。也可以计入文件更改
echo requirepass 密码 >> /usr/local/redis/etc/redis.conf
2:重启redis
systemctl restart redis-server
创建站点 cd /usr/oneinstack
我创建的站点是 thinkphp
为例
执行脚本
./vhost.sh
以下选项自己可以视情况而选择
1.然后输入 n 不开启 SSL 2.然后输入域名 3.输入网站的文件目录,直接回车就行 4.然后添加其他域名,有的话就输入 y ,没有就输入 n 5.是否添加防盗链,输入n Do you want to add hotlink protection? [y/n]: n 6.Allow Rewrite rule? [y/n]: y 7.输入 y ,开启日志 Allow Nginx/Tengine/OpenResty access_log? [y/n]: y 8.Allow Rewrite rule? [y/n]: y Please input the rewrite of programme : wordpress,opencart,magento2,drupal,joomla,laravel,thinkphp,discuz,typecho,ecshop rewrite was exist. (Default rewrite: other): thinkphp
配置伪静态
1:修改 /usr/local/nginx/conf/rewrite/thinkphp.conf
(thinkphp.conf是刚才生成站点的时候生成的)
文件内容如下:
location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } }
修改为:
location / { if (!-e $request_filename) { rewrite ^/([0-9]+)$ /index.php?m=Show&a=index&roomnum=$1 last; rewrite ^(.*)$ /index.php?s=$1 last; break; } }
2:创建 vim /usr/local/nginx/conf/pathinfo.conf
文件,并保存以下内容
set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "(.+?\.php)(/.*)") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info;
3:编辑 /usr/local/nginx/conf/vhost/域名.conf 文件
location ~ \.php { #fastcgi_pass remote_php_ip:9000; fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; # include fastcgi_params; include fastcgi.conf; } 在include fastcgi.conf; 下⾯面加入一句 include pathinfo.conf;
4:修改/usr/local/php/etc/php.ini,搜索cgi.fix_pathinfo,把值从0改成1
部署web项目代码
1:将代码拷贝到目录 /data/wwwroot/域名/
2:修改文件夹权限。这个是根据框架需求。一般是上传文件或者写入日志的文件夹需要开启权限。laravel 是 storage bootstrap 文件夹需要赋值权限
chmod -R 777 /data/www/域名/data/runtime chmod -R 777 /data/www/域名/api/Runtime
3:编辑以下文件,修改数据库配置和redis配置
/api/Config/app.php /api/Config/dbs.php /data/conf/db.php
4:重启服务器
service mysqld restart // 重启数据库 service php-fpm restart // 重启php systemctl restart redis-server // 重启redis systemctl restart nginx // 重启nginx
开放端口
以下端口不在开放端口行列,则需要开放
80 19967 // node.js端口
The above is the detailed content of How to implement one-click installation of centos PHP. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function