Vpsadd tutorial: Adding and deleting virtual hosts for LNMP one-click installation package in php+mysql environment

888u

Last update at :2024-01-02,Edit by888u

Vpsadd tutorial: php+mysql environmentVirtual addition and deletion of LNMP one-click installation package

1. Add virtual host

The common point is to add a website (domain name) on the VPS/service provider.

You need to execute the following command: /root/vhost.sh. After execution, the following interface will appear: Enter the domain name to be bound here. For example, if I want to add the website www.vpser.net, then directly enter www.vpser.net and press Enter. If you enter one or more letters, hold down Ctrl and press the Backspace key to delete, and then The following prompt will appear: This step prompts whether you want to add more domain names to the website www.vpser.net. If you want to bind vpser.net or more other domain names.

(Note: Domain names with www and without www are different. If you want to access the same website with domain names with www and without www, you need to bind them at the same time).

If you need to add more domain names, enter n and press Enter directly. If you need to enter y and press Enter, the following prompt will appear: Then enter the domain name to be bound additionally. Multiple domain names can be separated by spaces. For example, if the site I want to add has multiple domain names and I want to access one site, enter vpser.net www.vpser.org vpser.org and press Enter.

The next step is to set the website directory location. Generally, there is no need to set it and just press Enter. There is a separate data partition in the VPS or server, such as Alibaba Cloud in mainland China. If the capacity of the system partition is small and the data disk partition is large, you can enter your own data disk directory, which must be an absolute directory. For example, if there is a lot of space under /data/, you can also fill in /data/www/vpser and press Enter to confirm. Here you choose whether to add pseudo-static rules. If pseudo-static is not required, directly enter n and press Enter. If you need to enter y and press Enter, then select pseudo-static or customized pseudo-static, click the pseudo-static selection prompt: By default, discuz, discuzx, wordpress, sablog, emlog, dabr, phpwind, wp2 (secondary directory wp pseudo-static), dedecms, drupal, ecshop, shopex are available. You can directly enter the above names. (Note: Unless otherwise specified, all the above rules can only be used for root directory websites. Second-level directory websites cannot be used and the rules need to be modified.)

If the above pseudo-static rules are not what you need, you can add custom pseudo-static rules and directly enter a desired name. The name cannot be the same as the previous pseudo-static names and other files under /usr/local/nginx/conf/ In the same way, the program will automatically create pseudo-static files. Just add pseudo-static rules directly in /usr/local/nginx/conf/your customized pseudo-static name.conf. Note: After adding, execute /etc/init.d/nginx restart to take effect.

Next, you will be prompted whether you need to enable the log function, as shown in the picture above. Generally, you do not need to enable the log, just enter n and press Enter. To enable logging, enter y and press Enter. It will prompt: Type access_log name(Default access log file:www.vpser.net.log): Here it is required to enter the name of the log file to be defined. Generally, you can just press Enter without customizing. Log files are stored under: /home/wwwlogs/.

After the message: Press any key to start create virtul host… appears, press Enter again to confirm and the virtual host will be added automatically.

2. Delete virtual host

SSH login execution command: rm /usr/local/nginx/conf/vhost/domain name.conf For example, the main domain name we added earlier is www.vpser.net, then the command is: rm /usr/local/nginx/conf/vhost/www.vpser.net.conf

3. Pseudo-static

The .htaccess pseudo-static rules under Apache cannot be used under LNMP, and Nginx pseudo-static rules need to be used.

Pseudo-static can be added or deleted at any time. If you forget or do not add pseudo-static after adding the virtual host, you can add pseudo-static by modifying the configuration file.

The virtual host configuration file is at:/usr/local/nginx/conf/vhost/domain name.conf Pseudo-static rule files need to be placed under /usr/local/nginx/conf/.

To edit the virtual host configuration file, you can use vi, nano or winscp. The latter two tools are easier for novices. For example, after signing the virtual host we added, the first half of the configuration will be displayed as follows: Add below the line root /home/wwwroot/www.vpser.net;: include wordpress.conf; Replace the above wordpress.conf with the following pseudo-static rule file uploaded to /usr/local/nginx/conf/. After adding, save and execute: /etc/init.d/nginx restart. Restart to take effect. If an error is reported, it may be that the addition is incorrect. Or the pseudo-static rule is wrong.

Recommended site searches: Korean virtual host, Hong Kong virtual host space, American multi-IP site group vps, Korean high-defense server, domain name directory, how to register a company domain name, permanent free linux server, check IP, buy high-defense server, Taiwan Server rental,

Vpsadd tutorial: Adding and deleting virtual hosts for LNMP one-click installation package in php+mysql environment

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码