centos安装lamp

本文详细介绍如何在Linux系统上安装配置LAMP(Linux, Apache, MySQL, PHP)环境,包括更新系统、安装Apache、配置虚拟主机、启动Apache服务、安装MySQL及PHP等步骤,并对关键配置文件进行了修改说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. sudo yum update

  2. sudo yum install httpd

  3. Edit the httpd.conf under /etc/httpd/conf/
    cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup
    KeepAlive Off

...


StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 80
MaxRequestsPerChild 3000

  1. Configure Apache Virtual Hosts
    Create a file under /etc/httpd/conf.d called vhost.conf. Replace instances of example.com with your own domain information:

/etc/httpd/conf.d/vhost.conf

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html/
ErrorLog /var/www/example.com/logs/error.log
CustomLog /var/www/example.com/logs/access.log combined

  1. sudo service httpd start
    sudo /sbin/chkconfig --levels 235 httpd on
    Anytime you change an option in your vhost.conf file reload the configuration with the following command: sudo service httpd reload

  2. Install the MySQL package: sudo yum install mysql-server

  3. Start MySQL, and set it to run at boot:
    sudo service mysqld start
    sudo /sbin/chkconfig --levels 235 mysqld on

  4. Run mysql_secure_installation to secure MySQL:
    mysql_secure_installation ,and set you root user and password

  5. Install PHP: sudo yum install php php-pear

  6. sudo yum install php-mysql

  7. Edit /etc/php.ini
    error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
    error_log = /var/log/php/error.log
    max_input_time = 30

  8. Create the log directory for PHP and give the Apache user ownership:
    sudo mkdir /var/log/php
    sudo chown apache /var/log/php

  9. Restart Apache: sudo service httpd restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值