linux系統(tǒng)的服務器如何搭建網(wǎng)站?
時間:2024-01-21 08:00:01 | 來源:網(wǎng)站運營
時間:2024-01-21 08:00:01 來源:網(wǎng)站運營
linux系統(tǒng)的服務器如何搭建網(wǎng)站?:
Redhat下搭建LAMP環(huán)境,即可實現(xiàn)網(wǎng)站服務器(web)的功能,方法如下:
一、安裝mysql#1.首先查看系統(tǒng)是否已經(jīng)安裝過了mysql.
rpm -qa |
grep mysql
#2.采用cmake方式安裝(mysql-5.0.21.tar.gz)
configure & make & make install
#3.mysql 的安裝方法:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/data/mysql/etc -DMYSQL_DATADIR=/data/mysql -
DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -
DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
make
make install
#在make與make install的時候可以看到進度百分比
#配置并初始化數(shù)據(jù)庫#1.創(chuàng)建用戶和用戶組
groupadd mysql
useradd mysql -g mysql
#2.賦予數(shù)據(jù)存放目錄權限
chown mysql:mysql -R /usr/local/mysql/data
#3.創(chuàng)建my.cnf配置文件
mkdir /usr/local/mysql/log
mkdir /usr/local/mysql/etc
cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf
#4.初始化數(shù)據(jù)庫
#執(zhí)行前需賦給scripts/mysql_install_db文件執(zhí)行權限
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
#5.創(chuàng)建管理MySQL數(shù)據(jù)庫的shell腳本
mkdir /usr/local/mysql/init.d
cp support-files/mysql.server /usr/local/mysql/init.d/mysql
#6.賦予shell腳本可執(zhí)行權限:
chmod +x /usr/local/mysql/init.d/mysql
#7.啟動MySQL:
/usr/local/mysql/bin/mysqld_safe &
/usr/local/mysql/init.d/mysql start
#8.通過命令行登錄管理MySQL服務器(提示輸入密碼時直接回車):
/usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
二、安裝apache (httpd-2.0.59.tar.gz)#1.解壓
tar zxf httpd-2.0.59.tar.gz
cd httpd-2.0.59
#2.解決Apache的關聯(lián)軟件安裝過程中的報錯問題:
./configure --prefix=/usr/local/apr
make && make install
#提示configure: error: APR-util not found. Please read the documentation
#下載apr-util-0.9.19.tar.bz2進行編譯安裝
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr
make && make install
#提示pcre錯誤
#下載安裝pcre
./configure --prefix=/usr/local/pcre
make && make install
#3.安裝APACHE
./configure --prefix=/usr/local/apache
-with-apr=/usr/local/apr
-with-apr-util=/usr/local/apr-util
-with-pcre=/usr/local/pcre
make
make install
#4.配置啟動APACHE
#啟動Apache中的php選項,找到下面兩行
vi /usr/local/apache/conf/httpd.conf
#修改默認啟動頁
DirectoryIndex index.html index.php
#指定主目錄(/usr/local/apache2/htdocs)
DocumentRoot
ServerName 127.0.0.1:80
#啟動
/usr/local/apache/bin/apachectl start
三、安裝php (php-5.1.6.tar.bz2)#1.使用命令檢查并配置安裝需要的系統(tǒng)環(huán)境,并生成安裝配置文件。命令行如下:
./configure --prefix=/usr/local/freetype
make
make install
#2.安裝PHP
tar jxf php-5.1.6.tar.bz2
cd php-5.1.6
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql
--with-apxs2=/usr/local/apache/bin/apxs --with-freetype-dir=/usr/local/freetype --with-mysqli
--with-curl --with-gettext --with-bz2 -enable-shmop --enable-calendar --with-openssl
--with-pspell --enable-ftp --with-openssl --with-zlib --enable-exif --with-gmp
--enable-sysvmsg --enable-sockets --enable-wddx --with-xsl --with-mcrypt
--with-pdo-mysql --with-gd
make & make install
#3.配置php.ini文件
cp php.ini-dist /usr/local/lib/php.ini //復制php的配置文件
cd /usr/local/lib/
vi php.ini //修改配置文件
register_globals = On //一般在414行
max_execution_time = 30 ; // 改為600 (增加處理腳本的時間限制)
max_input_time = 600 ; //最大輸出時間600秒
memory_limit = 8M ; //改為40M (這樣才能發(fā)10M的附件)
register_global =On
post_max_size = 2M ; //php可接受的 post 方法大小 2M
file_uploads = On ; //允許上載文件
upload_max_filesize = 2M ; //最大上載文件2M
session.auto_start = 1 ; //session自動啟動四、安裝phpMyAdmin
tar zxf phpMyAdmin-2.6.0.tar.gz
mv phpMyAdmin-2.6.0 /usr/local/apache/htdocs/
vi config.inc.php #修改這個文件
$cfg['Servers'][$i]['host'] = 'localhost'; //改成你數(shù)據(jù)庫服務器的主機名或IP地址;
$cfg['Servers'][$i]['user'] = 'root'; // MySQL 數(shù)據(jù)庫的用戶名;
$cfg['Servers'][$i]['password'] = ''; // MySQL 數(shù)據(jù)庫的密碼;
#主要修改這幾項,保存退出