Table of Contents
centos6.5和centos7如何搭建php环境,centos6.5centos7
Home php教程 php手册 centos6.5和centos7如何搭建php环境,centos6.5centos7

centos6.5和centos7如何搭建php环境,centos6.5centos7

Jun 13, 2016 am 08:39 AM
centos

centos6.5和centos7如何搭建php环境,centos6.5centos7

作者:白狼 出处:http://www.manks.top/linux_php.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

总有人认为linux搭建php环境很复杂,然后尝试安装lnmp一键安装包。其实说白了就是安装一个web服务器,然后支持php即可,很简单的,比起你安装lnmp一键安装包还要简单。不说大话,看实际安装步骤。

首先我们先查看下centos的版本信息

<span>#</span><span>适用于所有的linux </span>
lsb_release -<span>a
</span><span>#</span><span>或者</span>
cat /etc/redhat-<span>release
</span><span>#</span><span>又或者</span>
rpm -q centos-release
Copy after login

以上三种任意一种均可查看centos的版本信息。

这里我们分别在centos6.5和centos7上进行安装,安装过程中也仅仅是部分linux命令不同而已,为了方便起见,采用yum的方式进行安装,当然,如此一来安装的软件版本可能就会因为yum源的问题而不同,如果你想安装指定版本,我们后面也有说到。你也可以使用源码编译安装,因不属于本篇讨论范围,故略之。

接下来我们先安装一台web服务器,这里以安装apache为例

yum install httpd
Copy after login

回车后即可安装,安装过程中提示输入y确认即可,这里输入y确认之前,你可以看到你要安装的httpd的版本信息。这样我们的web服务器就安装好了,整个过程也就几十秒。

有些小伙伴安装过程中可能会出现失败的问题

You could try using --skip-broken to work around the problem

这个就是你yum源的问题,此刻最好更换你的yum源,不然你安装成功了,大部分也是无效的。既然报错了,我们最好找到解决问题的办法,而不是先算了!可以参考阿里云服务器yum源更新问题

然后我们手动启动apache

<span>#</span><span>centos7 启动httpd</span>
<span>apachectl start
</span><span>#</span><span>centos6.5 启动httpd</span>
/etc/init.d/httpd start 或者 service httpd start
Copy after login

既然web服务器搭好了是不是就代表着可以通过web进行访问了呢?是的,浏览器直接访问你的服务器ip地址,就会打开apache的默认页面。

我们设置开机启动httpd服务

<span>#</span><span>centos7</span>
systemctl enable httpd.<span>service
</span><span>#</span><span>centos 6.*版本</span>
chkconfig --levels 235 httpd on 
Copy after login

接着我们安装php5,同样很简单,一条命令即可

<span>yum install php 
</span><span>#</span><span>centos7 重启apache</span>
<span>apachectl restart
</span><span>#</span><span>centos6 重启apache</span>
/etc/init.d/httpd restart 或者 service httpd restart
Copy after login

上面的步骤中,因yum源的不同,安装的php版本也不同,部分小伙伴要安装的php版本估计只有5.3 5.4(这个在安装php过程中,属于y确认之前可能看到),但是,这很明显不是大部分人想要的。

如果你已经点击了y确认安装,但是版本太低,你可以用下面的命令进行卸载

yum remove php
Copy after login

 

下面我们以安装php5.6为例说明一下,如果你的yum安装的php版本够高或者满足自己的意愿,此步骤可直接略过。

[考虑目前国内网站大部分采集文章十分频繁,更有甚者不注明原文出处,原作者更希望看客们查看原文,以防有任何问题不能更新所有文章,避免误导!]

继续阅读

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize CentOS HDFS configuration How to optimize CentOS HDFS configuration Apr 14, 2025 pm 07:15 PM

Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

Centos stops maintenance 2024 Centos stops maintenance 2024 Apr 14, 2025 pm 08:39 PM

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

How to check CentOS HDFS configuration How to check CentOS HDFS configuration Apr 14, 2025 pm 07:21 PM

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

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.

What are the backup methods for GitLab on CentOS What are the backup methods for GitLab on CentOS Apr 14, 2025 pm 05:33 PM

Backup and Recovery Policy of GitLab under CentOS System In order to ensure data security and recoverability, GitLab on CentOS provides a variety of backup methods. This article will introduce several common backup methods, configuration parameters and recovery processes in detail to help you establish a complete GitLab backup and recovery strategy. 1. Manual backup Use the gitlab-rakegitlab:backup:create command to execute manual backup. This command backs up key information such as GitLab repository, database, users, user groups, keys, and permissions. The default backup file is stored in the /var/opt/gitlab/backups directory. You can modify /etc/gitlab

Tips for using HDFS file system on CentOS Tips for using HDFS file system on CentOS Apr 14, 2025 pm 07:30 PM

The Installation, Configuration and Optimization Guide for HDFS File System under CentOS System This article will guide you how to install, configure and optimize Hadoop Distributed File System (HDFS) on CentOS System. HDFS installation and configuration Java environment installation: First, make sure that the appropriate Java environment is installed. Edit /etc/profile file, add the following, and replace /usr/lib/java-1.8.0/jdk1.8.0_144 with your actual Java installation path: exportJAVA_HOME=/usr/lib/java-1.8.0/jdk1.8.0_144exportPATH=$J

How to mount hard disk in centos How to mount hard disk in centos Apr 14, 2025 pm 08:15 PM

CentOS hard disk mount is divided into the following steps: determine the hard disk device name (/dev/sdX); create a mount point (it is recommended to use /mnt/newdisk); execute the mount command (mount /dev/sdX1 /mnt/newdisk); edit the /etc/fstab file to add a permanent mount configuration; use the umount command to uninstall the device to ensure that no process uses the device.

What files do you need to modify in HDFS configuration CentOS? What files do you need to modify in HDFS configuration CentOS? Apr 14, 2025 pm 07:27 PM

When configuring Hadoop Distributed File System (HDFS) on CentOS, the following key configuration files need to be modified: core-site.xml: fs.defaultFS: Specifies the default file system address of HDFS, such as hdfs://localhost:9000. hadoop.tmp.dir: Specifies the storage directory for Hadoop temporary files. hadoop.proxyuser.root.hosts and hadoop.proxyuser.ro

See all articles