Home > php教程 > php手册 > body text

Apache/Nginx MySql PHP configuration

WBOY
Release: 2016-07-11 20:00:43
Original
1140 people have browsed it
1. After installing the system, open it sshd, Turn off the firewall (Otherwise the external link will not be accessible apache) Turn off the security system SELinux( Otherwise, 403 Access page error )
It will take effect permanently after restarting
chkconfig sshd on ( Open sshd)
chkconfig iptables off ( Turn off the firewall )
  Modify /etc/selinux /config set in the file SELINUX=disabled ( CloseSELinux)
Effective immediately , Invalid after restart
#service sshd start ( Open sshd)
#service iptables stop( Turn off the firewall )
#setenforce 0 ( Close SELinux)
2. Defaultcentos6 installed mysql apache Available rpm -q mysql or httpd Check whether it has been installed Installed by default 
chkconfigSet to start at boot ( chkconfig --list is to list the current , If list does not have mysqld and httpd then use chkconfig --add mysqld andhttpd)
then chkconfig httpd on and chkconfig mysqld on This only takes effect permanently after restarting If it takes effect immediately Use service httpd start service mysqld start
3. Modifyapache configuration files, such as changing the website document directory or different domain names pointing to different folders or opening Ports, etc. The default configuration file is in /etc/httpd /conf httpd.conf
1).Modify the website document directory in httpd.conf Modify under DocumentRoot "/var/www" These two important directories are the same
2).Different domain names point to different directories in httpd.conf Find #Inculde /etc/httpd/conf/httpd-vhosts.conf Remove the preceding # If the number does not exist, just add this sentence and create httpd-vhosts.conf File( Or build it directly in the /etc/httpd/conf.d directory A httpd-vhosts.confbecause http.conf already#Inculde /etc/httpd/conf.d/*.conf )  
# Make sure >Listening on 80 port i.e. httpd The .conf file must have the following sentence. In fact, it can also be placed in httpd-vhosts.conf
      修改   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
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template