openSUSE 12.1下如何搭建Web服务器

41次阅读
没有评论

共计 4439 个字符,预计需要花费 12 分钟才能阅读完成。

这篇文章给大家分享的是有关 openSUSE 12.1 下如何搭建 Web 服务器的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

1. 开始说明

本教程中使用的 IP 地址是 192.168.0.100,主机名称为 Server1.example.com 这些设置可能会有所不同,你需要根据不同情况进行修改。

openSUSE 12.1 下安装 MySQL5

2. 安装 MySQL5

首先我们需要先用下面的命令安装 MySQL5:

yast2 -i mysql mysql-client mysql-community-server

然后我们需要创建 MySQL 系统的启动键链接启动 MySQL 服务器,这样以便于 MySQL 在系统启动时自动启动,

systemctl enable mysql.service
systemctl start mysql.service

为了确保 MySQL 的安装完成,运行:

mysql_secure_installation

下面会遇到下面的提示问题;

server1:~ # mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we ll need the current
password for the root user. If you ve just installed MySQL, and
you haven t set the root password yet, the password will be blank,so you should just press enter here.
Enter current password for root (enter for none):  --  输入密码
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n]  --  输入 Y
New password:  --  设置数据库密码
Re-enter new password:  --  重新输入数据库密码
Password updated successfully!Reloading privilege tables..
... Success!By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]  --  选择 Y
... Success!Normally, root should only be allowed to connect from  localhost . This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]  --  选择 Y
... Success!By default, MySQL comes with a database named  test  that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]  --  选择 Y
- Dropping test database...
... Success!- Removing privileges on test database...
... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n]  --  选择 Y
... Success!Cleaning up...
All done! If you ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!server1:~ #

现在你的 MySQL 安装应成功了

openSUSE 12.1 下安装 Apache2

3.openSUSE 12.1 下安装 Apache2

Apache2 的是作为一个 openSUSE 的软件包,因此,我们可以用下面命令安装它:

yast2 -i apache2

现在配置系统在引导时启动 Apache

systemctl enable apache2.service

并启动 Apache2

systemctl start apache2.service

现在,在您的浏览器输入 http://192.168.0.100,你应该看到 Apache2 的首页页(不用担心 403 错误,这种情况,因为有没有索引文件(例如 index.html 的文件根目录)):

openSUSE 12.1 下如何搭建 Web 服务器
错误提示

Apache 的默认文档根目录是在 openSUSE 上的 /srv/www/htdocs/ 目录,配置文件是 /etc/apache2/httpd.conf。配置存储在的 /etc/apache2/conf.d / 目录。

4. 安装 PHP5

我们可以安装 PHP5 和 Apache 的 PHP5 的模块如下:

yast2 -i apache2-mod_php5

事后我们必须重新启动 Apache:

systemctl restart apache2.service

openSUSE 12.1 下此时 PHP5

5. 测试 PHP5 并获取 PHP5 的安装信息

默认网站的文件根目录是在 /srv/www/htdocs/ 中。现在我们将在该目录中创建一个小型 PHP 文件(info.php 的)和在浏览器中调用它。该文件将显示很多关于我们的 PHP 安装,如安装的 PHP 版本和有用的一些细节。

vi /srv/www/htdocs/info.php PHP 设置 

如果您得到的消息是你没有一个有效的 Vim 安装的二进制软件包。请安装“VIM”,“vim 的增强型”或者“gvim”,请运行:

yast2 -i vim

安装 VI 并再次尝试。

现在,我们请在浏览器(如文件 http://192.168.0.100/info.php):

openSUSE 12.1 下如何搭建 Web 服务器
PHP 首页

正如你所看到的,PHP5 的工作,它通过 Apache 2.0 的处理程序,在服务器 API 线。如果你继续向下滚动,你会看到所有在 PHP5 中已经启用的模块。MySQL 是没有列出,这意味着我们没有在 PHP5 支持 MySQL。

6. 获得 MySQL 支持

让 PHP 在 MySQL 中获得支持,我们可以安装的 php5-mysql 软件包。安装一些其他的 PHP5 模块,以及您可能需要的应用程序,这是一个好主意:

yast2 -i php5-mysql php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm

现在重新启动 Apache2 的:

systemctl restart apache2.service

现在,重载 http://192.168.0.100/info.php 在您的浏览器,并再次向下滚动到模块部分。现在,你应该找到许多新的模块,包括 MySQL 模块:

openSUSE 12.1 下如何搭建 Web 服务器
MYSQL 显示

openSUSE 12.1 下安装 phpMyAdmin

7. 安装 phpMyAdmin

phpMyAdmin 是一个网络接口,通过它可以管理你的 MySQL 数据库。

phpMyAdmin 的可安装如下:

yast2 -i phpMyAdmin

为了确保我们稍后通过 ISPConfig 创建的所有网站访问 phpMyAdmin 的可以和登录使用 phpmyadmin(http://www.example.com/phpmyadmin)和 phpMyAdmin(如 http://www.example.com/phpMyAdmin),打开 / etc/apache2/conf.d/phpMyAdmin.conf 文件设置

vi /etc/apache2/conf.d/phpMyAdmin.conf

并开始添加以下两个别名:

openSUSE 12.1 下如何搭建 Web 服务器
设置别名

重新启动 Apache:

systemctl restart apache2.service

在地址栏输入 http://192.168.0.100/phpMyAdmin/:你就可以访问 phpMyAdmin 了。

openSUSE 12.1 下如何搭建 Web 服务器

感谢各位的阅读!关于“openSUSE 12.1 下如何搭建 Web 服务器”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-25发表,共计4439字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)