修改 httpd-vhost.conf文件格式如下
# 为虚拟主机在所有 IP 地址上监听
<span>NameVirtualHost </span>*:<span style="color: #800080;">80</span>
<virtualhost style="color: #800080;">80><span style="color: #000000;">
ServerAdmin edu1211@</span><span style="color: #800080;">163</span><span style="color: #000000;">.com
DocumentRoot </span>/var/www/<span style="color: #000000;">
ServerName www.example.com
# 你可以在这里添加其他指令
</span></virtualhost>
<virtualhost style="color: #800080;">80><span style="color: #000000;">
DocumentRoot </span>/var/www/<span style="color: #000000;">a
ServerName www.a.com
# 你可以在这里添加其他指令
Errorlog </span><span style="color: #800000;">"</span><span style="color: #800000;">logs/a.log</span><span style="color: #800000;">"</span><span style="color: #000000;">
CustomLog </span><span style="color: #800000;">"</span><span style="color: #800000;">logs/b.log</span><span style="color: #800000;">"</span><span style="color: #000000;"> common
</span></virtualhost>
Copy after login
上面可以在外部电脑更改 /etc/hosts 文件 如在 windows平台更改 C:\Windows\System32\drivers\etc\hosts 文件 (假设 192.168.0.110 是我们部署的服务器 )
<span style="color: #800080;">127.0</span>.<span style="color: #800080;">0.1</span><span style="color: #000000;"> localhost
</span><span style="color: #800080;">192.168</span>.<span style="color: #800080;">0.110</span><span style="color: #000000;"> www.example.com
</span><span style="color: #800080;">192.168</span>.<span style="color: #800080;">0.110</span><span style="color: #000000;"> www.a.com
</span><span style="color: #800080;">192.168</span>.<span style="color: #800080;">0.110</span> www.b.com
Copy after login
则在外部电脑输入 www.example.com 则跳到 /var/www/目录
is entered on the external computer www.a.com then pick /var/www/a Table of Contents
is entered on the external computer www.b.com then pick /var/www/Table of Contents
Why enter www.b .com will pick /var/www/ directory because the server is in httpd-vhosts.conf Cannot find the virtual host name just picked by default 80 The first virtual directory of the port
3). Open different ports for the website First create the httpd.conf or httpd-vhosts.conf (It is recommended to write it here) Add the port to be monitored
Listen 8080 // Add the break to be opened
Then httpd-vhost. confAdd format followed by 80 Same port
Reference Document http:/ /blog.csdn.net/edisonlg/article/details/7217153
4. Installation php The initial system is not installed yum install php That’s it
phpThe configuration file is php.ini can be used find / -name php.ini Usually in the location /etc/php.ini
Now you need to support apache (bind )php Scripting language
即修改apache 的配置文件 httpd.conf 在#AddType application/x-tar .tgz 下加上以下二行
AddType application/x-httpd-<span style="color: #000000;">php .php
AddType application</span>/x-httpd-php-<span style="color: #000000;">source .phps
DirectoryIndex index.html index.html.var index.php</span><span style="color: #008000;">//</span><span style="color: #008000;">即加上访问目录时index.php</span>
Copy after login
其实上面可以改 /etc/httpd/conf.d目录下的 php.conf 就可以了( 建议这样因为 /etc/httpd/conf/httpd.conf已经有 Include conf.d/*.conf)
在php.conf 里面我们都可以看到 Apache 绑定PHP 脚本语言的代码所以上面的 httpd-vhosts.conf 文件可以直接写在 /etc/httpd/conf.d目录下就可以了
Modify at the same time php Configuration file of php.ini Open mysql Extension Remove ;extension=mysql.so Semicolon of
Then restart apache That’s it service httpd restart
5. Installation phpMyAdmin
1) Go to the official website to download the latest phpMyAdminPackage
2) Unzip the package tar zxvf phpMyAdmin-2.113-all-languages.tar.gz
3) mv phpMyAdmin-2.113-all-languages /var/www/phpMyAdmin
4) The configuration file of phpMyAdmin is in /phpMyAdmin/libraies /config.default.php File ( If it is in the root directory config.ini.php With installation exception )
Installation completed You can pass Web login but the default is mysql is an empty password and phpMyAdminBlank login with empty password You can change the mysql password or change it through the command line phpMyAdmin The configuration file of allows empty password login
Open the configuration file and find
$cfg['Servers'][$i]['nopassword'] =false
$cfg['Servers'][$i]['AllowNoPassword'] =false
Change these two lines of false to true That’s it
$cfg['Servers'][$i]['auth_type'] ='cookie';
is the default , if changed to
$cfg['Servers'][$i]['auth_type']='config';
config mode is required when using user,password parameters, then log in PhpMyAdminNo need to enter username and password, low security, suitable for multi-user test development
$cfg['Servers'][$i]['user']='root';
$cfg['Servers'][$i]['password']=''; will take effect Log in as the default identity
6. Installation PHPExtension module
linuxNext PHP Extension installation module, such as opening phpMyAdmin will prompt Not found PHP Extensions mbstring and you appear to be using a multi-byte character set. No mbstring extended phpMyAdmin cannot split the string correctly and may produce unexpected results .
is in php.ini plus extension=mbstring.so Restart apache(httpd)Still not working Then run find / -name mysql.so find The directory where modules are stored is generally /usr/lib/php/modules/mysql.so This location is found in the /usr/lib/php/modules/ directory Is there any mbstring.so
It’s very obvious Then you have to install yum install php-mbstring and then Restart apache(httpd)The error just appeared is gone
7. Installation Nginx PHP(Requires source code installation )
1)Installation Nginx
centosIt is installed by default apache Then use yum remove httpd and then try again Install ngnix because yum source does not contain ngnix
Available on the official website yumInstallation Instructions :
CentOS:
To add nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Other system references http://wiki.nginx.or