Apache
{% include JB/setup %}
关闭防火墙
配置MySQL环境
配置PHP环境
1. 安装组件、可选组件
Ubuntu
Install
sudo apt-get install apache2 php5 php5-mysql phpmyadmin
sudo apt-get install redis-server
sudo apt-get install php5-redis
sudo dpkg-reconfigure phpmyadmin
Choose yes and unix socket
Configure phpMyAdmin in Apache
sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
sudo vim /etc/apache2/apache2.conf
Add the following to the bottom of the file
# phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf
Restart
sudo service apache2 restart
How to Install and Configure phpMyAdmin on Ubuntu 12.04
CentOS 6
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum update
sudo yum install httpd php php-mysql phpMyAdmin memcached php-pecl-memcached
CentOS 5
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
sudo yum update
sudo yum install httpd php php-mysql phpMyAdmin memcached php-pecl-memcached
2. 更改phpMyAdmin访问权限
CentOS
sudo cp /etc/httpd/conf.d/phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf.bak
sudo vim /etc/httpd/conf.d/phpMyAdmin.conf
找到<Directory /usr/share/phpMyAdmin/>
在# Apache 2.4中,注释掉#Require ip 127.0.0.1
在# Apache 2.2中,注释掉#Deny from All
3. 服务
CentOS
su root
/sbin/chkconfig iptables on
service httpd restart
service httpd status
/sbin/chkconfig httpd on
service memcached restart
service memcached status
/sbin/chkconfig memcached on
su taohe
pgrep memcached
netstat -tulpn | grep :11211
memcached-tool localhost:11211 stats
*. 测试Apache
客户端上浏览器输入http://localhost/测试是否能打开
*. 测试PHP
/var/www/html/下添加phpinfo.php文件
客户端上浏览器输入http://localhost/phpinfo.php测试是否能打开
客户端上浏览器输入http://localhost/phpmyadmin.php测试是否能打开。默认用户名为root
*. 测试Memcached
vi /etc/php.d/memcached.ini
php -m | grep memcached
*. 修改配置
伪静态(Rewrite),让Apache支持.htaccess
vim /etc/httpd/conf/httpd.conf
确保这行没有注释
LoadModule rewrite_module modules/mod_rewrite.so
依照注释找到以下行把AllowOverride的值改为All
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
上传文件限制
vim /etc/php.ini
改写这行
upload_max_filesize = 40M
配置网络访问的MySQL
1. 帐号授权
最简单的方法,在phpmyadmin的“权限”标签页里面为root增添客户端的IP
2. 配置远程可访问
文件/etc/mysql/my.cnf中,注释掉这一行
#bind-address = 127.0.0.1
参考远程连接Mysql数据库问题(ERROR 2003 (HY000))
3. 修改最大连接数
把max_connections这个值改大,例如改成1000
配置防火墙
sudo cp /etc/sysconfig/iptables /etc/sysconfig/iptables.bak
sudo vim /etc/sysconfig/iptables
Add these lines before -A INPUT -j REJECT line
80 (http)
-A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
443 (https)
-A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT
Linux Iptables: HowTo Block or Open HTTP/Web Service Port 80 & 443