How to implement one-click installation of centos PHP
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!

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.
