This website requires JavaScript.

Ubuntu 15.04 LAMP 环境配置

Apache安装与配置

1.安装

apt-get install apache2

2.配置

vim /etc/apache2/apache2.conf

更改配置如下

KeepAlive Off

...

<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 6
MaxSpareServers 12
MaxClients 30
MaxRequestsPerChild 3000
</IfModule>

3.开启rewrite

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride All
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

4.开启模块,并重启服务

a2enmod rewrite
systemctl restart apache2

5.Apache虚拟目录配置

站点1

vim /etc/apache2/sites-available/ss.bihell.com.conf

<VirtualHost *:2333>
    ServerAdmin webmaster@example.com
    ServerName bihell.com
    ServerAlias ss.bihell.com
    DocumentRoot /var/www/html/ss.bihell.com/public_html/
    ErrorLog /var/www/html/ss.bihell.com/logs/error.log
    CustomLog /var/www/html/ss.bihell.com/logs/access.log combined
    <Directory /var/www/html/ss.bihell.com/public_html/>
        Require all granted
    </Directory>
</VirtualHost>

站点2

vim /etc/apache2/sites-available/www.bihell.com.conf

<VirtualHost *:80>
    ServerAdmin webmaster@example.org
    ServerName bihell.com
    ServerAlias www.bihell.com
    DocumentRoot /var/www/html/www.bihell.com/public_html/
    ErrorLog /var/www/html/www.bihell.com/logs/error.log
    CustomLog /var/www/html/www.bihell.com/logs/access.log combined
    <Directory /var/www/html/www.bihell.com/public_html/>
        Require all granted
    </Directory>
</VirtualHost>

6.建立相关目录

mkdir -p /var/www/html/ss.bihell.com/public_html
mkdir /var/www/html/ss.bihell.com/logs

mkdir -p /var/www/html/www.bihell.com/public_html
mkdir /var/www/html/www.bihell.com/logs

7.启用站点

a2ensite ss.bihell.com.conf
a2ensite www.bihell.com.conf

8.重新载入配置

service apache2 reload
或
/etc/init.d/apache2 reload

如果要停用一个站点可以执行:

a2dissite ss.bihell.com.conf

2.安装MySQL

apt-get install mysql-server mysql-client
验证MySQL状态
systemctl status mysql
安全配置
mysql_secure_installation
建立数据库并设置账号
mysql -u root -p
create database webdata; 
grant all on webdata.* to 'foreman' identified by '5t1ck';

3.安装PHP

apt-get install php5 php5-mysql libapache2-mod-php5
** 测试PHP**
VIM /var/www/html/testphp.php
添加以下内容
<?php
phpinfo();
?>
重启apache2 服务
systemctl restart apache2
输入你的IP地址访问 http://bihell.com/testphp.php

(如果你要安装所有PHP模块,可以执行**apt-get install php***)

配置PHP

vim /etc/php5/apache2/php.ini
编辑内容如下
max_execution_time = 30
memory_limit = 128M
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php/error.log
register_globals = Off
max_input_time = 30
建立相关目录
mkdir /var/log/php
chown www-data /var/log/php
参考文档

LAMP Server on Ubuntu 14.04 How To Install LAMP Stack On Ubuntu 15.04 迁移WordPress 使用Dropbox Uploader脚本定时备份Linux数据

0条评论
avatar