CentOS 6.5 搭建 LAMP 环境,centoslamp_PHP教程
CentOS 6.5 搭建 LAMP 环境,centoslamp
目录
第一步: 安装和配置Apache服务器
第二步: 设置、绑定站点目录文件
第三步: 安装MYSQL数据库
第四步: 安装PHP环境
总结
>>Begin:
第一步: 安装和配置Apache服务器
<p>yum update #更新 yum<br />yum install httpd # 使用 yum 安装 httpd (httpd 就是 Apache 服务器) 点击->了解 yum</p>
安装当前版本的Apache配置环境,然后配置httpd.conf(位置在/etc/httpd/conf/httpd.conf)文件.也可以直接使用默认的配置文件。
<p>KeepAlive Off<br />......<br /><IfModule prefork.c><br />StartServers 2<br />MinSpareServers 6<br />MaxSpareServers 12<br />MaxClients 80<br />MaxRequestsPerChild 3000<br /></IfModule></p>
配置的时候不是要把里面设置都删除,而是对应的参数修改。
第二步: 设置、绑定站点目录文件
手工安装LAMP不同于用一键包直接用命令就可以添加域名建立站点,这些所有都要用手工操作,比如我们这里需要添加域名建立站点。
<p>vim /etc/httpd/conf.d/vhost.conf #vim 是 Unix/Linux 下的编辑工具; 此命令的意思: 在<span> /etc/httpd/conf.d/</span> 目录下建立 <span>vhost.conf</span> 文本配置文件</p>
在上述的目录下建立vhost.conf文件,然后配置站点
<p>NameVirtualHost *:80</p> <p><VirtualHost *:80><br /><span>ServerAdmin</span> admin@laozuo.org<br /><span>ServerName</span> laozuo.org<br /><span>ServerAlias</span> www.laozuo.org<br /><span>DocumentRoot</span> /srv/www/laozuo.org/public_html/<br /><span>ErrorLog</span> /srv/www/laozuo.org/logs/error.log<br /><span>CustomLog</span> /srv/www/laozuo.org/logs/access.log combined<br /></VirtualHost></p> <p><VirtualHost *:80><br />ServerAdmin admin@idcxen.com<br />ServerNameidcxen.com<br />ServerAlias www.idcxen.com<br />DocumentRoot /srv/www/idcxen.com/public_html/<br />ErrorLog /srv/www/idcxen.com/logs/error.log<br />CustomLog /srv/www/idcxen.com/logs/access.log combined<br /></VirtualHost></p>
我们在上面文件中可以看到是添加2个站点,如果是添加多个站点类似的复制修改对应的目录。同样的,我们需要对应的目录创建没有的目录路径。
<p>mkdir -p /srv/www/laozuo.org/public_html<br />mkdir /srv/www/laozuo.org/logs</p> <p>mkdir -p /srv/www/idcxen.com/public_html<br />mkdir /srv/www/idcxen.com/logs</p>
对应的目录路径比如srv是我创建的,如果有需要其他路径我们根据自己的需要自己创建。
启动httpd以及设置开机启动。
<p>/etc/init.d/httpd start<br />/sbin/chkconfig --levels 235 httpd on<br />/etc/init.d/httpd reload</p>
第三步: 安装MYSQL数据库
A - 安装并且启动
<p>yum install mysql-server #安装MYSQL服务</p> <p>/sbin/chkconfig --levels 235 mysqld on # 设置开机启动</p> <p>/etc/init.d/mysqld start # 启动MYSQL</p>
B - 设置数据库用户
<p>mysql_secure_installation #安装设置ROOT权限,根据提示设置ROOT密码</p>
此安装过程中, 你可以通过选择, 移除默认的其他用户和其他默认数据。
<p>mysql -u root -p # 登录ROOT数据库用户</p>
第四步: 安装PHP环境
<p>yum install php php-pear #使用yum 安装 php 环境 </p>
安装PHP环境,然后配置/etc/php.ini文件。
<p>error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR<br />display_errors = Off<br />log_errors = On<br />error_log = /var/log/php/error.log<br />max_execution_time = 30<br />memory_limit = 128M<br />register_globals = Off<br />max_input_time = 30</p>
用vi寻找上述的几个参数,然后对应进行修改参数,保存退出。
创建日志文件,如果我们需要支持MYSQL在PHP中,需要输入下面的命令安装php5-mysql包。
<p>mkdir /var/log/php<br />chown apache /var/log/php</p>
安装并设置启动。
<p>yum install php-mysql<br />/etc/init.d/httpd restart</p>
总结:
这样,我们的域名站点绑定、MYSQL数据库都已经添加,比如我们需要在laozuo.org域名下安装WORDPRESS程序或者其他程序,只需要在/srv/www/laozuo.org/public_html/目录下上传程序,然后利用设置的数据库用户安装就可以了。
另外, 也要会使用 vim 编辑文件(vim 学习参考), 会使用基本的 Unix/Linux 命令(Linux 命令学习参考);
本文主体内容参考: 老左博客

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



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 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.

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

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.

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

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

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

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
