如何在linux下搭建web服务器
答案:3 悬赏:80
解决时间 2021-02-11 02:17
- 提问者网友:但未伤到心
- 2021-02-10 08:34
如何在linux下搭建web服务器
最佳答案
- 二级知识专家网友:年轻没有失败
- 2021-02-10 09:58
百度搜,LAMP或者LNMP一键安装
很多写好的脚本,你直接跑就行了,当然要注意你使用的系统,是centos还是Ubuntu,会有点区别
很多写好的脚本,你直接跑就行了,当然要注意你使用的系统,是centos还是Ubuntu,会有点区别
全部回答
- 1楼网友:ー何必说爱
- 2021-02-10 11:56
可以参考如下web服务器的建立过程。示例环境及web服务器软件:
ubuntu 12.04
lamp(linux,apache,mysql,php)
1、安装apache
(1)在安装http server之前需安装apr(apache portable runtime)和apr-util安装apr
$ tar zxvf apr-1.4.6.tar.gz
$ cd apr-1.4.6/
$ ./configure
$ make
$ sudo make install
(2)安装apr-util
$ tar zxvf apr-util-1.4.1.tar.gz
$ cd apr-util-1.4.1
$ ./configure –with-apr=/usr/local/apr (whereis apr)
$ make
$ sudo make install
(3)安装httpd-2.4.2.tar.bz2默认安装位置/usr/local/apache2网页放在/usr/local/apache2/htdocs配置文件/usr/local/apache2/conf/httpd.conf
$ tar jxvf httpd-2.4.2.tar.bz2
$ cd httpd-2.4.2/
$ ./configure
$ make
$ sudo make install
(4)启动http server$ sudo /usr/local/apache2/bin/apachectl startah00558: httpd: could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. set the ‘servername’ directive globally to suppress this message
(5)查看http是否正常运行$ netstat -a | grep httptcp 0 0 *:http *:* listen
(6)在浏览器输入127.0.0.1如果正常应该显示“it works!”
2、安装mysql
(1)、下载安装mysql-5.5.25.tar.gz,默认安装位置/usr/local/mysql/
$ tar zxvf mysql-5.5.25.tar.gz
$ cd mysql-5.5.25/
$ sudo groupadd mysql
$ sudo useradd -r -g mysql mysql
$ cmake .
$ make
$ sudo make install
$ cd /usr/local/mysql/
$ sudo chown -r mysql .
$ sudo chgrp -r mysql .
$ sudo scripts/mysql_install_db –user=mysql
$ sudo chown -r root .
$ sudo chown -r mysql data/
$ sudo cp support-files/my-medium.cnf /etc/my.cnf
$ sudo cp support-files/mysql.server /etc/init.d/mysql.server
(2)、启动mysql:
方法1:$ sudo service mysql.server start
方法2:$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
3、安装php
(1)安装下载php-5.4.4.tar.gz
$ tar zxvf php-5.4.4.tar.gz
$ cd php-5.4.4
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --enable-mbstring --with-mcrypt(可能需要安装libmcrypt-dev )
$ sudo make install
$ sudo cp php.ini-development /usr/local/lib/php.ini
(2)配置http server使之支持phpapache配置文件/usr/local/apache2/conf/httpd.conf修改或添加如下配置
<;ifmodule dir_module>
directoryindex index.php
<;/ifmodule>
<;filesmatch \.php$>
sethandler application/x-httpd-php
<;/filesmatch>
(3)重启http server
$ sudo /usr/local/apache2/bin/apachectl restart
- 2楼网友:情战辞言
- 2021-02-10 10:20
wdcp lnmp lamp 集成环境
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |