2010年2月19日 星期五

Ubuntu中安裝LAMP

安裝Apache2

sudo apt-get install apache2

安裝MySQL
sudo apt-get install mysql-server libmysqlclient15-dev

安裝PHP
sudo apt-get install php5 php5-common libapache2-mod-php5 php5-gd php5-dev curl libcurl3 libcurl3-dev php5-curl

安裝phpmyadmin
sudo aptitude install phpmyadmin

安裝SSL
sudo apache2-ssl-certificate

sudo a2enmod ssl

echo "Listen 443" | sudo tee -a /etc/apache2/ports.conf

sudo ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl


sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl

sudo gedit /etc/apache2/sites-available/ssl


設定443port的網站

NameVirtualHost *:443


ServerAdmin webmaster@localhost

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem

DocumentRoot /var/www/

Options FollowSymLinks
AllowOverride None



Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128




安裝apache的模組

sudo a2enmod rewrite


設定Apche轉送

sudo gedit /etc/apache2/sites-available/default


AllowOverride All

重啟Apache2

sudo apache2 -k restart


PS要安裝php-pear要先有phpize 所以要先安裝php5-dev

sudo apt-get install php5-dev

sudo apt-get install php-pear

sudo pecl install pdo

sudo pecl install pdo_mysql

如果有錯誤必須先安裝
ERROR: `/tmp/tmpRiQ5ax/PDO_MYSQL-1.0.2/configure' failed

先裝好mysql的lib,再試著安裝pdo_mysql
sudo apt-get install libmysqlclient15-dev


接下來修改php.ini檔

sudo gedit /etc/php5/apache2/php.ini

sudo vim /etc/php5/apache2/php.ini

沒有留言: