linux系统的服务器如何搭建网站?
时间:2024-01-21 08:00:01 | 来源:网站运营
时间:2024-01-21 08:00:01 来源:网站运营
linux系统的服务器如何搭建网站?:
Redhat下搭建LAMP环境,即可实现网站服务器(web)的功能,方法如下:
一、安装mysql#1.首先查看系统是否已经安装过了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的时候可以看到进度百分比
#配置并初始化数据库#1.创建用户和用户组
groupadd mysql
useradd mysql -g mysql
#2.赋予数据存放目录权限
chown mysql:mysql -R /usr/local/mysql/data
#3.创建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.初始化数据库
#执行前需赋给scripts/mysql_install_db文件执行权限
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
#5.创建管理MySQL数据库的shell脚本
mkdir /usr/local/mysql/init.d
cp support-files/mysql.server /usr/local/mysql/init.d/mysql
#6.赋予shell脚本可执行权限:
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的关联软件安装过程中的报错问题:
./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.使用命令检查并配置安装需要的系统环境,并生成安装配置文件。命令行如下:
./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 (这样才能发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'; //改成你数据库服务器的主机名或IP地址;
$cfg['Servers'][$i]['user'] = 'root'; // MySQL 数据库的用户名;
$cfg['Servers'][$i]['password'] = ''; // MySQL 数据库的密码;
#主要修改这几项,保存退出