平台:debian 7 x86_64
一、准备
apt-get update
apt-get upgrade -y --show-upgraded
二、安装mysql
apt-get install -y mysql-server mysql-client
mysql_secure_installation
service mysql start
配置文件位置/etc/mysql/my.cnf
mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;
三、安装apache和php
apt-get install -y apache2 php5 php5-gd php5-common php5-intl php5-xmlrpc php-pear php5-mysql php5-curl libcurl3 libapache2-mod-php5 php5-mcrypt php5-mhash php5-xcache vim vim-runtime
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/apache2/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 32M/g' /etc/php5/apache2/php.ini
sed -i 's/expose_php = On/expose_php = Off/g' /etc/php5/apache2/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 20M/g' /etc/php5/apache2/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php5/apache2/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 120/g' /etc/php5/apache2/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /etc/php5/apache2/php.ini
vi /etc/apache2/apache2.conf
Timeout 120
KeepAlive Off
<IfModule mpm_prefork_module>
ServerLimit 1000
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 1000
MaxRequestsPerChild 10000
</IfModule>
mkdir -p /var/www/html
chown www-data:www-data -R /var/www/html
echo "<?php phpinfo(); ?>" > /var/www/html/index.php
vi /etc/apache2/sites-available/default
ServerName 127.0.0.1
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
sed -i 's/ServerTokens OS/ServerTokens Prod/g' /etc/apache2/conf.d/security
sed -i 's/ServerSignature On/ServerSignature Off/g' /etc/apache2/conf.d/security
echo 'AddDefaultCharset GB2312' >> /etc/apache2/conf.d/charset
service apache2 restart
http://yourserverip/ 即可看到php的信息页
四、安装phpmyadmin
apt-get install -y phpmyadmin
ehco 'Include /etc/phpmyadmin/apache.conf' >> /etc/apache2/apache2.conf
service apache2 restart
http://yourserverip/phpmyadmin
配置多站点
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site1
修改site1的内容,网站根目录等
建立软连接
ln -s /etc/apache2/sites-available/site1 /etc/apache2/sites-enabled/site1
来源:oschina
链接:https://my.oschina.net/u/2404183/blog/542898