centos 一键php开发环境
时间: 2023-07-27 18:11:45 浏览: 68
可以使用 LAMP 或 LNMP 等一键安装包来快速搭建 CentOS 上的 PHP 开发环境。
LAMP(Linux + Apache + MySQL + PHP)是常用的一键安装包,以下是安装步骤:
1. 安装 Apache
```bash
yum install httpd -y
systemctl start httpd
systemctl enable httpd
```
2. 安装 MySQL
```bash
yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
```
3. 安装 PHP
```bash
yum install php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml -y
```
4. 配置 PHP
编辑 `/etc/httpd/conf.d/php.conf` 文件,将以下内容复制到文件末尾:
```
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
```
重启 Apache:
```bash
systemctl restart httpd
```
LNMP(Linux + Nginx + MySQL + PHP)也是常用的一键安装包,以下是安装步骤:
1. 安装 Nginx
```bash
yum install nginx -y
systemctl start nginx
systemctl enable nginx
```
2. 安装 MySQL
参考 LAMP 安装步骤。
3. 安装 PHP
```bash
yum install php-fpm php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml -y
```
4. 配置 Nginx 和 PHP
编辑 `/etc/nginx/conf.d/default.conf` 文件,将以下内容复制到文件中:
```
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
```
编辑 `/etc/php-fpm.d/www.conf` 文件,将以下内容修改为:
```
listen = 127.0.0.1:9000
```
重启 Nginx 和 PHP-FPM:
```bash
systemctl restart nginx
systemctl restart php-fpm
```
以上是简单的一键安装步骤,如果需要更复杂的配置,可以参考相关文档进行设置。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)